bewizz commited on
Commit
be8fefe
·
verified ·
1 Parent(s): 91bef31

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +5 -62
app.py CHANGED
@@ -13,8 +13,12 @@ from typing import List
13
  WORKFLOW_FILENAME = 'sd3.json'
14
  ROOT_DIR = os.getcwd() # Root directory of the project
15
  OUTPUT_DIR = os.path.join(ROOT_DIR, 'output')
 
16
  URL = "https://3653-47-216-153-41.ngrok-free.app/prompt" # Replace with your ngrok URL
17
 
 
 
 
18
  # Configure logging
19
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
20
 
@@ -247,65 +251,4 @@ def main():
247
  with gr.Accordion("Instructions", open=True):
248
  gr.Markdown("""
249
  **SD3 Batch Imagine Instructions**
250
- - Enter your prompts below, one per empty line.
251
- - Enter your negative prompts below, one per line. (Optional)
252
- - Set the zip interval to determine how many images will be included in each zip file.
253
- - Click "Process Prompts" to start generating images.
254
- - Click "Cancel Processing" to stop the current batch run.
255
- - Watch the progress as images are generated in real-time.
256
- - At the end of the process, zip files containing your images will be available for download.
257
- """)
258
-
259
- with gr.Column(scale=2):
260
- gr.Markdown("### Enter Prompts")
261
- prompts_text = gr.Textbox(lines=20, placeholder="Enter your prompts here, one per empty line.", label="Prompts")
262
- negative_prompts_text = gr.Textbox(lines=5, placeholder="Enter your negative prompts here, one per line.", label="Negative Prompts")
263
- zip_interval = gr.Number(value=10, label="Zip Interval", precision=0)
264
- process_btn = gr.Button("Process Prompts")
265
- cancel_btn = gr.Button("Cancel Processing")
266
- progress_text = gr.Markdown("Progress")
267
- gallery_output = gr.Gallery(label="Generated Images")
268
- zip_files_output = gr.Files(label="Zip Files")
269
-
270
- with gr.Column(scale=1):
271
- gr.Markdown("### Detailed Logs")
272
- logs_output = gr.Textbox(lines=10, interactive=False, label="Logs")
273
-
274
- def generate_user_folder():
275
- user_folder = os.path.normpath(os.path.join(OUTPUT_DIR, f'SD3{random.randint(1000, 9999)}'))
276
- os.makedirs(user_folder, exist_ok=True)
277
- log_message(f"Generated user folder: {user_folder}")
278
- return user_folder
279
-
280
- def on_click(prompts_text, negative_prompts_text, zip_interval):
281
- reset_cancel_processing_fn()
282
- user_folder = generate_user_folder()
283
- output_images, zip_files_list = [], []
284
- logs = ""
285
- try:
286
- for images, zip_files, log_msg in process_prompts(prompts_text, negative_prompts_text, user_folder, zip_interval):
287
- output_images = images
288
- zip_files_list = zip_files
289
- logs = log_msg
290
- yield images, zip_files_list, logs + log_messages
291
- except Exception as e:
292
- log_message(f"Error during prompt processing: {e}")
293
- logs += f"Error: {e}\n"
294
- yield output_images, zip_files_list, logs + log_messages
295
-
296
- process_btn.click(
297
- fn=on_click,
298
- inputs=[prompts_text, negative_prompts_text, zip_interval],
299
- outputs=[gallery_output, zip_files_output, logs_output]
300
- )
301
-
302
- cancel_btn.click(
303
- fn=cancel_processing_fn,
304
- inputs=[],
305
- outputs=[]
306
- )
307
-
308
- demo.launch()
309
-
310
- if __name__ == "__main__":
311
- main()
 
13
  WORKFLOW_FILENAME = 'sd3.json'
14
  ROOT_DIR = os.getcwd() # Root directory of the project
15
  OUTPUT_DIR = os.path.join(ROOT_DIR, 'output')
16
+ USER_OUTPUTS_DIR = os.path.join(OUTPUT_DIR, 'user_outputs')
17
  URL = "https://3653-47-216-153-41.ngrok-free.app/prompt" # Replace with your ngrok URL
18
 
19
+ # Create output directories if they don't exist
20
+ os.makedirs(USER_OUTPUTS_DIR, exist_ok=True)
21
+
22
  # Configure logging
23
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
24
 
 
251
  with gr.Accordion("Instructions", open=True):
252
  gr.Markdown("""
253
  **SD3 Batch Imagine Instructions**
254
+ -