small bug in the process data

This commit is contained in:
MrKarimiD committed 2024-07-08 10:46:06 -04:00
1 parent d9d7d0baa2
commit 9cb44e6598
1 file changed
+14 -2
+14 -2
View File
@@ -215,6 +215,7 @@ def copy_images_list(
verbose: bool = False, verbose: bool = False,
upscale_factor: Optional[int] = None, upscale_factor: Optional[int] = None,
nearest_neighbor: bool = False, nearest_neighbor: bool = False,
use_folder_name: bool = False,
) -> List[Path]: ) -> List[Path]:
"""Copy all images in a list of Paths. Useful for filtering from a directory. """Copy all images in a list of Paths. Useful for filtering from a directory.
Args: Args:
@@ -241,11 +242,21 @@ def copy_images_list(
for idx, image_path in enumerate(image_paths): for idx, image_path in enumerate(image_paths):
if verbose: if verbose:
CONSOLE.log(f"Copying image {idx + 1} of {len(image_paths)}...") CONSOLE.log(f"Copying image {idx + 1} of {len(image_paths)}...")
copied_image_path = image_dir / f"frame_{idx + 1:05d}{image_path.suffix}" # copied_image_path = image_dir / f"frame_{idx + 1:05d}{image_path.suffix}"
if use_folder_name:
if "left_e1" in str(image_path.parent):
copied_image_path = image_dir / Path('left_e1_' + str(image_path.name))
elif "right_e2" in str(image_path.parent):
copied_image_path = image_dir / Path('right_e2_' + str(image_path.name))
else:
assert("The folder name should be left_e1 or right_e2")
else:
copied_image_path = image_dir / image_path.name
try: try:
# if CR2 raw, we want to read raw and write TIFF, and change the file suffix for downstream processing # if CR2 raw, we want to read raw and write TIFF, and change the file suffix for downstream processing
if image_path.suffix.lower() in ALLOWED_RAW_EXTS: if image_path.suffix.lower() in ALLOWED_RAW_EXTS:
copied_image_path = image_dir / f"frame_{idx + 1:05d}{RAW_CONVERTED_SUFFIX}" # copied_image_path = image_dir / f"frame_{idx + 1:05d}{RAW_CONVERTED_SUFFIX}"
copied_image_path = image_dir / image_path.name
with rawpy.imread(str(image_path)) as raw: with rawpy.imread(str(image_path)) as raw:
rgb = raw.postprocess() rgb = raw.postprocess()
imageio.imsave(copied_image_path, rgb) imageio.imsave(copied_image_path, rgb)
@@ -257,6 +268,7 @@ def copy_images_list(
copied_image_paths.append(copied_image_path) copied_image_paths.append(copied_image_path)
nn_flag = "" if not nearest_neighbor else ":flags=neighbor" nn_flag = "" if not nearest_neighbor else ":flags=neighbor"
if num_downscales > 0:
downscale_chains = [f"[t{i}]scale=iw/{2**i}:ih/{2**i}{nn_flag}[out{i}]" for i in range(num_downscales + 1)] downscale_chains = [f"[t{i}]scale=iw/{2**i}:ih/{2**i}{nn_flag}[out{i}]" for i in range(num_downscales + 1)]
downscale_dirs = [Path(str(image_dir) + (f"_{2**i}" if i > 0 else "")) for i in range(num_downscales + 1)] downscale_dirs = [Path(str(image_dir) + (f"_{2**i}" if i > 0 else "")) for i in range(num_downscales + 1)]
downscale_paths = [ downscale_paths = [