File size: 4,965 Bytes
21146b3
1dacff1
21146b3
1dacff1
 
21146b3
 
1dacff1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
---
title: SD3_Batch_Imagine
app_file: app.py
sdk: gradio
sdk_version: 4.31.5
---


Sure, here is a detailed README for your script:

GroOvy SD3 Batch Imagine
Overview
The GroOvy SD3 Batch Imagine tool is designed for batch image generation using the SD3 Medium model. This tool allows users to input multiple prompts and generate images in batches, with options for negative prompts, and automated zipping of generated images for easy download. The integration with ComfyUI ensures a seamless workflow for AI-powered image generation.

Features
Batch Image Generation: Enter multiple prompts and generate images in bulk.
Negative Prompts: Specify negative prompts to refine image outputs.
Zip Interval: Set the interval at which images are zipped.
Real-time Progress Monitoring: Watch the progress of image generation in real-time.
Automated File Management: Generated images are automatically copied to user-specific folders and zipped at specified intervals.
Detailed Logging: Monitor detailed logs of the image generation process.
Prerequisites
Python 3.7 or higher
Required Python packages: requests, gradio, logging, shutil, zipfile, os, json, random, time
Installation
Clone the repository:
bash
Copy code
git clone https://github.com/your-repo/groovy-sd3-batch-imagine.git
Navigate to the project directory:
bash
Copy code
cd groovy-sd3-batch-imagine
Install the required packages:
bash
Copy code
pip install -r requirements.txt
Usage
Running the Application
To run the application, execute the following command in your terminal:

bash
Copy code
python app.py
Accessing the Interface
Once the application is running, you can access the Gradio interface via the provided local URL (http://127.0.0.1:7860) or a public URL if you choose to share it.

Interface Overview
Developer Information
This section provides information about the developer, BeWiZ, including contact details and social media links.

About SD3 Batch Imagine
Learn about the purpose and features of the GroOvy SD3 Batch Imagine tool.

Instructions
Follow these instructions to use the tool effectively:

Enter your prompts, one per empty line.
Enter your negative prompts, one per line (optional).
Set the zip interval to determine how many images will be included in each zip file.
Click "Process Prompts" to start generating images.
Click "Cancel Processing" to stop the current batch run.
Monitor the progress in real-time.
Download the generated zip files at the end of the process.
Components
Enter Prompts
Prompts: Input your image generation prompts here, one per empty line.
Negative Prompts: Input negative prompts here, one per line (optional).
Zip Interval: Specify the number of images per zip file.
Process Prompts Button: Start the batch image generation process.
Cancel Processing Button: Cancel the current batch run.
Progress: Displays real-time progress of image generation.
Generated Images
Gallery: Displays the generated images.
Zip Files
Zip Files: Displays the generated zip files for download.
Detailed Logs
Logs: Displays detailed logs of the image generation process.
Script Details
Constants
COMFYUI_DIR: Directory path for ComfyUI.
WORKFLOW_PATH: Path to the workflow JSON file.
OUTPUT_DIR: Directory path for output images.
URL: URL for sending the workflow to ComfyUI.
Functions
read_workflow(file_path)
Reads and returns the workflow JSON from the specified file path.

update_workflow(workflow, prompt, negative_prompt)
Updates the workflow with new prompts and negative prompts.

write_workflow(workflow, file_path)
Writes the updated workflow back to the specified file path.

send_workflow_to_comfyui(workflow, url)
Sends the updated workflow to ComfyUI and logs the response.

monitor_output_images(output_dir, previous_images, timeout=60)
Monitors the output directory for new images, returning the latest image found within the timeout period.

copy_file_with_retry(src, dst_dir, file_index, retries=5, delay=1)
Copies a file from the source to the destination directory, with retries in case of permission errors.

zip_files(output_images: List[str], zip_interval: int, zip_folder: str)
Creates zip files from the list of output images at specified intervals and saves them to the zip folder.

process_prompts(prompts_text, negative_prompt_text, user_folder, zip_interval)
Processes the prompts, generates images, copies them to the user folder, and zips them at specified intervals.

cancel_processing_fn()
Sets the cancel processing flag to True to stop the current batch run.

reset_cancel_processing_fn()
Resets the cancel processing flag to False.

Main Function
The main() function initializes the Gradio interface and sets up the UI components for entering prompts, monitoring progress, displaying generated images, zip files, and logs.

License
This project is licensed under the MIT License. See the LICENSE file for more details.

Contact
For any queries or support, please contact [email protected] or reach out on Twitter @AiAnarchist.