app.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # -*- coding: utf-8 -*-
  2. """
  3. @author: yq
  4. @time: 2024/12/4
  5. @desc:
  6. """
  7. import gradio as gr
  8. from webui import f_project_is_exist, f_data_upload, engine
  9. input_elems = set()
  10. elem_dict = {}
  11. with gr.Blocks("Easy-ML") as demo:
  12. gr.HTML('<h1 ><center><font size="5">Easy-ML</font></center></h1>')
  13. gr.HTML('<h2 ><center><font size="2">快速建模工具</font></center></h2>')
  14. with gr.Tabs():
  15. with gr.TabItem("数据"):
  16. with gr.Row():
  17. project_name = gr.Textbox(label="项目名称", placeholder="请输入不重复的项目名称",
  18. info="项目名称将会被作为缓存目录名称,如果重复会导致结果被覆盖")
  19. with gr.Row():
  20. file_data = gr.File(label="建模数据")
  21. with gr.TabItem("训练"):
  22. with gr.Row():
  23. with gr.Column():
  24. model_type = gr.Dropdown(["lr"], value="lr", label="模型")
  25. search_strategy = gr.Dropdown(["iv"], value="iv", label="特征搜索策略")
  26. gr.Textbox(label="Y标签")
  27. gr.Textbox(label="X特征")
  28. gr.Slider(0.05, 1, value=0.1, label="分箱组合采样率", step=0.01),
  29. train_button = gr.Button("开始训练", variant="primary")
  30. with gr.Column():
  31. gr.Textbox(value="输出")
  32. input_elems.update({project_name, file_data, model_type, search_strategy})
  33. elem_dict.update(dict(
  34. project_name=project_name,
  35. file_data=file_data,
  36. model_type=model_type,
  37. search_strategy=search_strategy
  38. ))
  39. engine.add_elems(elem_dict)
  40. project_name.change(fn=f_project_is_exist, inputs=input_elems)
  41. file_data.upload(fn=f_data_upload, inputs=input_elems, outputs=[])
  42. demo.launch(share=True)
  43. if __name__ == "__main__":
  44. pass