ZahirJS commited on
Commit
b9ff5dc
·
verified ·
1 Parent(s): 4229fc7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -248
app.py CHANGED
@@ -1,245 +1,3 @@
1
- # import gradio as gr
2
-
3
- # from concept_map_generator import generate_concept_map
4
- # from synoptic_chart_generator import generate_synoptic_chart
5
- # from radial_diagram_generator import generate_radial_diagram
6
- # from process_flow_generator import generate_process_flow_diagram
7
- # from wbs_diagram_generator import generate_wbs_diagram
8
-
9
- # from sample_data import CONCEPT_MAP_JSON, SYNOPTIC_CHART_JSON, RADIAL_DIAGRAM_JSON, PROCESS_FLOW_JSON, WBS_DIAGRAM_JSON
10
-
11
- # if __name__ == "__main__":
12
- # DEFAULT_BASE_COLOR = '#19191a'
13
-
14
- # with gr.Blocks(
15
- # title="Advanced Graph Generator",
16
- # css="""
17
- # .gradio-container {
18
- # font-family: 'Inter', sans-serif !important;
19
- # }
20
- # .gr-tab-item {
21
- # padding: 10px 20px;
22
- # font-size: 1.1em;
23
- # font-weight: bold;
24
- # }
25
- # .gr-button {
26
- # border-radius: 8px;
27
- # box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
28
- # background-color: #FFA500;
29
- # color: white;
30
- # padding: 10px 20px;
31
- # font-size: 1.1em;
32
- # }
33
- # .gr-button:hover {
34
- # background-color: #FF8C00;
35
- # }
36
- # .gr-textbox {
37
- # border-radius: 8px;
38
- # padding: 10px;
39
- # }
40
- # .example-images img {
41
- # max-width: 100%;
42
- # height: auto;
43
- # min-height: 400px;
44
- # object-fit: contain;
45
- # }
46
- # /* Dark mode styles */
47
- # .gradio-container.dark {
48
- # --tw-bg-opacity: 1;
49
- # background-color: rgb(24 24 27 / var(--tw-bg-opacity));
50
- # color: #d4d4d8;
51
- # }
52
- # .gradio-container.dark .gr-textbox {
53
- # background-color: rgb(39 39 42 / var(--tw-bg-opacity));
54
- # color: #d4d4d8;
55
- # border-color: #52525b;
56
- # }
57
- # .gradio-container.dark .gr-tab-item {
58
- # color: #d4d4d8;
59
- # }
60
- # .gradio-container.dark .gr-tab-item.selected {
61
- # background-color: rgb(39 39 42 / var(--tw-bg-opacity));
62
- # color: #fff;
63
- # }
64
- # """
65
- # ) as demo:
66
- # gr.Markdown(
67
- # """
68
- # # Graphify: generate diagrams from JSON super fast and easy ⚡!
69
- # Choose a graph type and provide your JSON data to generate a visual representation.
70
- # All graphs maintain a consistent, elegant style with rounded boxes,
71
- # a dark-to-light color gradient, and a clean white background.
72
- # """
73
- # )
74
-
75
- # with gr.Row(variant="panel"):
76
- # output_format_radio = gr.Radio(
77
- # choices=["png", "svg"],
78
- # value="png",
79
- # label="Output Format",
80
- # interactive=True
81
- # )
82
-
83
- # with gr.Tabs():
84
- # with gr.TabItem("Concept Map"):
85
- # with gr.Row():
86
- # with gr.Column(scale=1):
87
- # json_input_cm = gr.Textbox(
88
- # value=CONCEPT_MAP_JSON,
89
- # placeholder="Paste JSON following the documented format",
90
- # label="JSON Input",
91
- # lines=20
92
- # )
93
- # submit_btn_cm = gr.Button("Generate Concept Map", variant="primary")
94
-
95
- # with gr.Column(scale=2):
96
- # output_cm = gr.Image(
97
- # label="Generated Diagram",
98
- # type="filepath",
99
- # show_download_button=True,
100
- # height=500
101
- # )
102
-
103
- # submit_btn_cm.click(
104
- # fn=generate_concept_map,
105
- # inputs=[json_input_cm, output_format_radio],
106
- # outputs=output_cm
107
- # )
108
-
109
- # gr.Markdown("## Examples")
110
- # with gr.Row(elem_classes=["example-images"]):
111
- # gr.Image(value="./images/cm1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
112
- # gr.Image(value="./images/cm2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
113
-
114
- # with gr.TabItem("Synoptic Chart"):
115
- # with gr.Row():
116
- # with gr.Column(scale=1):
117
- # json_input_sc = gr.Textbox(
118
- # value=SYNOPTIC_CHART_JSON,
119
- # placeholder="Paste JSON following the documented format",
120
- # label="JSON Input",
121
- # lines=20
122
- # )
123
- # submit_btn_sc = gr.Button("Generate Synoptic Chart", variant="primary")
124
-
125
- # with gr.Column(scale=2):
126
- # output_sc = gr.Image(
127
- # label="Generated Diagram",
128
- # type="filepath",
129
- # show_download_button=True,
130
- # height=500
131
- # )
132
-
133
- # submit_btn_sc.click(
134
- # fn=generate_synoptic_chart,
135
- # inputs=[json_input_sc, output_format_radio],
136
- # outputs=output_sc
137
- # )
138
-
139
- # gr.Markdown("## Examples")
140
- # with gr.Row(elem_classes=["example-images"]):
141
- # gr.Image(value="./images/sc1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
142
- # gr.Image(value="./images/sc2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
143
-
144
- # with gr.TabItem("Radial Diagram"):
145
- # with gr.Row():
146
- # with gr.Column(scale=1):
147
- # json_input_rd = gr.Textbox(
148
- # value=RADIAL_DIAGRAM_JSON,
149
- # placeholder="Paste JSON following the documented format",
150
- # label="JSON Input",
151
- # lines=20
152
- # )
153
- # submit_btn_rd = gr.Button("Generate Radial Diagram", variant="primary")
154
-
155
- # with gr.Column(scale=2):
156
- # output_rd = gr.Image(
157
- # label="Generated Diagram",
158
- # type="filepath",
159
- # show_download_button=True,
160
- # height=500
161
- # )
162
-
163
- # submit_btn_rd.click(
164
- # fn=generate_radial_diagram,
165
- # inputs=[json_input_rd, output_format_radio],
166
- # outputs=output_rd
167
- # )
168
-
169
- # gr.Markdown("## Examples")
170
- # with gr.Row(elem_classes=["example-images"]):
171
- # gr.Image(value="./images/rd1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
172
- # gr.Image(value="./images/rd2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
173
- # gr.Image(value="./images/rd3.svg", label="Sample 3", show_label=True, interactive=False, height="auto", width="100%")
174
- # gr.Image(value="./images/rd4.svg", label="Sample 4", show_label=True, interactive=False, height="auto", width="100%")
175
-
176
- # with gr.TabItem("Process Flow"):
177
- # with gr.Row():
178
- # with gr.Column(scale=1):
179
- # json_input_pf = gr.Textbox(
180
- # value=PROCESS_FLOW_JSON,
181
- # placeholder="Paste JSON following the documented format",
182
- # label="JSON Input",
183
- # lines=20
184
- # )
185
- # submit_btn_pf = gr.Button("Generate Process Flow", variant="primary")
186
-
187
- # with gr.Column(scale=2):
188
- # output_pf = gr.Image(
189
- # label="Generated Diagram",
190
- # type="filepath",
191
- # show_download_button=True,
192
- # height=500
193
- # )
194
-
195
- # submit_btn_pf.click(
196
- # fn=generate_process_flow_diagram,
197
- # inputs=[json_input_pf, output_format_radio],
198
- # outputs=output_pf
199
- # )
200
-
201
- # gr.Markdown("## Examples")
202
- # with gr.Row(elem_classes=["example-images"]):
203
- # gr.Image(value="./images/pf1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
204
- # gr.Image(value="./images/pf2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
205
-
206
- # with gr.TabItem("WBS Diagram"):
207
- # with gr.Row():
208
- # with gr.Column(scale=1):
209
- # json_input_wbs = gr.Textbox(
210
- # value=WBS_DIAGRAM_JSON,
211
- # placeholder="Paste JSON following the documented format",
212
- # label="JSON Input",
213
- # lines=20
214
- # )
215
- # submit_btn_wbs = gr.Button("Generate WBS Diagram", variant="primary")
216
-
217
- # with gr.Column(scale=2):
218
- # output_wbs = gr.Image(
219
- # label="Generated Diagram",
220
- # type="filepath",
221
- # show_download_button=True,
222
- # height=500
223
- # )
224
-
225
- # submit_btn_wbs.click(
226
- # fn=generate_wbs_diagram,
227
- # inputs=[json_input_wbs, output_format_radio],
228
- # outputs=output_wbs
229
- # )
230
-
231
- # gr.Markdown("## Examples")
232
- # with gr.Row(elem_classes=["example-images"]):
233
- # gr.Image(value="./images/wd1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
234
- # gr.Image(value="./images/wd2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
235
-
236
- # demo.launch(
237
- # mcp_server=True,
238
- # share=False,
239
- # server_port=7860,
240
- # server_name="0.0.0.0"
241
- # )
242
-
243
  import gradio as gr
