Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,36 +36,55 @@ def generate_image(prompt, seed, randomize_seed, width, height, steps, guidance_
|
|
| 36 |
def set_prompt(example_text):
|
| 37 |
return example_text
|
| 38 |
|
| 39 |
-
# Example prompts per tab
|
| 40 |
example_prompts = {
|
| 41 |
"Product Design": [
|
| 42 |
-
"A
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
| 45 |
],
|
| 46 |
-
"
|
| 47 |
-
"A
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
| 50 |
],
|
| 51 |
"Infographic": [
|
| 52 |
-
"
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
"A mockup wireframe for a dog-shaped toy robot's app interface, highlighting playful interactions.",
|
| 59 |
-
"A mockup of a drone's control system and layout, featuring modern UX elements."
|
| 60 |
],
|
| 61 |
"Diagram": [
|
| 62 |
-
"A diagram illustrating the
|
| 63 |
-
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
]
|
| 66 |
}
|
| 67 |
|
| 68 |
-
# CSS style: fixed container width and
|
| 69 |
css = """
|
| 70 |
* {
|
| 71 |
box-sizing: border-box;
|
|
@@ -122,7 +141,7 @@ with gr.Blocks(css=css, title="Workflow Canvas") as demo:
|
|
| 122 |
<div style="text-align:center;">
|
| 123 |
<h1>Workflow Canvas</h1>
|
| 124 |
<p>Generate design concepts and workflow diagrams for your business needs using our multi-tab interface.</p>
|
| 125 |
-
<p><strong>AI Spaces:</strong> Product Design,
|
| 126 |
</div>
|
| 127 |
"""
|
| 128 |
)
|
|
@@ -138,10 +157,11 @@ with gr.Blocks(css=css, title="Workflow Canvas") as demo:
|
|
| 138 |
steps_slider = gr.Slider(label="Inference Steps", minimum=1, maximum=50, step=1, value=20)
|
| 139 |
guidance_slider = gr.Slider(label="Guidance Scale", minimum=0.0, maximum=15.0, step=0.5, value=7.5)
|
| 140 |
|
| 141 |
-
# Main area: Tabbed interface for different design types
|
|
|
|
| 142 |
with gr.Column(scale=8):
|
| 143 |
with gr.Tabs():
|
| 144 |
-
#
|
| 145 |
with gr.Tab("Product Design"):
|
| 146 |
pd_prompt = gr.Textbox(
|
| 147 |
label="Product Design Prompt",
|
|
@@ -151,25 +171,25 @@ with gr.Blocks(css=css, title="Workflow Canvas") as demo:
|
|
| 151 |
)
|
| 152 |
pd_generate = gr.Button("Generate Product Design")
|
| 153 |
pd_image = gr.Image(label="Generated Product Design")
|
| 154 |
-
with gr.Accordion("Example Prompts", open=
|
| 155 |
for ex in example_prompts["Product Design"]:
|
| 156 |
gr.Button(ex, variant="secondary").click(fn=lambda ex=ex: set_prompt(ex), outputs=pd_prompt)
|
| 157 |
|
| 158 |
-
#
|
| 159 |
-
with gr.Tab("
|
| 160 |
-
|
| 161 |
-
label="
|
| 162 |
-
placeholder="Enter a
|
| 163 |
lines=5,
|
| 164 |
-
value=example_prompts["
|
| 165 |
)
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
with gr.Accordion("Example Prompts", open=
|
| 169 |
-
for ex in example_prompts["
|
| 170 |
-
gr.Button(ex, variant="secondary").click(fn=lambda ex=ex: set_prompt(ex), outputs=
|
| 171 |
|
| 172 |
-
#
|
| 173 |
with gr.Tab("Infographic"):
|
| 174 |
info_prompt = gr.Textbox(
|
| 175 |
label="Infographic Prompt",
|
|
@@ -179,25 +199,11 @@ with gr.Blocks(css=css, title="Workflow Canvas") as demo:
|
|
| 179 |
)
|
| 180 |
info_generate = gr.Button("Generate Infographic")
|
| 181 |
info_image = gr.Image(label="Generated Infographic")
|
| 182 |
-
with gr.Accordion("Example Prompts", open=
|
| 183 |
for ex in example_prompts["Infographic"]:
|
| 184 |
gr.Button(ex, variant="secondary").click(fn=lambda ex=ex: set_prompt(ex), outputs=info_prompt)
|
| 185 |
|
| 186 |
-
#
|
| 187 |
-
with gr.Tab("Mockup"):
|
| 188 |
-
mock_prompt = gr.Textbox(
|
| 189 |
-
label="Mockup Prompt",
|
| 190 |
-
placeholder="Enter a mockup description...",
|
| 191 |
-
lines=5,
|
| 192 |
-
value=example_prompts["Mockup"][0]
|
| 193 |
-
)
|
| 194 |
-
mock_generate = gr.Button("Generate Mockup")
|
| 195 |
-
mock_image = gr.Image(label="Generated Mockup")
|
| 196 |
-
with gr.Accordion("Example Prompts", open=False, elem_classes="example-accordion"):
|
| 197 |
-
for ex in example_prompts["Mockup"]:
|
| 198 |
-
gr.Button(ex, variant="secondary").click(fn=lambda ex=ex: set_prompt(ex), outputs=mock_prompt)
|
| 199 |
-
|
| 200 |
-
# Fifth tab: Diagram
|
| 201 |
with gr.Tab("Diagram"):
|
| 202 |
diag_prompt = gr.Textbox(
|
| 203 |
label="Diagram Prompt",
|
|
@@ -207,9 +213,23 @@ with gr.Blocks(css=css, title="Workflow Canvas") as demo:
|
|
| 207 |
)
|
| 208 |
diag_generate = gr.Button("Generate Diagram")
|
| 209 |
diag_image = gr.Image(label="Generated Diagram")
|
| 210 |
-
with gr.Accordion("Example Prompts", open=
|
| 211 |
for ex in example_prompts["Diagram"]:
|
| 212 |
gr.Button(ex, variant="secondary").click(fn=lambda ex=ex: set_prompt(ex), outputs=diag_prompt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
|
| 214 |
# Bind events for generation buttons
|
| 215 |
pd_generate.click(
|
|
@@ -218,10 +238,10 @@ with gr.Blocks(css=css, title="Workflow Canvas") as demo:
|
|
| 218 |
outputs=[pd_image, seed_slider]
|
| 219 |
)
|
| 220 |
|
| 221 |
-
|
| 222 |
fn=generate_image,
|
| 223 |
-
inputs=[
|
| 224 |
-
outputs=[
|
| 225 |
)
|
| 226 |
|
| 227 |
info_generate.click(
|
|
@@ -230,17 +250,17 @@ with gr.Blocks(css=css, title="Workflow Canvas") as demo:
|
|
| 230 |
outputs=[info_image, seed_slider]
|
| 231 |
)
|
| 232 |
|
| 233 |
-
mock_generate.click(
|
| 234 |
-
fn=generate_image,
|
| 235 |
-
inputs=[mock_prompt, seed_slider, randomize_seed, width_slider, height_slider, steps_slider, guidance_slider],
|
| 236 |
-
outputs=[mock_image, seed_slider]
|
| 237 |
-
)
|
| 238 |
-
|
| 239 |
diag_generate.click(
|
| 240 |
fn=generate_image,
|
| 241 |
inputs=[diag_prompt, seed_slider, randomize_seed, width_slider, height_slider, steps_slider, guidance_slider],
|
| 242 |
outputs=[diag_image, seed_slider]
|
| 243 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 244 |
|
| 245 |
if __name__ == "__main__":
|
| 246 |
demo.queue()
|
|
|
|
| 36 |
def set_prompt(example_text):
|
| 37 |
return example_text
|
| 38 |
|
| 39 |
+
# Example prompts per tab in the specified tree/list format:
|
| 40 |
example_prompts = {
|
| 41 |
"Product Design": [
|
| 42 |
+
"""A sleek industrial design concept for a coffee machine:
|
| 43 |
+
- Curved metallic body with minimal bezel
|
| 44 |
+
- Touchscreen panel for settings
|
| 45 |
+
- Modern matte black finish
|
| 46 |
+
- Hand-drawn concept sketch style"""
|
| 47 |
],
|
| 48 |
+
"Mockup": [
|
| 49 |
+
"""A clean hand-drawn style wireframe for a mobile banking app:
|
| 50 |
+
- Title screen with logo
|
| 51 |
+
- Login screen (username, password, login button)
|
| 52 |
+
- Dashboard with 3 main sections (balance, transactions, quick actions)
|
| 53 |
+
- Bottom navigation bar (home, transfers, profile)"""
|
| 54 |
],
|
| 55 |
"Infographic": [
|
| 56 |
+
"""A modern flat-style infographic about global renewable energy usage:
|
| 57 |
+
- Title: "Global Renewable Energy Share"
|
| 58 |
+
- Bar chart showing Solar, Wind, Hydro
|
| 59 |
+
- Pie chart: 40% Solar, 35% Wind, 25% Hydro
|
| 60 |
+
- Minimalist icons: sun, wind turbine, water wave
|
| 61 |
+
- Clean layout with pastel color scheme"""
|
|
|
|
|
|
|
| 62 |
],
|
| 63 |
"Diagram": [
|
| 64 |
+
"""A colorful hand-drawn diagram illustrating the water cycle:
|
| 65 |
+
- Evaporation (arrows from ocean)
|
| 66 |
+
- Condensation (clouds forming)
|
| 67 |
+
- Precipitation (rain from clouds)
|
| 68 |
+
- Collection (rivers, lakes)
|
| 69 |
+
- Include simple icons: sun, cloud, raindrops
|
| 70 |
+
- Vibrant educational style"""
|
| 71 |
+
],
|
| 72 |
+
"Flowchart": [
|
| 73 |
+
"""A hand-drawn style flowchart, vibrant colors, minimalistic icons.
|
| 74 |
+
BUSINESS WORKFLOW
|
| 75 |
+
βββ START [Green Button ~40px]
|
| 76 |
+
β βββ COLLECT REQUIREMENTS [Folder Icon]
|
| 77 |
+
β βββ ANALYZE DATA [Chart Icon]
|
| 78 |
+
βββ IMPLEMENTATION [Coding Symbol ~50px]
|
| 79 |
+
β βββ FRONTEND [Browser Icon]
|
| 80 |
+
β βββ BACKEND [Server Icon]
|
| 81 |
+
βββ TEST & INTEGRATION [Gear Icon ~45px]
|
| 82 |
+
βββ DEPLOY
|
| 83 |
+
βββ END [Checkered Flag ~40px]"""
|
| 84 |
]
|
| 85 |
}
|
| 86 |
|
| 87 |
+
# CSS style: fixed container width and preventing examples from expanding the layout
|
| 88 |
css = """
|
| 89 |
* {
|
| 90 |
box-sizing: border-box;
|
|
|
|
| 141 |
<div style="text-align:center;">
|
| 142 |
<h1>Workflow Canvas</h1>
|
| 143 |
<p>Generate design concepts and workflow diagrams for your business needs using our multi-tab interface.</p>
|
| 144 |
+
<p><strong>AI Spaces:</strong> Product Design, Mockup, Infographic, Diagram, Flowchart</p>
|
| 145 |
</div>
|
| 146 |
"""
|
| 147 |
)
|
|
|
|
| 157 |
steps_slider = gr.Slider(label="Inference Steps", minimum=1, maximum=50, step=1, value=20)
|
| 158 |
guidance_slider = gr.Slider(label="Guidance Scale", minimum=0.0, maximum=15.0, step=0.5, value=7.5)
|
| 159 |
|
| 160 |
+
# Main area: Tabbed interface for different design types in specified order:
|
| 161 |
+
# Order: Product Design, Mockup, Infographic, Diagram, Flowchart
|
| 162 |
with gr.Column(scale=8):
|
| 163 |
with gr.Tabs():
|
| 164 |
+
# Tab 1: Product Design
|
| 165 |
with gr.Tab("Product Design"):
|
| 166 |
pd_prompt = gr.Textbox(
|
| 167 |
label="Product Design Prompt",
|
|
|
|
| 171 |
)
|
| 172 |
pd_generate = gr.Button("Generate Product Design")
|
| 173 |
pd_image = gr.Image(label="Generated Product Design")
|
| 174 |
+
with gr.Accordion("Example Prompts", open=True, elem_classes="example-accordion"):
|
| 175 |
for ex in example_prompts["Product Design"]:
|
| 176 |
gr.Button(ex, variant="secondary").click(fn=lambda ex=ex: set_prompt(ex), outputs=pd_prompt)
|
| 177 |
|
| 178 |
+
# Tab 2: Mockup
|
| 179 |
+
with gr.Tab("Mockup"):
|
| 180 |
+
mock_prompt = gr.Textbox(
|
| 181 |
+
label="Mockup Prompt",
|
| 182 |
+
placeholder="Enter a mockup description...",
|
| 183 |
lines=5,
|
| 184 |
+
value=example_prompts["Mockup"][0]
|
| 185 |
)
|
| 186 |
+
mock_generate = gr.Button("Generate Mockup")
|
| 187 |
+
mock_image = gr.Image(label="Generated Mockup")
|
| 188 |
+
with gr.Accordion("Example Prompts", open=True, elem_classes="example-accordion"):
|
| 189 |
+
for ex in example_prompts["Mockup"]:
|
| 190 |
+
gr.Button(ex, variant="secondary").click(fn=lambda ex=ex: set_prompt(ex), outputs=mock_prompt)
|
| 191 |
|
| 192 |
+
# Tab 3: Infographic
|
| 193 |
with gr.Tab("Infographic"):
|
| 194 |
info_prompt = gr.Textbox(
|
| 195 |
label="Infographic Prompt",
|
|
|
|
| 199 |
)
|
| 200 |
info_generate = gr.Button("Generate Infographic")
|
| 201 |
info_image = gr.Image(label="Generated Infographic")
|
| 202 |
+
with gr.Accordion("Example Prompts", open=True, elem_classes="example-accordion"):
|
| 203 |
for ex in example_prompts["Infographic"]:
|
| 204 |
gr.Button(ex, variant="secondary").click(fn=lambda ex=ex: set_prompt(ex), outputs=info_prompt)
|
| 205 |
|
| 206 |
+
# Tab 4: Diagram
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
with gr.Tab("Diagram"):
|
| 208 |
diag_prompt = gr.Textbox(
|
| 209 |
label="Diagram Prompt",
|
|
|
|
| 213 |
)
|
| 214 |
diag_generate = gr.Button("Generate Diagram")
|
| 215 |
diag_image = gr.Image(label="Generated Diagram")
|
| 216 |
+
with gr.Accordion("Example Prompts", open=True, elem_classes="example-accordion"):
|
| 217 |
for ex in example_prompts["Diagram"]:
|
| 218 |
gr.Button(ex, variant="secondary").click(fn=lambda ex=ex: set_prompt(ex), outputs=diag_prompt)
|
| 219 |
+
|
| 220 |
+
# Tab 5: Flowchart
|
| 221 |
+
with gr.Tab("Flowchart"):
|
| 222 |
+
flow_prompt = gr.Textbox(
|
| 223 |
+
label="Flowchart Prompt",
|
| 224 |
+
placeholder="Enter a flowchart description...",
|
| 225 |
+
lines=5,
|
| 226 |
+
value=example_prompts["Flowchart"][0]
|
| 227 |
+
)
|
| 228 |
+
flow_generate = gr.Button("Generate Flowchart")
|
| 229 |
+
flow_image = gr.Image(label="Generated Flowchart")
|
| 230 |
+
with gr.Accordion("Example Prompts", open=True, elem_classes="example-accordion"):
|
| 231 |
+
for ex in example_prompts["Flowchart"]:
|
| 232 |
+
gr.Button(ex, variant="secondary").click(fn=lambda ex=ex: set_prompt(ex), outputs=flow_prompt)
|
| 233 |
|
| 234 |
# Bind events for generation buttons
|
| 235 |
pd_generate.click(
|
|
|
|
| 238 |
outputs=[pd_image, seed_slider]
|
| 239 |
)
|
| 240 |
|
| 241 |
+
mock_generate.click(
|
| 242 |
fn=generate_image,
|
| 243 |
+
inputs=[mock_prompt, seed_slider, randomize_seed, width_slider, height_slider, steps_slider, guidance_slider],
|
| 244 |
+
outputs=[mock_image, seed_slider]
|
| 245 |
)
|
| 246 |
|
| 247 |
info_generate.click(
|
|
|
|
| 250 |
outputs=[info_image, seed_slider]
|
| 251 |
)
|
| 252 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
diag_generate.click(
|
| 254 |
fn=generate_image,
|
| 255 |
inputs=[diag_prompt, seed_slider, randomize_seed, width_slider, height_slider, steps_slider, guidance_slider],
|
| 256 |
outputs=[diag_image, seed_slider]
|
| 257 |
)
|
| 258 |
+
|
| 259 |
+
flow_generate.click(
|
| 260 |
+
fn=generate_image,
|
| 261 |
+
inputs=[flow_prompt, seed_slider, randomize_seed, width_slider, height_slider, steps_slider, guidance_slider],
|
| 262 |
+
outputs=[flow_image, seed_slider]
|
| 263 |
+
)
|
| 264 |
|
| 265 |
if __name__ == "__main__":
|
| 266 |
demo.queue()
|