xycold commited on
Commit
a523421
1 Parent(s): a6f0dd8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -27,7 +27,8 @@ def process_file(file):
27
  gr.update(choices=last_column, value=last_column[-1], visible=True),
28
  gr.update(visible=True),
29
  gr.update(visible=True),
30
- df.head()
 
31
  )
32
 
33
  def update_slider(choice):
@@ -65,7 +66,7 @@ def generate_output(file, column1, column2, choice, bins):
65
  plt.savefig(image_path)
66
  # plt.close()
67
 
68
- return df.head(), gr.update(visible=True), image_path, gr.update(visible=True), gr.update(visible=True)
69
 
70
  with gr.Blocks() as demo:
71
  with gr.Row():
@@ -73,7 +74,7 @@ with gr.Blocks() as demo:
73
  file_input = gr.File(label="上传表格文件(支持CSV、XLS、XLSX等格式", file_types=["csv", "xls", "xlsx"])
74
  col1_dropdown = gr.Dropdown(label="请选择特征列", visible=False)
75
  col2_dropdown = gr.Dropdown(label="选择标签列", visible=False)
76
- choice_radio = gr.Radio(["是", "否"], label="特征列是否为连续值", value="否", visible=False)
77
  slider = gr.Slider(minimum=3, maximum=7, step=1, label="选择将特征列分组的分组数", visible=False, value=4)
78
  submit_button = gr.Button("查看结果", visible=False)
79
  with gr.Column():
@@ -81,12 +82,12 @@ with gr.Blocks() as demo:
81
  output_image = gr.Image(visible=False)
82
 
83
  # 文件上传后调用 process_file 函数
84
- file_input.upload(process_file, inputs=file_input, outputs=[col1_dropdown, col2_dropdown, choice_radio, df_display, df_display])
85
 
86
  # 选择框值改变时调用 update_slider 函数
87
  choice_radio.change(update_slider, inputs=choice_radio, outputs=slider)
88
 
89
  # 点击提交按钮时调用 generate_output 函数
90
- submit_button.click(generate_output, inputs=[file_input, col1_dropdown, col2_dropdown, choice_radio, slider], outputs=[df_display, df_display, output_image, output_image, submit_button])
91
 
92
  demo.launch(share=True)
 
27
  gr.update(choices=last_column, value=last_column[-1], visible=True),
28
  gr.update(visible=True),
29
  gr.update(visible=True),
30
+ df.head(),
31
+ gr.update(visible=True)
32
  )
33
 
34
  def update_slider(choice):
 
66
  plt.savefig(image_path)
67
  # plt.close()
68
 
69
+ return df.head(), gr.update(visible=True), image_path, gr.update(visible=True)
70
 
71
  with gr.Blocks() as demo:
72
  with gr.Row():
 
74
  file_input = gr.File(label="上传表格文件(支持CSV、XLS、XLSX等格式", file_types=["csv", "xls", "xlsx"])
75
  col1_dropdown = gr.Dropdown(label="请选择特征列", visible=False)
76
  col2_dropdown = gr.Dropdown(label="选择标签列", visible=False)
77
+ choice_radio = gr.Radio(["是", "否"], label="特征列是否为连续值", visible=False) # , value="否"
78
  slider = gr.Slider(minimum=3, maximum=7, step=1, label="选择将特征列分组的分组数", visible=False, value=4)
79
  submit_button = gr.Button("查看结果", visible=False)
80
  with gr.Column():
 
82
  output_image = gr.Image(visible=False)
83
 
84
  # 文件上传后调用 process_file 函数
85
+ file_input.upload(process_file, inputs=file_input, outputs=[col1_dropdown, col2_dropdown, choice_radio, df_display, df_display, submit_button])
86
 
87
  # 选择框值改变时调用 update_slider 函数
88
  choice_radio.change(update_slider, inputs=choice_radio, outputs=slider)
89
 
90
  # 点击提交按钮时调用 generate_output 函数
91
+ submit_button.click(generate_output, inputs=[file_input, col1_dropdown, col2_dropdown, choice_radio, slider], outputs=[df_display, df_display, output_image, output_image])
92
 
93
  demo.launch(share=True)