Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,16 +5,156 @@ import torch
|
|
| 5 |
from diffusers import DiffusionPipeline
|
| 6 |
import spaces
|
| 7 |
|
| 8 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
dtype = torch.bfloat16
|
| 10 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 11 |
-
|
| 12 |
-
# Load model (FLUX.1-schnell)
|
| 13 |
pipe = DiffusionPipeline.from_pretrained(
|
| 14 |
"black-forest-labs/FLUX.1-schnell",
|
| 15 |
torch_dtype=dtype
|
| 16 |
).to(device)
|
| 17 |
-
|
| 18 |
MAX_SEED = np.iinfo(np.int32).max
|
| 19 |
MAX_IMAGE_SIZE = 2048
|
| 20 |
|
|
@@ -36,7 +176,6 @@ def generate_image(prompt, seed, randomize_seed, width, height, steps, guidance_
|
|
| 36 |
def set_prompt(example_text):
|
| 37 |
return example_text
|
| 38 |
|
| 39 |
-
# Updated example prompts per tab with richer details:
|
| 40 |
example_prompts = {
|
| 41 |
"Product Design": [
|
| 42 |
"""A sleek industrial design concept for a coffee machine:
|
|
@@ -111,64 +250,13 @@ BUSINESS WORKFLOW
|
|
| 111 |
]
|
| 112 |
}
|
| 113 |
|
| 114 |
-
|
| 115 |
-
css = """
|
| 116 |
-
* {
|
| 117 |
-
box-sizing: border-box;
|
| 118 |
-
}
|
| 119 |
-
body {
|
| 120 |
-
background: linear-gradient(135deg, #667eea, #764ba2);
|
| 121 |
-
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
| 122 |
-
color: #333;
|
| 123 |
-
margin: 0;
|
| 124 |
-
padding: 0;
|
| 125 |
-
}
|
| 126 |
-
.gradio-container {
|
| 127 |
-
background: rgba(255, 255, 255, 0.95);
|
| 128 |
-
border-radius: 15px;
|
| 129 |
-
padding: 30px 40px;
|
| 130 |
-
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
|
| 131 |
-
margin: 40px auto;
|
| 132 |
-
width: 1200px;
|
| 133 |
-
}
|
| 134 |
-
.sidebar {
|
| 135 |
-
background: rgba(255, 255, 255, 0.98);
|
| 136 |
-
border-radius: 10px;
|
| 137 |
-
padding: 20px;
|
| 138 |
-
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
|
| 139 |
-
}
|
| 140 |
-
button, .btn {
|
| 141 |
-
background: linear-gradient(90deg, #ff8a00, #e52e71);
|
| 142 |
-
border: none;
|
| 143 |
-
color: #fff;
|
| 144 |
-
padding: 12px 24px;
|
| 145 |
-
text-transform: uppercase;
|
| 146 |
-
font-weight: bold;
|
| 147 |
-
letter-spacing: 1px;
|
| 148 |
-
border-radius: 5px;
|
| 149 |
-
cursor: pointer;
|
| 150 |
-
transition: transform 0.2s ease-in-out;
|
| 151 |
-
}
|
| 152 |
-
button:hover, .btn:hover {
|
| 153 |
-
transform: scale(1.05);
|
| 154 |
-
}
|
| 155 |
-
.example-accordion {
|
| 156 |
-
width: 100% !important;
|
| 157 |
-
max-width: 100% !important;
|
| 158 |
-
}
|
| 159 |
-
.example-accordion button {
|
| 160 |
-
width: auto !important;
|
| 161 |
-
white-space: normal !important;
|
| 162 |
-
}
|
| 163 |
-
"""
|
| 164 |
-
|
| 165 |
-
with gr.Blocks(css=css, title="Workflow Canvas") as demo:
|
| 166 |
gr.Markdown(
|
| 167 |
"""
|
| 168 |
-
<div style="text-align:center;">
|
| 169 |
-
<h1>Workflow Canvas</h1>
|
| 170 |
-
<p>Generate design concepts and workflow diagrams for your business needs using our multi-tab interface.</p>
|
| 171 |
-
<p><strong>community:</strong> <a href="https://discord.gg/openfreeai" target="_blank">https://discord.gg/openfreeai</a></p>
|
| 172 |
</div>
|
| 173 |
"""
|
| 174 |
)
|
|
@@ -177,137 +265,136 @@ with gr.Blocks(css=css, title="Workflow Canvas") as demo:
|
|
| 177 |
<img src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fginigen-Workflow-Canvas.hf.space&countColor=%23263759" alt="Visitor Badge"/>
|
| 178 |
</a>"""
|
| 179 |
)
|
| 180 |
-
|
| 181 |
with gr.Row():
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
# 1: Product Design, 2: Mindmap, 3: Mockup, 4: Infographic, 5: Diagram, 6: Flowchart
|
| 194 |
-
with gr.Column(scale=8):
|
| 195 |
with gr.Tabs():
|
| 196 |
-
#
|
| 197 |
with gr.Tab("Product Design"):
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
|
|
|
| 206 |
with gr.Accordion("Example Prompts", open=True, elem_classes="example-accordion"):
|
| 207 |
for ex in example_prompts["Product Design"]:
|
| 208 |
gr.Button(ex, variant="secondary").click(fn=lambda ex=ex: set_prompt(ex), outputs=pd_prompt)
|
| 209 |
-
|
| 210 |
-
#
|
| 211 |
with gr.Tab("Mindmap"):
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
|
|
|
| 220 |
with gr.Accordion("Example Prompts", open=True, elem_classes="example-accordion"):
|
| 221 |
for ex in example_prompts["Mindmap"]:
|
| 222 |
gr.Button(ex, variant="secondary").click(fn=lambda ex=ex: set_prompt(ex), outputs=mindmap_prompt)
|
| 223 |
-
|
| 224 |
-
#
|
| 225 |
with gr.Tab("Mockup"):
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
|
|
|
| 234 |
with gr.Accordion("Example Prompts", open=True, elem_classes="example-accordion"):
|
| 235 |
for ex in example_prompts["Mockup"]:
|
| 236 |
gr.Button(ex, variant="secondary").click(fn=lambda ex=ex: set_prompt(ex), outputs=mock_prompt)
|
| 237 |
-
|
| 238 |
-
#
|
| 239 |
with gr.Tab("Infographic"):
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
|
|
|
| 248 |
with gr.Accordion("Example Prompts", open=True, elem_classes="example-accordion"):
|
| 249 |
for ex in example_prompts["Infographic"]:
|
| 250 |
gr.Button(ex, variant="secondary").click(fn=lambda ex=ex: set_prompt(ex), outputs=info_prompt)
|
| 251 |
-
|
| 252 |
-
#
|
| 253 |
with gr.Tab("Diagram"):
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
|
|
|
| 262 |
with gr.Accordion("Example Prompts", open=True, elem_classes="example-accordion"):
|
| 263 |
for ex in example_prompts["Diagram"]:
|
| 264 |
gr.Button(ex, variant="secondary").click(fn=lambda ex=ex: set_prompt(ex), outputs=diag_prompt)
|
| 265 |
-
|
| 266 |
-
#
|
| 267 |
with gr.Tab("Flowchart"):
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
|
|
|
| 276 |
with gr.Accordion("Example Prompts", open=True, elem_classes="example-accordion"):
|
| 277 |
for ex in example_prompts["Flowchart"]:
|
| 278 |
gr.Button(ex, variant="secondary").click(fn=lambda ex=ex: set_prompt(ex), outputs=flow_prompt)
|
| 279 |
-
|
| 280 |
# Bind events for generation buttons
|
| 281 |
pd_generate.click(
|
| 282 |
fn=generate_image,
|
| 283 |
inputs=[pd_prompt, seed_slider, randomize_seed, width_slider, height_slider, steps_slider, guidance_slider],
|
| 284 |
outputs=[pd_image, seed_slider]
|
| 285 |
)
|
| 286 |
-
|
| 287 |
mindmap_generate.click(
|
| 288 |
fn=generate_image,
|
| 289 |
inputs=[mindmap_prompt, seed_slider, randomize_seed, width_slider, height_slider, steps_slider, guidance_slider],
|
| 290 |
outputs=[mindmap_image, seed_slider]
|
| 291 |
)
|
| 292 |
-
|
| 293 |
mock_generate.click(
|
| 294 |
fn=generate_image,
|
| 295 |
inputs=[mock_prompt, seed_slider, randomize_seed, width_slider, height_slider, steps_slider, guidance_slider],
|
| 296 |
outputs=[mock_image, seed_slider]
|
| 297 |
)
|
| 298 |
-
|
| 299 |
info_generate.click(
|
| 300 |
fn=generate_image,
|
| 301 |
inputs=[info_prompt, seed_slider, randomize_seed, width_slider, height_slider, steps_slider, guidance_slider],
|
| 302 |
outputs=[info_image, seed_slider]
|
| 303 |
)
|
| 304 |
-
|
| 305 |
diag_generate.click(
|
| 306 |
fn=generate_image,
|
| 307 |
inputs=[diag_prompt, seed_slider, randomize_seed, width_slider, height_slider, steps_slider, guidance_slider],
|
| 308 |
outputs=[diag_image, seed_slider]
|
| 309 |
)
|
| 310 |
-
|
| 311 |
flow_generate.click(
|
| 312 |
fn=generate_image,
|
| 313 |
inputs=[flow_prompt, seed_slider, randomize_seed, width_slider, height_slider, steps_slider, guidance_slider],
|
|
|
|
| 5 |
from diffusers import DiffusionPipeline
|
| 6 |
import spaces
|
| 7 |
|
| 8 |
+
# ---- THEME DESIGN TOKENS ----
|
| 9 |
+
SAAS_CSS = """
|
| 10 |
+
:root {
|
| 11 |
+
--color-bg: #f7f7fb;
|
| 12 |
+
--color-bg-gradient: linear-gradient(135deg, #667eea, #764ba2);
|
| 13 |
+
--color-sidebar: #23242a;
|
| 14 |
+
--color-card: #222328;
|
| 15 |
+
--color-primary-gradient: linear-gradient(90deg, #ff8a00, #e52e71, #ff6a6a);
|
| 16 |
+
--color-accent: #fd5caa;
|
| 17 |
+
--color-btn-hover: #ff8a8a;
|
| 18 |
+
--color-border: #ececec;
|
| 19 |
+
--radius-xl: 1.5rem;
|
| 20 |
+
--radius-2xl: 2.5rem;
|
| 21 |
+
--shadow-soft: 0 6px 24px rgba(80,90,150,0.12);
|
| 22 |
+
--font-main: 'IBM Plex Sans', 'Inter', Arial, sans-serif;
|
| 23 |
+
--font-mono: 'Roboto Mono', monospace;
|
| 24 |
+
}
|
| 25 |
+
body {
|
| 26 |
+
background: var(--color-bg-gradient);
|
| 27 |
+
font-family: var(--font-main);
|
| 28 |
+
color: #222;
|
| 29 |
+
}
|
| 30 |
+
.gradio-container {
|
| 31 |
+
background: rgba(255,255,255,0.97);
|
| 32 |
+
border-radius: var(--radius-xl);
|
| 33 |
+
padding: 32px 0 40px 0;
|
| 34 |
+
box-shadow: 0 8px 30px rgba(0,0,0,0.18);
|
| 35 |
+
margin: 40px auto;
|
| 36 |
+
max-width: 1360px;
|
| 37 |
+
}
|
| 38 |
+
.sidebar {
|
| 39 |
+
background: var(--color-sidebar);
|
| 40 |
+
color: #fff;
|
| 41 |
+
border-radius: var(--radius-xl);
|
| 42 |
+
padding: 2rem 1.5rem;
|
| 43 |
+
box-shadow: var(--shadow-soft);
|
| 44 |
+
margin: 0 24px 0 0;
|
| 45 |
+
}
|
| 46 |
+
.sidebar label, .sidebar .gr-markdown {
|
| 47 |
+
color: #fff;
|
| 48 |
+
font-size: 1.12rem;
|
| 49 |
+
font-weight: 500;
|
| 50 |
+
}
|
| 51 |
+
.sidebar .gr-slider, .sidebar .gr-checkbox {
|
| 52 |
+
margin-bottom: 1.2rem;
|
| 53 |
+
}
|
| 54 |
+
.gr-tabs {
|
| 55 |
+
padding: 0;
|
| 56 |
+
}
|
| 57 |
+
.gr-tab {
|
| 58 |
+
margin-right: 0.5rem;
|
| 59 |
+
}
|
| 60 |
+
.gr-tab .gr-button {
|
| 61 |
+
background: none;
|
| 62 |
+
border-radius: var(--radius-2xl);
|
| 63 |
+
color: var(--color-accent);
|
| 64 |
+
font-weight: 600;
|
| 65 |
+
padding: 0.8rem 2.5rem;
|
| 66 |
+
transition: background 0.15s, color 0.15s;
|
| 67 |
+
}
|
| 68 |
+
.gr-tab.gr-active .gr-button {
|
| 69 |
+
background: var(--color-primary-gradient);
|
| 70 |
+
color: #fff;
|
| 71 |
+
box-shadow: var(--shadow-soft);
|
| 72 |
+
}
|
| 73 |
+
.card {
|
| 74 |
+
background: var(--color-card);
|
| 75 |
+
border-radius: var(--radius-xl);
|
| 76 |
+
box-shadow: var(--shadow-soft);
|
| 77 |
+
padding: 1rem 1.5rem 1.5rem 1.5rem;
|
| 78 |
+
margin: 0.75rem 0 1.5rem 0;
|
| 79 |
+
}
|
| 80 |
+
.card label {
|
| 81 |
+
color: #fff !important;
|
| 82 |
+
}
|
| 83 |
+
.button-primary, button, .btn {
|
| 84 |
+
background: var(--color-primary-gradient);
|
| 85 |
+
border: none;
|
| 86 |
+
color: #fff !important;
|
| 87 |
+
padding: 1.2rem 2.8rem;
|
| 88 |
+
text-transform: uppercase;
|
| 89 |
+
font-weight: bold;
|
| 90 |
+
letter-spacing: 0.08em;
|
| 91 |
+
border-radius: var(--radius-2xl);
|
| 92 |
+
font-size: 1.08rem;
|
| 93 |
+
cursor: pointer;
|
| 94 |
+
box-shadow: var(--shadow-soft);
|
| 95 |
+
transition: transform 0.15s, box-shadow 0.15s, filter 0.13s;
|
| 96 |
+
}
|
| 97 |
+
.button-primary:hover, button:hover, .btn:hover {
|
| 98 |
+
filter: brightness(1.09);
|
| 99 |
+
transform: translateY(-2px);
|
| 100 |
+
box-shadow: 0 8px 24px rgba(255,106,106,0.13);
|
| 101 |
+
}
|
| 102 |
+
.gr-image, .image-preview {
|
| 103 |
+
border-radius: var(--radius-xl);
|
| 104 |
+
background: #fff;
|
| 105 |
+
border: 1px solid var(--color-border);
|
| 106 |
+
box-shadow: var(--shadow-soft);
|
| 107 |
+
padding: 1rem;
|
| 108 |
+
}
|
| 109 |
+
.image-toolbar {
|
| 110 |
+
display: flex;
|
| 111 |
+
gap: 0.6rem;
|
| 112 |
+
position: absolute;
|
| 113 |
+
right: 1.5rem;
|
| 114 |
+
top: 1.2rem;
|
| 115 |
+
z-index: 10;
|
| 116 |
+
}
|
| 117 |
+
.image-toolbar button {
|
| 118 |
+
background: var(--color-card);
|
| 119 |
+
border-radius: 50%;
|
| 120 |
+
padding: 0.55rem 0.7rem;
|
| 121 |
+
color: var(--color-accent);
|
| 122 |
+
border: none;
|
| 123 |
+
box-shadow: 0 1px 4px rgba(80,90,150,0.11);
|
| 124 |
+
transition: background 0.11s, color 0.11s;
|
| 125 |
+
}
|
| 126 |
+
.image-toolbar button:hover {
|
| 127 |
+
background: var(--color-primary-gradient);
|
| 128 |
+
color: #fff;
|
| 129 |
+
}
|
| 130 |
+
.example-accordion {
|
| 131 |
+
width: 100% !important;
|
| 132 |
+
max-width: 100% !important;
|
| 133 |
+
background: #27293a !important;
|
| 134 |
+
color: #fff !important;
|
| 135 |
+
border-radius: 1.1rem;
|
| 136 |
+
box-shadow: var(--shadow-soft);
|
| 137 |
+
padding: 0.1rem 0.8rem 1rem 0.8rem;
|
| 138 |
+
}
|
| 139 |
+
.example-accordion button {
|
| 140 |
+
width: 100% !important;
|
| 141 |
+
white-space: normal !important;
|
| 142 |
+
background: #2d2e3e;
|
| 143 |
+
border: none;
|
| 144 |
+
color: #fd5caa;
|
| 145 |
+
font-size: 1.01rem;
|
| 146 |
+
border-radius: 0.75rem;
|
| 147 |
+
margin: 0.25rem 0;
|
| 148 |
+
}
|
| 149 |
+
"""
|
| 150 |
+
|
| 151 |
+
# --- MAIN APP LOGIC ---
|
| 152 |
dtype = torch.bfloat16
|
| 153 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
|
|
|
| 154 |
pipe = DiffusionPipeline.from_pretrained(
|
| 155 |
"black-forest-labs/FLUX.1-schnell",
|
| 156 |
torch_dtype=dtype
|
| 157 |
).to(device)
|
|
|
|
| 158 |
MAX_SEED = np.iinfo(np.int32).max
|
| 159 |
MAX_IMAGE_SIZE = 2048
|
| 160 |
|
|
|
|
| 176 |
def set_prompt(example_text):
|
| 177 |
return example_text
|
| 178 |
|
|
|
|
| 179 |
example_prompts = {
|
| 180 |
"Product Design": [
|
| 181 |
"""A sleek industrial design concept for a coffee machine:
|
|
|
|
| 250 |
]
|
| 251 |
}
|
| 252 |
|
| 253 |
+
with gr.Blocks(css=SAAS_CSS, title="Workflow Canvas") as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
gr.Markdown(
|
| 255 |
"""
|
| 256 |
+
<div style="text-align:center; margin-bottom: -28px;">
|
| 257 |
+
<h1 style="background: linear-gradient(90deg,#ff8a00,#e52e71,#764ba2); -webkit-background-clip: text; color:transparent; display:inline-block; font-size:2.65rem; letter-spacing:0.04em; font-weight:700; margin:0 0 10px 0;">Workflow Canvas</h1>
|
| 258 |
+
<p style="font-size:1.19rem; font-weight:400;">Generate design concepts and workflow diagrams for your business needs using our multi-tab interface.</p>
|
| 259 |
+
<p><strong>community:</strong> <a href="https://discord.gg/openfreeai" target="_blank" style="color:#e52e71">https://discord.gg/openfreeai</a></p>
|
| 260 |
</div>
|
| 261 |
"""
|
| 262 |
)
|
|
|
|
| 265 |
<img src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fginigen-Workflow-Canvas.hf.space&countColor=%23263759" alt="Visitor Badge"/>
|
| 266 |
</a>"""
|
| 267 |
)
|
| 268 |
+
|
| 269 |
with gr.Row():
|
| 270 |
+
with gr.Column(scale=2, min_width=340):
|
| 271 |
+
with gr.Group(elem_classes="sidebar"):
|
| 272 |
+
gr.Markdown("### Generation Parameters")
|
| 273 |
+
seed_slider = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=42)
|
| 274 |
+
randomize_seed = gr.Checkbox(label="Randomize Seed", value=True)
|
| 275 |
+
width_slider = gr.Slider(label="Width", minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=1024)
|
| 276 |
+
height_slider = gr.Slider(label="Height", minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=1024)
|
| 277 |
+
steps_slider = gr.Slider(label="Inference Steps", minimum=1, maximum=50, step=1, value=20)
|
| 278 |
+
guidance_slider = gr.Slider(label="Guidance Scale", minimum=0.0, maximum=15.0, step=0.5, value=7.5)
|
| 279 |
+
|
| 280 |
+
with gr.Column(scale=7):
|
|
|
|
|
|
|
| 281 |
with gr.Tabs():
|
| 282 |
+
# -- Product Design --
|
| 283 |
with gr.Tab("Product Design"):
|
| 284 |
+
with gr.Group(elem_classes="card"):
|
| 285 |
+
pd_prompt = gr.Textbox(
|
| 286 |
+
label="Product Design Prompt",
|
| 287 |
+
placeholder="Enter a product design concept...",
|
| 288 |
+
lines=5,
|
| 289 |
+
value=example_prompts["Product Design"][0]
|
| 290 |
+
)
|
| 291 |
+
pd_generate = gr.Button("Generate Product Design", elem_classes="button-primary")
|
| 292 |
+
pd_image = gr.Image(label="Generated Product Design", elem_classes="image-preview")
|
| 293 |
with gr.Accordion("Example Prompts", open=True, elem_classes="example-accordion"):
|
| 294 |
for ex in example_prompts["Product Design"]:
|
| 295 |
gr.Button(ex, variant="secondary").click(fn=lambda ex=ex: set_prompt(ex), outputs=pd_prompt)
|
| 296 |
+
|
| 297 |
+
# -- Mindmap --
|
| 298 |
with gr.Tab("Mindmap"):
|
| 299 |
+
with gr.Group(elem_classes="card"):
|
| 300 |
+
mindmap_prompt = gr.Textbox(
|
| 301 |
+
label="Mindmap Prompt",
|
| 302 |
+
placeholder="Enter a mind map description...",
|
| 303 |
+
lines=5,
|
| 304 |
+
value=example_prompts["Mindmap"][0]
|
| 305 |
+
)
|
| 306 |
+
mindmap_generate = gr.Button("Generate Mindmap", elem_classes="button-primary")
|
| 307 |
+
mindmap_image = gr.Image(label="Generated Mindmap", elem_classes="image-preview")
|
| 308 |
with gr.Accordion("Example Prompts", open=True, elem_classes="example-accordion"):
|
| 309 |
for ex in example_prompts["Mindmap"]:
|
| 310 |
gr.Button(ex, variant="secondary").click(fn=lambda ex=ex: set_prompt(ex), outputs=mindmap_prompt)
|
| 311 |
+
|
| 312 |
+
# -- Mockup --
|
| 313 |
with gr.Tab("Mockup"):
|
| 314 |
+
with gr.Group(elem_classes="card"):
|
| 315 |
+
mock_prompt = gr.Textbox(
|
| 316 |
+
label="Mockup Prompt",
|
| 317 |
+
placeholder="Enter a mockup description...",
|
| 318 |
+
lines=5,
|
| 319 |
+
value=example_prompts["Mockup"][0]
|
| 320 |
+
)
|
| 321 |
+
mock_generate = gr.Button("Generate Mockup", elem_classes="button-primary")
|
| 322 |
+
mock_image = gr.Image(label="Generated Mockup", elem_classes="image-preview")
|
| 323 |
with gr.Accordion("Example Prompts", open=True, elem_classes="example-accordion"):
|
| 324 |
for ex in example_prompts["Mockup"]:
|
| 325 |
gr.Button(ex, variant="secondary").click(fn=lambda ex=ex: set_prompt(ex), outputs=mock_prompt)
|
| 326 |
+
|
| 327 |
+
# -- Infographic --
|
| 328 |
with gr.Tab("Infographic"):
|
| 329 |
+
with gr.Group(elem_classes="card"):
|
| 330 |
+
info_prompt = gr.Textbox(
|
| 331 |
+
label="Infographic Prompt",
|
| 332 |
+
placeholder="Enter an infographic description...",
|
| 333 |
+
lines=5,
|
| 334 |
+
value=example_prompts["Infographic"][0]
|
| 335 |
+
)
|
| 336 |
+
info_generate = gr.Button("Generate Infographic", elem_classes="button-primary")
|
| 337 |
+
info_image = gr.Image(label="Generated Infographic", elem_classes="image-preview")
|
| 338 |
with gr.Accordion("Example Prompts", open=True, elem_classes="example-accordion"):
|
| 339 |
for ex in example_prompts["Infographic"]:
|
| 340 |
gr.Button(ex, variant="secondary").click(fn=lambda ex=ex: set_prompt(ex), outputs=info_prompt)
|
| 341 |
+
|
| 342 |
+
# -- Diagram --
|
| 343 |
with gr.Tab("Diagram"):
|
| 344 |
+
with gr.Group(elem_classes="card"):
|
| 345 |
+
diag_prompt = gr.Textbox(
|
| 346 |
+
label="Diagram Prompt",
|
| 347 |
+
placeholder="Enter a diagram description...",
|
| 348 |
+
lines=5,
|
| 349 |
+
value=example_prompts["Diagram"][0]
|
| 350 |
+
)
|
| 351 |
+
diag_generate = gr.Button("Generate Diagram", elem_classes="button-primary")
|
| 352 |
+
diag_image = gr.Image(label="Generated Diagram", elem_classes="image-preview")
|
| 353 |
with gr.Accordion("Example Prompts", open=True, elem_classes="example-accordion"):
|
| 354 |
for ex in example_prompts["Diagram"]:
|
| 355 |
gr.Button(ex, variant="secondary").click(fn=lambda ex=ex: set_prompt(ex), outputs=diag_prompt)
|
| 356 |
+
|
| 357 |
+
# -- Flowchart --
|
| 358 |
with gr.Tab("Flowchart"):
|
| 359 |
+
with gr.Group(elem_classes="card"):
|
| 360 |
+
flow_prompt = gr.Textbox(
|
| 361 |
+
label="Flowchart Prompt",
|
| 362 |
+
placeholder="Enter a flowchart description...",
|
| 363 |
+
lines=5,
|
| 364 |
+
value=example_prompts["Flowchart"][0]
|
| 365 |
+
)
|
| 366 |
+
flow_generate = gr.Button("Generate Flowchart", elem_classes="button-primary")
|
| 367 |
+
flow_image = gr.Image(label="Generated Flowchart", elem_classes="image-preview")
|
| 368 |
with gr.Accordion("Example Prompts", open=True, elem_classes="example-accordion"):
|
| 369 |
for ex in example_prompts["Flowchart"]:
|
| 370 |
gr.Button(ex, variant="secondary").click(fn=lambda ex=ex: set_prompt(ex), outputs=flow_prompt)
|
| 371 |
+
|
| 372 |
# Bind events for generation buttons
|
| 373 |
pd_generate.click(
|
| 374 |
fn=generate_image,
|
| 375 |
inputs=[pd_prompt, seed_slider, randomize_seed, width_slider, height_slider, steps_slider, guidance_slider],
|
| 376 |
outputs=[pd_image, seed_slider]
|
| 377 |
)
|
|
|
|
| 378 |
mindmap_generate.click(
|
| 379 |
fn=generate_image,
|
| 380 |
inputs=[mindmap_prompt, seed_slider, randomize_seed, width_slider, height_slider, steps_slider, guidance_slider],
|
| 381 |
outputs=[mindmap_image, seed_slider]
|
| 382 |
)
|
|
|
|
| 383 |
mock_generate.click(
|
| 384 |
fn=generate_image,
|
| 385 |
inputs=[mock_prompt, seed_slider, randomize_seed, width_slider, height_slider, steps_slider, guidance_slider],
|
| 386 |
outputs=[mock_image, seed_slider]
|
| 387 |
)
|
|
|
|
| 388 |
info_generate.click(
|
| 389 |
fn=generate_image,
|
| 390 |
inputs=[info_prompt, seed_slider, randomize_seed, width_slider, height_slider, steps_slider, guidance_slider],
|
| 391 |
outputs=[info_image, seed_slider]
|
| 392 |
)
|
|
|
|
| 393 |
diag_generate.click(
|
| 394 |
fn=generate_image,
|
| 395 |
inputs=[diag_prompt, seed_slider, randomize_seed, width_slider, height_slider, steps_slider, guidance_slider],
|
| 396 |
outputs=[diag_image, seed_slider]
|
| 397 |
)
|
|
|
|
| 398 |
flow_generate.click(
|
| 399 |
fn=generate_image,
|
| 400 |
inputs=[flow_prompt, seed_slider, randomize_seed, width_slider, height_slider, steps_slider, guidance_slider],
|