Spaces:
Sleeping
Sleeping
Diego Salinas commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import matplotlib.pyplot as plt
|
|
|
|
| 3 |
|
| 4 |
def create_portfolio_graph():
|
| 5 |
# Data for the bars
|
|
@@ -23,10 +24,13 @@ def create_portfolio_graph():
|
|
| 23 |
plt.savefig("/mnt/data/portfolio_chart.png")
|
| 24 |
plt.close()
|
| 25 |
|
|
|
|
|
|
|
|
|
|
| 26 |
# Gradio Interface (without user input)
|
| 27 |
iface = gr.Interface(
|
| 28 |
fn=create_portfolio_graph,
|
| 29 |
-
outputs=gr.Image(type="
|
| 30 |
live=True,
|
| 31 |
capture_session=True
|
| 32 |
)
|
|
@@ -40,3 +44,4 @@ iface.launch()
|
|
| 40 |
|
| 41 |
|
| 42 |
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import matplotlib.pyplot as plt
|
| 3 |
+
import numpy as np
|
| 4 |
|
| 5 |
def create_portfolio_graph():
|
| 6 |
# Data for the bars
|
|
|
|
| 24 |
plt.savefig("/mnt/data/portfolio_chart.png")
|
| 25 |
plt.close()
|
| 26 |
|
| 27 |
+
# Return the image as a NumPy array
|
| 28 |
+
return np.array(plt.imread("/mnt/data/portfolio_chart.png"))
|
| 29 |
+
|
| 30 |
# Gradio Interface (without user input)
|
| 31 |
iface = gr.Interface(
|
| 32 |
fn=create_portfolio_graph,
|
| 33 |
+
outputs=gr.Image(type="numpy", label="Portfolio Composition Chart"),
|
| 34 |
live=True,
|
| 35 |
capture_session=True
|
| 36 |
)
|
|
|
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
+
|