Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
import matplotlib.pyplot as plt
|
| 3 |
import io
|
| 4 |
import base64
|
|
@@ -28,6 +29,8 @@ def create_bar_chart(a, b, c):
|
|
| 28 |
img_base64 = base64.b64encode(buf.read()).decode('utf-8')
|
| 29 |
buf.close()
|
| 30 |
|
|
|
|
|
|
|
| 31 |
return img_base64
|
| 32 |
|
| 33 |
# Funci贸n para utilizar en Gradio
|
|
@@ -39,9 +42,9 @@ def gradio_interface(a, b, c):
|
|
| 39 |
demo = gr.Interface(
|
| 40 |
fn=gradio_interface,
|
| 41 |
inputs=[
|
| 42 |
-
gr.Number(
|
| 43 |
-
gr.Number(
|
| 44 |
-
gr.Number(
|
| 45 |
],
|
| 46 |
outputs=gr.Image(label="Gr谩fico de Barras"),
|
| 47 |
title="Generador de Gr谩ficos de Barras",
|
|
@@ -49,3 +52,4 @@ demo = gr.Interface(
|
|
| 49 |
)
|
| 50 |
|
| 51 |
demo.launch(share=True)
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import gradio as gr
|
| 3 |
import matplotlib.pyplot as plt
|
| 4 |
import io
|
| 5 |
import base64
|
|
|
|
| 29 |
img_base64 = base64.b64encode(buf.read()).decode('utf-8')
|
| 30 |
buf.close()
|
| 31 |
|
| 32 |
+
plt.close() # Cerrar la figura para liberar recursos
|
| 33 |
+
|
| 34 |
return img_base64
|
| 35 |
|
| 36 |
# Funci贸n para utilizar en Gradio
|
|
|
|
| 42 |
demo = gr.Interface(
|
| 43 |
fn=gradio_interface,
|
| 44 |
inputs=[
|
| 45 |
+
gr.Number(name="a", label="Valor A", default=a),
|
| 46 |
+
gr.Number(name="b", label="Valor B", default=b),
|
| 47 |
+
gr.Number(name="c", label="Valor C", default=c)
|
| 48 |
],
|
| 49 |
outputs=gr.Image(label="Gr谩fico de Barras"),
|
| 50 |
title="Generador de Gr谩ficos de Barras",
|
|
|
|
| 52 |
)
|
| 53 |
|
| 54 |
demo.launch(share=True)
|
| 55 |
+
|