Spaces:
ginigen
/
Running on Zero

aiqcamp commited on
Commit
87d3ec0
Β·
verified Β·
1 Parent(s): a473659

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -25
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(type="filepath", label="Generated Diagram"),
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
- try:
290
- demo.queue(max_size=10)
291
- demo.launch(
292
- server_name="0.0.0.0",
293
- server_port=7860,
294
- share=False,
295
- show_error=True,
296
- debug=True
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
+ )