244
 
245
  from concept_map_generator import generate_concept_map
@@ -503,9 +261,9 @@ if __name__ == "__main__":
503
  )
504
 
505
  gr.Markdown("## Examples")
506
- #with gr.Row(elem_classes=["example-images"]):
507
- #gr.Image(value="./images/tl1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
508
- #gr.Image(value="./images/tl2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
509
 
510
  with gr.TabItem("Binary Tree"):
511
  with gr.Row():
@@ -533,9 +291,9 @@ if __name__ == "__main__":
533
  )
534
 
535
  gr.Markdown("## Examples")
536
- #with gr.Row(elem_classes=["example-images"]):
537
- #gr.Image(value="./images/bt1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
538
- #gr.Image(value="./images/bt2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
539
 
540
  demo.launch(
541
  mcp_server=True,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
  from concept_map_generator import generate_concept_map
 
261
  )
262
 
263
  gr.Markdown("## Examples")
264
+ with gr.Row(elem_classes=["example-images"]):
265
+ gr.Image(value="./images/tl1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
266
+ gr.Image(value="./images/tl2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
267
 
268
  with gr.TabItem("Binary Tree"):
269
  with gr.Row():
 
291
  )
292
 
293
  gr.Markdown("## Examples")
294
+ with gr.Row(elem_classes=["example-images"]):
295
+ gr.Image(value="./images/bt1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
296
+ gr.Image(value="./images/bt2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
297
 
298
  demo.launch(
299
  mcp_server=True,