Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,6 +31,45 @@ def generate_diagram(prompt, width=1024, height=1024):
|
|
| 31 |
except Exception as e:
|
| 32 |
raise gr.Error(f"Error generating diagram: {str(e)}")
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
|
| 36 |
# Enhanced examples with more detailed prompts and specific styling
|
|
@@ -236,6 +275,7 @@ GRADIO_EXAMPLES = [
|
|
| 236 |
for example in EXAMPLES
|
| 237 |
]
|
| 238 |
|
|
|
|
| 239 |
demo = gr.Interface(
|
| 240 |
fn=generate_diagram,
|
| 241 |
inputs=[
|
|
@@ -259,7 +299,7 @@ demo = gr.Interface(
|
|
| 259 |
value=1024
|
| 260 |
)
|
| 261 |
],
|
| 262 |
-
outputs=gr.Image(
|
| 263 |
title="π¨ FLUX Diagram Generator",
|
| 264 |
description="Generate beautiful hand-drawn style diagrams using FLUX AI",
|
| 265 |
article="""
|
|
@@ -268,33 +308,18 @@ demo = gr.Interface(
|
|
| 268 |
- Include icon descriptions in brackets
|
| 269 |
- Keep text concise and meaningful
|
| 270 |
- Use consistent formatting
|
| 271 |
-
|
| 272 |
-
### Template Structure
|
| 273 |
-
```
|
| 274 |
-
MAIN TOPIC
|
| 275 |
-
βββ SUBTOPIC 1 [Icon]
|
| 276 |
-
βββ SUBTOPIC 2 [Icon]
|
| 277 |
-
βββ SUBTOPIC 3
|
| 278 |
-
βββ DETAIL 1 [Icon]
|
| 279 |
-
βββ DETAIL 2 [Icon]
|
| 280 |
-
```
|
| 281 |
""",
|
| 282 |
examples=GRADIO_EXAMPLES,
|
| 283 |
-
cache_examples=True
|
| 284 |
-
theme=gr.themes.Soft()
|
| 285 |
)
|
| 286 |
|
| 287 |
# Launch app
|
| 288 |
if __name__ == "__main__":
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
)
|
| 298 |
-
except Exception as e:
|
| 299 |
-
print(f"Error launching app: {str(e)}")
|
| 300 |
-
raise
|
|
|
|
| 31 |
except Exception as e:
|
| 32 |
raise gr.Error(f"Error generating diagram: {str(e)}")
|
| 33 |
|
| 34 |
+
# Convert example format for Gradio
|
| 35 |
+
GRADIO_EXAMPLES = [
|
| 36 |
+
[
|
| 37 |
+
"""A handrawn colorful mind map diagram, educational style, vibrant colors, clear hierarchy.
|
| 38 |
+
KNOWLEDGE
|
| 39 |
+
βββ ACQUISITION [Brain with Lightning ~60px]
|
| 40 |
+
β βββ READING [Open Book with Glow]
|
| 41 |
+
β βββ PRACTICE [Hands-on Tools]
|
| 42 |
+
βββ APPLICATION
|
| 43 |
+
βββ CREATION [Artist Palette]
|
| 44 |
+
βββ INNOVATION [Lightbulb]""",
|
| 45 |
+
1024,
|
| 46 |
+
1024
|
| 47 |
+
],
|
| 48 |
+
[
|
| 49 |
+
"""A handrawn colorful mind map diagram, tech-focused style, neon accents.
|
| 50 |
+
DIGITAL TRANSFORM
|
| 51 |
+
βββ CLOUD [Cloud with Data ~55px]
|
| 52 |
+
β βββ STORAGE [Database]
|
| 53 |
+
β βββ COMPUTING [Server]
|
| 54 |
+
βββ SECURITY
|
| 55 |
+
βββ ENCRYPTION [Lock]
|
| 56 |
+
βββ MONITORING [Radar]""",
|
| 57 |
+
1024,
|
| 58 |
+
1024
|
| 59 |
+
],
|
| 60 |
+
[
|
| 61 |
+
"""A handrawn colorful mind map diagram, creative style, flowing design.
|
| 62 |
+
INNOVATION
|
| 63 |
+
βββ IDEATION [Lightbulb ~60px]
|
| 64 |
+
β βββ RESEARCH [Magnifier]
|
| 65 |
+
β βββ BRAINSTORM [Brain]
|
| 66 |
+
βββ EXECUTION
|
| 67 |
+
βββ PROTOTYPE [Tools]
|
| 68 |
+
βββ TEST [Checklist]""",
|
| 69 |
+
1024,
|
| 70 |
+
1024
|
| 71 |
+
]
|
| 72 |
+
]
|
| 73 |
|
| 74 |
|
| 75 |
# Enhanced examples with more detailed prompts and specific styling
|
|
|
|
| 275 |
for example in EXAMPLES
|
| 276 |
]
|
| 277 |
|
| 278 |
+
# Create Gradio interface
|
| 279 |
demo = gr.Interface(
|
| 280 |
fn=generate_diagram,
|
| 281 |
inputs=[
|
|
|
|
| 299 |
value=1024
|
| 300 |
)
|
| 301 |
],
|
| 302 |
+
outputs=gr.Image(label="Generated Diagram"),
|
| 303 |
title="π¨ FLUX Diagram Generator",
|
| 304 |
description="Generate beautiful hand-drawn style diagrams using FLUX AI",
|
| 305 |
article="""
|
|
|
|
| 308 |
- Include icon descriptions in brackets
|
| 309 |
- Keep text concise and meaningful
|
| 310 |
- Use consistent formatting
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 311 |
""",
|
| 312 |
examples=GRADIO_EXAMPLES,
|
| 313 |
+
cache_examples=True
|
|
|
|
| 314 |
)
|
| 315 |
|
| 316 |
# Launch app
|
| 317 |
if __name__ == "__main__":
|
| 318 |
+
demo.launch(
|
| 319 |
+
server_name="0.0.0.0",
|
| 320 |
+
server_port=7860,
|
| 321 |
+
share=False,
|
| 322 |
+
show_error=True,
|
| 323 |
+
debug=True,
|
| 324 |
+
ssr=False # Disable SSR
|
| 325 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|