This PR implements a recursive option to RealESRGANModel.upsample_imagefolder such that all images in subdirectories inside the input directories are upscaled. Currently, only images one level down the input directory are upscaled. This is relevant to this project because StableDiffusionWalkPipeline.walk creates subdirectories of images inside the output directory.
Example: the user just created a video using the following code:
Now the user wishes to upscale all the images. Calling RealESRGANModel.upsample_imagefolder(in_dir="dreams/cats", out_dir="path/to/output_dir") currently does nothing as there are no images inside dreams/cats/ (the images are in subfolders). The user currently needs to call the method for each subfolder inside dreams/cats/. This PR allows the user to provide recursive=True to upscale all images in subfolders without having to call the method for each subfolder. The output directory then presents the same structure as the input directory:
Added a force option to allow overwriting of output files. Currently, output files are overwritten. With this PR, the default behavior is to skip if the output file already exists, unless force=True is provided.
Added logging. Logs tell if the image is skipped or upscaled, and the current progress (current image number over total number of images)
This PR implements a
recursive
option toRealESRGANModel.upsample_imagefolder
such that all images in subdirectories inside the input directories are upscaled. Currently, only images one level down the input directory are upscaled. This is relevant to this project becauseStableDiffusionWalkPipeline.walk
creates subdirectories of images inside the output directory.Example: the user just created a video using the following code:
Now the directory
dreams/
looks like this:Now the user wishes to upscale all the images. Calling
RealESRGANModel.upsample_imagefolder(in_dir="dreams/cats", out_dir="path/to/output_dir")
currently does nothing as there are no images insidedreams/cats/
(the images are in subfolders). The user currently needs to call the method for each subfolder insidedreams/cats/
. This PR allows the user to providerecursive=True
to upscale all images in subfolders without having to call the method for each subfolder. The output directory then presents the same structure as the input directory:Other additions:
force
option to allow overwriting of output files. Currently, output files are overwritten. With this PR, the default behavior is to skip if the output file already exists, unlessforce=True
is provided.