Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -94,9 +94,9 @@ def generate_image(prompt, width=1024, height=1024, guidance_scale=7.5):
|
|
94 |
|
95 |
if response.headers['Content-Type'].startswith('image'):
|
96 |
img = Image.open(BytesIO(response.content))
|
97 |
-
return img
|
98 |
else:
|
99 |
-
return None
|
100 |
|
101 |
css = """
|
102 |
#mkd {
|
@@ -108,8 +108,8 @@ css = """
|
|
108 |
|
109 |
def process_request(logo_request, width, height, guidance_scale):
|
110 |
improved_prompt = generate_improved_prompt(logo_request)
|
111 |
-
image = generate_image(improved_prompt, width, height, guidance_scale)
|
112 |
-
return image
|
113 |
|
114 |
with gr.Blocks(css=css) as app:
|
115 |
with gr.Row():
|
@@ -124,12 +124,25 @@ with gr.Blocks(css=css) as app:
|
|
124 |
gr.HTML("<h1><center>Magical AI Logo Generator</h1><center>")
|
125 |
generate_button = gr.Button("Generate")
|
126 |
image_output = gr.Image(label="Generated Logo")
|
|
|
|
|
|
|
|
|
127 |
generate_button.click(
|
128 |
fn=process_request,
|
129 |
inputs=[logo_input, width, height, guidance_scale],
|
130 |
-
outputs=[image_output]
|
131 |
)
|
132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
gr.Markdown("""
|
134 |
---
|
135 |
### Meta Information
|
|
|
94 |
|
95 |
if response.headers['Content-Type'].startswith('image'):
|
96 |
img = Image.open(BytesIO(response.content))
|
97 |
+
return img, image_url
|
98 |
else:
|
99 |
+
return None, None
|
100 |
|
101 |
css = """
|
102 |
#mkd {
|
|
|
108 |
|
109 |
def process_request(logo_request, width, height, guidance_scale):
|
110 |
improved_prompt = generate_improved_prompt(logo_request)
|
111 |
+
image, image_url = generate_image(improved_prompt, width, height, guidance_scale)
|
112 |
+
return image, image_url, improved_prompt, f"{width}x{height}", guidance_scale
|
113 |
|
114 |
with gr.Blocks(css=css) as app:
|
115 |
with gr.Row():
|
|
|
124 |
gr.HTML("<h1><center>Magical AI Logo Generator</h1><center>")
|
125 |
generate_button = gr.Button("Generate")
|
126 |
image_output = gr.Image(label="Generated Logo")
|
127 |
+
url_output = gr.Textbox(label="Image URL", interactive=False, visible=False)
|
128 |
+
prompt_output = gr.Textbox(label="Generated Prompt", interactive=False, visible=False)
|
129 |
+
size_output = gr.Textbox(label="Image Size", interactive=False, visible=False)
|
130 |
+
guidance_output = gr.Textbox(label="Guidance Scale", interactive=False, visible=False)
|
131 |
generate_button.click(
|
132 |
fn=process_request,
|
133 |
inputs=[logo_input, width, height, guidance_scale],
|
134 |
+
outputs=[image_output, url_output, prompt_output, size_output, guidance_output]
|
135 |
)
|
136 |
+
with gr.Row():
|
137 |
+
with gr.Column():
|
138 |
+
gr.Markdown("""
|
139 |
+
| **Preview Image** | **Used Prompt** | **Size** | **Guidance Scale** |
|
140 |
+
|-------------------|-----------------|----------|-------------------|
|
141 |
+
""")
|
142 |
+
gr.Image(url_output)
|
143 |
+
gr.Textbox(prompt_output, interactive=False)
|
144 |
+
gr.Textbox(size_output, interactive=False)
|
145 |
+
gr.Textbox(guidance_output, interactive=False)
|
146 |
gr.Markdown("""
|
147 |
---
|
148 |
### Meta Information
|