The original InstantID tool is currently limited to processing a single image per execution. The preprocess.py module overcomes this limitation, enabling batch image processing. This enhancement allows for the continuous generation of stylized images by hijacking the initial loader function to preprocess and manage multiple images in sequence.
The heart of this upgrade lies in the ability to loop through an entire folder of images (sample_images), applying a diverse set of styles and parameters to each image. With this ability, users can maximize the utility of InstantID by processing large datasets without manual intervention.
Users can define and experiment with ranges of values for various parameters to discover the optimal settings:
This structured variety helps find the sweet spot for each image, allowing for you to find the right customization:
IDENTITYNET_STRENGTH_RATIO_RANGE = (1.0, 1.5)
ADAPTER_STRENGTH_RATIO_RANGE = (0.7, 1.0)
NUM_INFERENCE_STEPS_RANGE = (40, 60)
GUIDANCE_SCALE_RANGE = (7.0, 12.0)
...
Additionally, the script can loop through predefined or random styles, applying each to the set of images to generate a rich array of results.
Efficient image preparation is vital for achieving consistent results. The preprocess.py module employs resize_and_pad_image to standardize all images to the same dimensions, ensuring uniformity across the batch, ready for further processing by InstantID.
The module randomly selects images from the sample_images directory, ensuring an unbiased and varied selection for processing. This feature is particularly useful when dealing with large collections of images.
Each processed image's configuration and outcomes are meticulously logged in a CSV file (default generation_log.csv). This log includes key details like identity and adapter strength ratios, the number of inference steps, guidance scale, and any error messages.
As the batch processing unfolds, preprocess.py provides real-time feedback in the console, displaying time remaining, progress of values, and overall statistics. This immediate insight into the batch progress is crucial for efficient workflow management.
After batch processing, users can opt to open up Gradio for fine-tuned, one-off image processing. This flexibility marries the robustness of batch processing with the refinement of individual image customization.
from preprocess import initial_image, generate_image
initial_image(generate_image)
preprocess.py transforms the InstantID tool into a powerhouse of batch image processing. By extending the original script to handle multiple images, providing detailed logs, and integrating with Gradio for one-off customizations, this module unlocks the full potential of the InstantID pipeline for users and researchers alike.
For more details on InstantID, refer to the official project page and associated research paper:
1 commits
Python
99.3%
The original InstantID tool is currently limited to processing a single image per execution. The preprocess.py module overcomes this limitation, enabling batch image processing. This enhancement allows for the continuous generation of stylized images by hijacking the initial loader function to preprocess and manage multiple images in sequence.
The heart of this upgrade lies in the ability to loop through an entire folder of images (sample_images), applying a diverse set of styles and parameters to each image. With this ability, users can maximize the utility of InstantID by processing large datasets without manual intervention.
Users can define and experiment with ranges of values for various parameters to discover the optimal settings:
This structured variety helps find the sweet spot for each image, allowing for you to find the right customization:
IDENTITYNET_STRENGTH_RATIO_RANGE = (1.0, 1.5)
ADAPTER_STRENGTH_RATIO_RANGE = (0.7, 1.0)
NUM_INFERENCE_STEPS_RANGE = (40, 60)
GUIDANCE_SCALE_RANGE = (7.0, 12.0)
...
Additionally, the script can loop through predefined or random styles, applying each to the set of images to generate a rich array of results.
Efficient image preparation is vital for achieving consistent results. The preprocess.py module employs resize_and_pad_image to standardize all images to the same dimensions, ensuring uniformity across the batch, ready for further processing by InstantID.
The module randomly selects images from the sample_images directory, ensuring an unbiased and varied selection for processing. This feature is particularly useful when dealing with large collections of images.
Each processed image's configuration and outcomes are meticulously logged in a CSV file (default generation_log.csv). This log includes key details like identity and adapter strength ratios, the number of inference steps, guidance scale, and any error messages.
As the batch processing unfolds, preprocess.py provides real-time feedback in the console, displaying time remaining, progress of values, and overall statistics. This immediate insight into the batch progress is crucial for efficient workflow management.
After batch processing, users can opt to open up Gradio for fine-tuned, one-off image processing. This flexibility marries the robustness of batch processing with the refinement of individual image customization.
from preprocess import initial_image, generate_image
initial_image(generate_image)
preprocess.py transforms the InstantID tool into a powerhouse of batch image processing. By extending the original script to handle multiple images, providing detailed logs, and integrating with Gradio for one-off customizations, this module unlocks the full potential of the InstantID pipeline for users and researchers alike.
For more details on InstantID, refer to the official project page and associated research paper:
1 commits
Python
99.3%