Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
# Import generator functions and sample JSONs
|
| 4 |
from concept_map_generator import generate_concept_map
|
| 5 |
from synoptic_chart_generator import generate_synoptic_chart
|
| 6 |
from radial_diagram_generator import generate_radial_diagram
|
|
@@ -10,8 +9,7 @@ from wbs_diagram_generator import generate_wbs_diagram
|
|
| 10 |
from sample_data import CONCEPT_MAP_JSON, SYNOPTIC_CHART_JSON, RADIAL_DIAGRAM_JSON, PROCESS_FLOW_JSON, WBS_DIAGRAM_JSON
|
| 11 |
|
| 12 |
if __name__ == "__main__":
|
| 13 |
-
|
| 14 |
-
DEFAULT_BASE_COLOR = '#19191a' # This is now the fixed base color for all diagrams
|
| 15 |
|
| 16 |
with gr.Blocks(
|
| 17 |
title="Advanced Graph Generator",
|
|
@@ -61,16 +59,24 @@ if __name__ == "__main__":
|
|
| 61 |
) as demo:
|
| 62 |
gr.Markdown(
|
| 63 |
"""
|
| 64 |
-
# Graphify:
|
| 65 |
Choose a graph type and provide your JSON data to generate a visual representation.
|
| 66 |
All graphs maintain a consistent, elegant style with rounded boxes,
|
| 67 |
a dark-to-light color gradient, and a clean white background.
|
| 68 |
"""
|
| 69 |
)
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
with gr.Tabs():
|
| 76 |
with gr.TabItem("Concept Map"):
|
|
@@ -87,10 +93,9 @@ if __name__ == "__main__":
|
|
| 87 |
)
|
| 88 |
submit_btn_cm = gr.Button("Submit")
|
| 89 |
|
| 90 |
-
# Removed base_color from inputs, it's now hardcoded in generators
|
| 91 |
submit_btn_cm.click(
|
| 92 |
fn=generate_concept_map,
|
| 93 |
-
inputs=[json_input_cm],
|
| 94 |
outputs=output_cm
|
| 95 |
)
|
| 96 |
gr.Markdown("<br>")
|
|
@@ -113,10 +118,9 @@ if __name__ == "__main__":
|
|
| 113 |
)
|
| 114 |
submit_btn_sc = gr.Button("Submit")
|
| 115 |
|
| 116 |
-
# Removed base_color from inputs, it's now hardcoded in generators
|
| 117 |
submit_btn_sc.click(
|
| 118 |
fn=generate_synoptic_chart,
|
| 119 |
-
inputs=[json_input_sc],
|
| 120 |
outputs=output_sc
|
| 121 |
)
|
| 122 |
gr.Markdown("<br>")
|
|
@@ -139,10 +143,9 @@ if __name__ == "__main__":
|
|
| 139 |
)
|
| 140 |
submit_btn_rd = gr.Button("Submit")
|
| 141 |
|
| 142 |
-
# Removed base_color from inputs, it's now hardcoded in generators
|
| 143 |
submit_btn_rd.click(
|
| 144 |
fn=generate_radial_diagram,
|
| 145 |
-
inputs=[json_input_rd],
|
| 146 |
outputs=output_rd
|
| 147 |
)
|
| 148 |
gr.Markdown("<br>")
|
|
@@ -151,7 +154,7 @@ if __name__ == "__main__":
|
|
| 151 |
gr.Image(value="./images/rd1.png", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
| 152 |
gr.Image(value="./images/rd2.png", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
| 153 |
|
| 154 |
-
|
| 155 |
with gr.TabItem("Process Flow"):
|
| 156 |
json_input_pf = gr.Textbox(
|
| 157 |
value=PROCESS_FLOW_JSON,
|
|
@@ -166,10 +169,9 @@ if __name__ == "__main__":
|
|
| 166 |
)
|
| 167 |
submit_btn_pf = gr.Button("Submit")
|
| 168 |
|
| 169 |
-
# Removed base_color from inputs, it's now hardcoded in generators
|
| 170 |
submit_btn_pf.click(
|
| 171 |
fn=generate_process_flow_diagram,
|
| 172 |
-
inputs=[json_input_pf],
|
| 173 |
outputs=output_pf
|
| 174 |
)
|
| 175 |
gr.Markdown("<br>")
|
|
@@ -178,7 +180,6 @@ if __name__ == "__main__":
|
|
| 178 |
gr.Image(value="./images/pf1.png", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
| 179 |
gr.Image(value="./images/pf2.png", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
| 180 |
|
| 181 |
-
# New Tab for WBS Diagram
|
| 182 |
with gr.TabItem("WBS Diagram"):
|
| 183 |
json_input_wbs = gr.Textbox(
|
| 184 |
value=WBS_DIAGRAM_JSON,
|
|
@@ -193,10 +194,9 @@ if __name__ == "__main__":
|
|
| 193 |
)
|
| 194 |
submit_btn_wbs = gr.Button("Submit")
|
| 195 |
|
| 196 |
-
# Removed base_color from inputs, it's now hardcoded in generators
|
| 197 |
submit_btn_wbs.click(
|
| 198 |
fn=generate_wbs_diagram,
|
| 199 |
-
inputs=[json_input_wbs],
|
| 200 |
outputs=output_wbs
|
| 201 |
)
|
| 202 |
gr.Markdown("<br>")
|
|
|
|
| 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
|
|
|
|
| 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",
|
|
|
|
| 59 |
) as demo:
|
| 60 |
gr.Markdown(
|
| 61 |
"""
|
| 62 |
+
# Graphify: generate diagrams from JSON super fast and easy ⚡!
|
| 63 |
Choose a graph type and provide your JSON data to generate a visual representation.
|
| 64 |
All graphs maintain a consistent, elegant style with rounded boxes,
|
| 65 |
a dark-to-light color gradient, and a clean white background.
|
| 66 |
"""
|
| 67 |
)
|
| 68 |
|
| 69 |
+
with gr.Row(variant="panel"):
|
| 70 |
+
gr.Markdown("### Output Format")
|
| 71 |
+
output_format_radio = gr.Radio(
|
| 72 |
+
choices=["png", "svg"],
|
| 73 |
+
value="png",
|
| 74 |
+
label="Select Output File Format",
|
| 75 |
+
interactive=True,
|
| 76 |
+
elem_id="output-format-selector"
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
gr.Markdown("<br>")
|
| 80 |
|
| 81 |
with gr.Tabs():
|
| 82 |
with gr.TabItem("Concept Map"):
|
|
|
|
| 93 |
)
|
| 94 |
submit_btn_cm = gr.Button("Submit")
|
| 95 |
|
|
|
|
| 96 |
submit_btn_cm.click(
|
| 97 |
fn=generate_concept_map,
|
| 98 |
+
inputs=[json_input_cm, output_format_radio],
|
| 99 |
outputs=output_cm
|
| 100 |
)
|
| 101 |
gr.Markdown("<br>")
|
|
|
|
| 118 |
)
|
| 119 |
submit_btn_sc = gr.Button("Submit")
|
| 120 |
|
|
|
|
| 121 |
submit_btn_sc.click(
|
| 122 |
fn=generate_synoptic_chart,
|
| 123 |
+
inputs=[json_input_sc, output_format_radio],
|
| 124 |
outputs=output_sc
|
| 125 |
)
|
| 126 |
gr.Markdown("<br>")
|
|
|
|
| 143 |
)
|
| 144 |
submit_btn_rd = gr.Button("Submit")
|
| 145 |
|
|
|
|
| 146 |
submit_btn_rd.click(
|
| 147 |
fn=generate_radial_diagram,
|
| 148 |
+
inputs=[json_input_rd, output_format_radio],
|
| 149 |
outputs=output_rd
|
| 150 |
)
|
| 151 |
gr.Markdown("<br>")
|
|
|
|
| 154 |
gr.Image(value="./images/rd1.png", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
| 155 |
gr.Image(value="./images/rd2.png", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
| 156 |
|
| 157 |
+
|
| 158 |
with gr.TabItem("Process Flow"):
|
| 159 |
json_input_pf = gr.Textbox(
|
| 160 |
value=PROCESS_FLOW_JSON,
|
|
|
|
| 169 |
)
|
| 170 |
submit_btn_pf = gr.Button("Submit")
|
| 171 |
|
|
|
|
| 172 |
submit_btn_pf.click(
|
| 173 |
fn=generate_process_flow_diagram,
|
| 174 |
+
inputs=[json_input_pf, output_format_radio],
|
| 175 |
outputs=output_pf
|
| 176 |
)
|
| 177 |
gr.Markdown("<br>")
|
|
|
|
| 180 |
gr.Image(value="./images/pf1.png", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
| 181 |
gr.Image(value="./images/pf2.png", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
| 182 |
|
|
|
|
| 183 |
with gr.TabItem("WBS Diagram"):
|
| 184 |
json_input_wbs = gr.Textbox(
|
| 185 |
value=WBS_DIAGRAM_JSON,
|
|
|
|
| 194 |
)
|
| 195 |
submit_btn_wbs = gr.Button("Submit")
|
| 196 |
|
|
|
|
| 197 |
submit_btn_wbs.click(
|
| 198 |
fn=generate_wbs_diagram,
|
| 199 |
+
inputs=[json_input_wbs, output_format_radio],
|
| 200 |
outputs=output_wbs
|
| 201 |
)
|
| 202 |
gr.Markdown("<br>")
|