Hello,
I would like to transfer data from one gradio app to another without including the first one into the second like with Series. To do so, I was wandering if there was a way to access to a gradio.Dataframe data out of the initial app where it is an output.
Ex.
import altair
import gradio as gr
from math import sqrt
import matplotlib
matplotlib.use(“Agg”)
import matplotlib.pyplot as plt
import numpy as np
import plotly.express as px
import pandas as pd
import random
def flip_image(df):
return df[‘x’][0], df[‘y’][1]
def outbreak(f, t0, t1, nbpts):
f = f*1e6
t0 = t0*1e-6
t1 = t1*1e-6
nbpts = int(nbpts)
t = np.arange(t0, t1, (t1-t0)/(nbpts-1))
y = np.sin(2*np.pi*f*t)
fig = plt.figure()
plt.plot(t*1e6,y, '*')
plt.xlabel('t (µm)')
plt.ylabel('sine (A.U.)')
plt.title("Sine function")
df = np.transpose([t, y])
return fig, df
demo = gr.Blocks()
with demo:
gr.Markdown(“Flip text or image files using this demo.”)
with gr.Tabs():
with gr.TabItem(“Sensor Definition”):
inputsensor = [
gr.Number(value = 1, label=“Frequency (MHz)”),
gr.Number(value = 0, label=“t0”),
gr.Number(value = 10, label=“t1”),
gr.Number(value = 50, label=“Number of points”),
]
outputsensor = [gr.Plot(),
gr.Numpy(datatype=“number”, type=“numpy”, headers = [‘t’, ‘y’], interactive = True, visible=True)#gr.Dataframe(row_count = (1887, “fixed”), col_count=(2, “dynamic”), visible=False)
]
text_button = gr.Button("Compute sensor")
with gr.TabItem("Field on z"):
with gr.Row():
image_input = gr.Dataframe(row_count = (1887, "fixed"), col_count=(2, "dynamic"), visible=False)
image_output = [gr.Number(), gr.Number()]
image_button = gr.Button("Flip")
text_button.click(outbreak, inputs=inputsensor, outputs=outputsensor)
image_button.click(flip_image, inputs=image_input, outputs=image_output)
demo.launch()
In this example, the first app generates both a graph and a dataframe. I would like to use this latter into the second app (which is irrelevant in the code above). I manage to have access at an object that is a gradio.dataframe but cannot use it (have access to the data) or transfer it to the second app.
Thanks in advance!