murphy / app.py
cheesexuebao's picture
test upload and download file
a20001f
raw
history blame
1.73 kB
import gradio as gr
import pandas as pd
import matplotlib.pyplot as plt
# from Prediction import *
# 定义处理函数
def process_data(csv_file, num, model_name):
# 读取CSV文件
df = pd.read_csv(csv_file.name)
# 处理数据
processed_data = df * num
# 生成图片
plt.plot(processed_data)
plt.xlabel('X Label')
plt.ylabel('Y Label')
plt.title('Processed Data')
plt.grid(True)
plt.savefig('output.png')
plt.close()
# 生成字符串结果
result = pd.DataFrame({'result':[1,2,3]})
result.to_csv('output.csv')
print(model_name)
return 'output.csv', ['output.png','output.png']
my_theme = gr.Theme.from_hub("gstaff/sketch")
with gr.Blocks(theme=my_theme, title='Test') as demo:
gr.Markdown("""# Test
xxxx
""")
with gr.Tab("Single Sentence"):
with gr.Column():
csv_input = gr.File(label="CSV文件")
text_output = gr.File(label="结果")
image_output = gr.Gallery(label="图像")
with gr.Row():
seed_input = gr.Slider(minimum=0, maximum=100, step=1, label="seed",info="Different seeds may generate different results")
model_input = gr.CheckboxGroup(["ALL_Data", "Facebook", "Kickstarter", "Twitter"], label="Countries", info="Where are they from?")
with gr.Row():
button = gr.Button("Submit", variant="primary")
button.click(fn=process_data, inputs=[csv_input, seed_input, model_input], outputs=[text_output, image_output])
clear = gr.ClearButton([csv_input, text_output, image_output])
with gr.Tab("Csv File"):
...
with gr.Tab("README"):
seed_input = gr.Textbox(label="seed")
demo.launch()