Add recursive
option to upsample_imagefolder
#154
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.