Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -336,15 +336,14 @@ def generate_images_with_progress(prompt, negative_prompt, batch_count, use_cont
|
|
336 |
preprocessed_images.append(img)
|
337 |
|
338 |
images = []
|
339 |
-
for
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
clear_memory()
|
348 |
|
349 |
else:
|
350 |
if 'controlnet_pipe' in globals() and controlnet_pipe is not None:
|
@@ -493,18 +492,18 @@ with gr.Blocks() as demo:
|
|
493 |
clear_selection_button.click(fn=clear_selected_folder_images, inputs=[], outputs=selected_folder_images)
|
494 |
|
495 |
def generate_images_with_folder_images(prompt, negative_prompt, batch_count, use_controlnet, controlnet_type, mode, use_control_folder, selected_folder_images, batch_images_input, num_inference_steps, control_image, progress=gr.Progress(track_tqdm=True)):
|
496 |
-
if mode == "
|
497 |
-
selected_images = [control_image]
|
498 |
-
elif mode == "Multiselect":
|
499 |
-
selected_images = [img[1] for img in selected_folder_images]
|
500 |
-
elif mode == "Batch" and use_control_folder:
|
501 |
selected_images = [img[1] for img in loaded_images]
|
502 |
elif mode == "Batch":
|
503 |
if not batch_images_input:
|
504 |
raise ValueError("No images uploaded for batch processing.")
|
505 |
selected_images = [resize_image(Image.open(img).convert("RGB")) for img in batch_images_input]
|
|
|
|
|
506 |
else:
|
507 |
-
|
|
|
|
|
508 |
return generate_images_with_progress(prompt, negative_prompt, batch_count, use_controlnet, controlnet_type, mode, selected_images, num_inference_steps, progress)
|
509 |
|
510 |
generate_button = gr.Button("Generate Images")
|
@@ -550,3 +549,4 @@ if __name__ == "__main__":
|
|
550 |
# Your Gradio interface setup here
|
551 |
demo.launch(auth=("roland", "roland"), debug=True)
|
552 |
clear_memory()
|
|
|
|
336 |
preprocessed_images.append(img)
|
337 |
|
338 |
images = []
|
339 |
+
for i in range(0, len(preprocessed_images), chunk_size):
|
340 |
+
chunk = preprocessed_images[i:i+chunk_size]
|
341 |
+
if controlnet_type == "Reference":
|
342 |
+
images_chunk = process_image_batch(chunk, reference_pipe, prompt, negative_prompt, num_inference_steps, progress)
|
343 |
+
else:
|
344 |
+
images_chunk = process_image_batch(chunk, controlnet_pipe, prompt, negative_prompt, num_inference_steps, progress)
|
345 |
+
images.extend(images_chunk)
|
346 |
+
clear_memory()
|
|
|
347 |
|
348 |
else:
|
349 |
if 'controlnet_pipe' in globals() and controlnet_pipe is not None:
|
|
|
492 |
clear_selection_button.click(fn=clear_selected_folder_images, inputs=[], outputs=selected_folder_images)
|
493 |
|
494 |
def generate_images_with_folder_images(prompt, negative_prompt, batch_count, use_controlnet, controlnet_type, mode, use_control_folder, selected_folder_images, batch_images_input, num_inference_steps, control_image, progress=gr.Progress(track_tqdm=True)):
|
495 |
+
if mode == "Batch" and use_control_folder:
|
|
|
|
|
|
|
|
|
496 |
selected_images = [img[1] for img in loaded_images]
|
497 |
elif mode == "Batch":
|
498 |
if not batch_images_input:
|
499 |
raise ValueError("No images uploaded for batch processing.")
|
500 |
selected_images = [resize_image(Image.open(img).convert("RGB")) for img in batch_images_input]
|
501 |
+
elif mode == "Single Image" and control_image is not None:
|
502 |
+
selected_images = [control_image]
|
503 |
else:
|
504 |
+
selected_images = [img[1] for img in selected_folder_images]
|
505 |
+
# Adjust the batch_count here to generate the desired number of images
|
506 |
+
selected_images = selected_images * batch_count
|
507 |
return generate_images_with_progress(prompt, negative_prompt, batch_count, use_controlnet, controlnet_type, mode, selected_images, num_inference_steps, progress)
|
508 |
|
509 |
generate_button = gr.Button("Generate Images")
|
|
|
549 |
# Your Gradio interface setup here
|
550 |
demo.launch(auth=("roland", "roland"), debug=True)
|
551 |
clear_memory()
|
552 |
+
|