Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,6 +15,7 @@ from PIL import Image
|
|
| 15 |
import openai
|
| 16 |
import pandas as pd
|
| 17 |
from graphviz import Digraph
|
|
|
|
| 18 |
|
| 19 |
HRA_TOKEN=os.getenv("HRA_TOKEN")
|
| 20 |
|
|
@@ -83,7 +84,15 @@ def getmindmap(topic,openapikey):
|
|
| 83 |
name='temp.png'
|
| 84 |
img.save(name)
|
| 85 |
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
with gr.Blocks() as demo:
|
| 89 |
gr.Markdown("<h1><center>Mind Map Generator</center></h1>")
|
|
@@ -97,11 +106,14 @@ with gr.Blocks() as demo:
|
|
| 97 |
btn = gr.Button("Generate")
|
| 98 |
examples = gr.Examples(examples=['English Premier League','Heavy metal music','Face recognition','Arsenal Football Club',],
|
| 99 |
inputs=[textbox1])
|
|
|
|
|
|
|
|
|
|
| 100 |
with gr.Column():
|
| 101 |
-
|
| 102 |
|
| 103 |
|
| 104 |
-
btn.click(getmindmap,inputs=[textbox1,textbox2], outputs=[output_image1])
|
| 105 |
|
| 106 |
|
| 107 |
demo.launch()
|
|
|
|
| 15 |
import openai
|
| 16 |
import pandas as pd
|
| 17 |
from graphviz import Digraph
|
| 18 |
+
import plotly.express as px
|
| 19 |
|
| 20 |
HRA_TOKEN=os.getenv("HRA_TOKEN")
|
| 21 |
|
|
|
|
| 84 |
name='temp.png'
|
| 85 |
img.save(name)
|
| 86 |
|
| 87 |
+
fig = px.treemap(df, path=['name', 'level1', 'level2'],
|
| 88 |
+
values='count', color='level1')
|
| 89 |
+
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
|
| 90 |
+
fig.show()
|
| 91 |
+
fig.write_image('temp1.png')
|
| 92 |
+
img1 = Image.open("temp1.png")
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
return img,img1
|
| 96 |
|
| 97 |
with gr.Blocks() as demo:
|
| 98 |
gr.Markdown("<h1><center>Mind Map Generator</center></h1>")
|
|
|
|
| 106 |
btn = gr.Button("Generate")
|
| 107 |
examples = gr.Examples(examples=['English Premier League','Heavy metal music','Face recognition','Arsenal Football Club',],
|
| 108 |
inputs=[textbox1])
|
| 109 |
+
with gr.Row() as row:
|
| 110 |
+
with gr.Column():
|
| 111 |
+
output_image1 = gr.components.Image(label="Your Mind Map as Graph")
|
| 112 |
with gr.Column():
|
| 113 |
+
output_image2 = gr.components.Image(label="Your Mind Map as Tree Map")
|
| 114 |
|
| 115 |
|
| 116 |
+
btn.click(getmindmap,inputs=[textbox1,textbox2], outputs=[output_image1,output_image2])
|
| 117 |
|
| 118 |
|
| 119 |
demo.launch()
|