Spaces:
Sleeping
Sleeping
File size: 1,730 Bytes
0198505 a20001f 0198505 ae15986 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
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() |