mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-07 00:09:14 +08:00
Improve process data with filename filters and saving mp4s (#756)
* Updated Discord link * ns-process-data to grab only jpg and png * Updated alert for an incorrect folder * minor format updates * black Co-authored-by: Nik Ska <dokluch@gmail.com>
This commit is contained in:
1 parent
3acb1201f2
commit
569a698d4e
1 file changed
+16
-8
+16
-8
@@ -156,16 +156,19 @@ def copy_images(data: Path, image_dir: Path, verbose) -> int:
|
|||||||
Returns:
|
Returns:
|
||||||
The number of images copied.
|
The number of images copied.
|
||||||
"""
|
"""
|
||||||
image_paths = sorted(data.glob("*"))
|
allowed_exts = [".jpg", ".jpeg", ".png", ".tif", ".tiff"]
|
||||||
idx = 0
|
image_paths = sorted([p for p in data.glob("[!.]*") if p.suffix.lower() in allowed_exts])
|
||||||
|
|
||||||
|
# Remove original directory only if we provide a proper image folder path
|
||||||
|
if image_dir.is_dir() and len(image_paths):
|
||||||
|
shutil.rmtree(image_dir, ignore_errors=True)
|
||||||
|
image_dir.mkdir(exist_ok=True, parents=True)
|
||||||
|
|
||||||
# Images should be 1-indexed for the rest of the pipeline.
|
# Images should be 1-indexed for the rest of the pipeline.
|
||||||
for image_path in image_paths:
|
for idx, image_path in enumerate(image_paths):
|
||||||
if image_path.name.startswith("."):
|
|
||||||
continue
|
|
||||||
idx += 1
|
|
||||||
if verbose:
|
if verbose:
|
||||||
CONSOLE.log(f"Copying image {idx} of {len(image_paths)}...")
|
CONSOLE.log(f"Copying image {idx + 1} of {len(image_paths)}...")
|
||||||
shutil.copy(image_path, image_dir / f"frame_{idx:05d}{image_path.suffix}")
|
shutil.copy(image_path, image_dir / f"frame_{idx + 1:05d}{image_path.suffix}")
|
||||||
|
|
||||||
return len(image_paths)
|
return len(image_paths)
|
||||||
|
|
||||||
@@ -420,9 +423,14 @@ def main(
|
|||||||
num_frames = copy_images(data, image_dir=image_dir, verbose=verbose)
|
num_frames = copy_images(data, image_dir=image_dir, verbose=verbose)
|
||||||
else:
|
else:
|
||||||
num_frames = copy_images(data, image_dir=image_dir, verbose=verbose)
|
num_frames = copy_images(data, image_dir=image_dir, verbose=verbose)
|
||||||
|
|
||||||
|
if num_frames == 0:
|
||||||
|
CONSOLE.log("[bold red]:tada: No usable images in the data folder.")
|
||||||
|
else:
|
||||||
CONSOLE.log("[bold green]:tada: Done copying images.")
|
CONSOLE.log("[bold green]:tada: Done copying images.")
|
||||||
summary_log.append(f"Starting with {num_frames} images")
|
summary_log.append(f"Starting with {num_frames} images")
|
||||||
|
|
||||||
|
if num_frames > 0:
|
||||||
if num_downscales > 0:
|
if num_downscales > 0:
|
||||||
if not verbose:
|
if not verbose:
|
||||||
with CONSOLE.status("[bold yellow]Downscaling images...", spinner="growVertical"):
|
with CONSOLE.status("[bold yellow]Downscaling images...", spinner="growVertical"):
|
||||||
|
|||||||
Reference in new issue
Block a user