Spaces:
Sleeping
Sleeping
kandi1clickkits
commited on
Commit
·
813e8a0
1
Parent(s):
748cd0a
added code
Browse files- __pycache__/gradio.cpython-311.pyc +0 -0
- __pycache__/main.cpython-311.pyc +0 -0
- gradio_app.py +21 -0
- main.py +17 -23
__pycache__/gradio.cpython-311.pyc
ADDED
|
Binary file (898 Bytes). View file
|
|
|
__pycache__/main.cpython-311.pyc
ADDED
|
Binary file (907 Bytes). View file
|
|
|
gradio_app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
+
|
| 4 |
+
simple = pd.DataFrame(
|
| 5 |
+
{
|
| 6 |
+
"item": ["A", "B", "C", "D", "E", "F", "G", "H", "I"],
|
| 7 |
+
"inventory": [28, 55, 43, 91, 81, 53, 19, 87, 52],
|
| 8 |
+
}
|
| 9 |
+
)
|
| 10 |
+
|
| 11 |
+
with gr.Blocks() as demo:
|
| 12 |
+
gr.BarPlot(
|
| 13 |
+
value=simple,
|
| 14 |
+
x="item",
|
| 15 |
+
y="inventory",
|
| 16 |
+
title="Simple Bar Plot",
|
| 17 |
+
container=False,
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
if __name__ == "__main__":
|
| 21 |
+
demo.launch(share=True)
|
main.py
CHANGED
|
@@ -1,27 +1,21 @@
|
|
| 1 |
-
from fastapi import FastAPI, HTTPException
|
| 2 |
-
from fastapi.responses import HTMLResponse
|
| 3 |
import gradio as gr
|
|
|
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
chart_html = create_chart(categories, values)
|
| 15 |
-
iframe_code = f'<iframe srcdoc="{chart_html}" width="600" height="400" frameborder="0"></iframe>'
|
| 16 |
-
return HTMLResponse(content=iframe_code, status_code=200)
|
| 17 |
-
|
| 18 |
-
@app.get("/visualization/", response_class=HTMLResponse)
|
| 19 |
-
async def show_visualization():
|
| 20 |
-
# For simplicity, I'm assuming you have two lists of categories and values
|
| 21 |
-
# Modify this part based on your actual data structure
|
| 22 |
-
categories = ["Category1", "Category2", "Category3"]
|
| 23 |
-
values = [10, 20, 30]
|
| 24 |
-
|
| 25 |
-
chart_html = create_chart(categories, values)
|
| 26 |
-
iframe_code = f'<iframe srcdoc="{chart_html}" width="600" height="400" frameborder="0"></iframe>'
|
| 27 |
-
return HTMLResponse(content=iframe_code, status_code=200)
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
|
| 4 |
+
simple = pd.DataFrame(
|
| 5 |
+
{
|
| 6 |
+
"item": ["A", "B", "C", "D", "E", "F", "G", "H", "I"],
|
| 7 |
+
"inventory": [28, 55, 43, 91, 81, 53, 19, 87, 52],
|
| 8 |
+
}
|
| 9 |
+
)
|
| 10 |
|
| 11 |
+
with gr.Blocks() as demo:
|
| 12 |
+
gr.BarPlot(
|
| 13 |
+
value=simple,
|
| 14 |
+
x="item",
|
| 15 |
+
y="inventory",
|
| 16 |
+
title="Simple Bar Plot",
|
| 17 |
+
container=False,
|
| 18 |
+
)
|
| 19 |
|
| 20 |
+
if __name__ == "__main__":
|
| 21 |
+
demo.launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|