Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -18,7 +18,10 @@ def generate_comic(prompt):
|
|
18 |
return f"Error: {response.status_code}, {response.text}"
|
19 |
|
20 |
# Extracting generated images
|
21 |
-
images = response.json()
|
|
|
|
|
|
|
22 |
|
23 |
# Convert image bytes into PIL Image format
|
24 |
pil_images = [Image.open(io.BytesIO(img)) for img in images]
|
@@ -33,15 +36,15 @@ def gradio_interface():
|
|
33 |
|
34 |
with gr.Row():
|
35 |
prompt = gr.Textbox(label="Enter your short story description", placeholder="Once upon a time...")
|
36 |
-
|
37 |
-
# Directly
|
38 |
-
output_gallery = gr.Gallery(label="Generated Comic Panels",
|
39 |
-
|
40 |
submit_button = gr.Button("Generate Comic")
|
41 |
-
|
42 |
# Set up button functionality
|
43 |
submit_button.click(fn=generate_comic, inputs=prompt, outputs=output_gallery)
|
44 |
-
|
45 |
return demo
|
46 |
|
47 |
# Run the Gradio app
|
|
|
18 |
return f"Error: {response.status_code}, {response.text}"
|
19 |
|
20 |
# Extracting generated images
|
21 |
+
images = response.json().get("generated_images", [])
|
22 |
+
|
23 |
+
if not images:
|
24 |
+
return "No images were generated, please try again with a different prompt."
|
25 |
|
26 |
# Convert image bytes into PIL Image format
|
27 |
pil_images = [Image.open(io.BytesIO(img)) for img in images]
|
|
|
36 |
|
37 |
with gr.Row():
|
38 |
prompt = gr.Textbox(label="Enter your short story description", placeholder="Once upon a time...")
|
39 |
+
|
40 |
+
# Directly specifying the number of columns without .style()
|
41 |
+
output_gallery = gr.Gallery(label="Generated Comic Panels", columns=3, height=300)
|
42 |
+
|
43 |
submit_button = gr.Button("Generate Comic")
|
44 |
+
|
45 |
# Set up button functionality
|
46 |
submit_button.click(fn=generate_comic, inputs=prompt, outputs=output_gallery)
|
47 |
+
|
48 |
return demo
|
49 |
|
50 |
# Run the Gradio app
|