orrinin commited on
Commit
79d6899
·
verified ·
1 Parent(s): ca5822d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -16
app.py CHANGED
@@ -85,7 +85,19 @@ def process_image(image_input, unit):
85
 
86
  return "等待分析..."
87
 
88
-
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
 
91
  def main(text_input="", image_input=None, unit=""):
@@ -103,7 +115,7 @@ with gr.Blocks(css=css, title="家庭医生AI助手") as iface:
103
  "整形美容科", "营养科", "生殖中心", "麻醉医学科", "医学影像科", \
104
  "骨科", "肿瘤科", "急诊科", "检验科"])
105
  with gr.Row():
106
- output_box = gr.Markdown(value=result, every=10, label="分析")
107
  with gr.Row():
108
  image_input = gr.Image(type="filepath", label="上传图片") # Create an image upload button
109
  text_input = gr.Textbox(label="输入") # Create a text input box
@@ -111,21 +123,9 @@ with gr.Blocks(css=css, title="家庭医生AI助手") as iface:
111
  submit_btn = gr.Button("🚀 确认") # Create a submit button
112
  clear_btn = gr.ClearButton([output_box,image_input,text_input], value="🗑️ 清空") # Create a clear button
113
 
114
- def update():
115
- if json_path:
116
- job = client.submit(
117
- json_path,
118
- fn_index=1
119
- )
120
- response = job.result(timeout=60)
121
- with open(response, 'r') as f:
122
- data = json.load(f)
123
- print(data)
124
- result = data[-1][1]
125
- else:
126
- return
127
  # Set up the event listeners
128
- submit_btn.click(main, inputs=[text_input, image_input, unit], outputs=output_box).then(update)
129
  gr.Markdown(LICENSE)
130
 
131
  #gr.close_all()
 
85
 
86
  return "等待分析..."
87
 
88
+ def update(json_path: str):
89
+ if json_path:
90
+ job = client.submit(
91
+ json_path,
92
+ fn_index=1
93
+ )
94
+ response = job.result(timeout=60)
95
+ with open(response, 'r') as f:
96
+ data = json.load(f)
97
+ print(data)
98
+ result = data[-1][1]
99
+ else:
100
+ return
101
 
102
 
103
  def main(text_input="", image_input=None, unit=""):
 
115
  "整形美容科", "营养科", "生殖中心", "麻醉医学科", "医学影像科", \
116
  "骨科", "肿瘤科", "急诊科", "检验科"])
117
  with gr.Row():
118
+ output_box = gr.Markdown(value=result, every=10, label="分析").change(update(json_path))
119
  with gr.Row():
120
  image_input = gr.Image(type="filepath", label="上传图片") # Create an image upload button
121
  text_input = gr.Textbox(label="输入") # Create a text input box
 
123
  submit_btn = gr.Button("🚀 确认") # Create a submit button
124
  clear_btn = gr.ClearButton([output_box,image_input,text_input], value="🗑️ 清空") # Create a clear button
125
 
126
+
 
 
 
 
 
 
 
 
 
 
 
 
127
  # Set up the event listeners
128
+ submit_btn.click(main, inputs=[text_input, image_input, unit], outputs=output_box)
129
  gr.Markdown(LICENSE)
130
 
131
  #gr.close_all()