Update app.py
Browse files
app.py
CHANGED
|
@@ -22,6 +22,7 @@ DESCRIPTION = '''
|
|
| 22 |
<p>🩺一个帮助您分析症状和检验报告的家庭医生(AI诊疗助手)。</p>
|
| 23 |
<p>🔎 选择您需要咨询的科室医生,在输入框中输入症状描述或者体检信息等;您也可以在图片框中上传检测报告图。</p>
|
| 24 |
<p>🦕 请注意生成信息可能不准确,且不具备任何实际参考价值,如有需要请联系专业医生。</p>
|
|
|
|
| 25 |
</div>
|
| 26 |
'''
|
| 27 |
|
|
@@ -56,7 +57,7 @@ def process_text(text_input, unit):
|
|
| 56 |
response = job.result()
|
| 57 |
print(response)
|
| 58 |
result = response[1][0][1]
|
| 59 |
-
|
| 60 |
|
| 61 |
def process_image(image_input, unit):
|
| 62 |
global result, json_path
|
|
@@ -99,8 +100,8 @@ def process_image(image_input, unit):
|
|
| 99 |
|
| 100 |
threading.Thread(target=update).start()
|
| 101 |
|
| 102 |
-
|
| 103 |
-
|
| 104 |
|
| 105 |
def reset_result():
|
| 106 |
result = 0
|
|
@@ -111,7 +112,7 @@ def main(text_input="", image_input=None, unit=""):
|
|
| 111 |
process_text(text_input, unit)
|
| 112 |
elif image_input is not None:
|
| 113 |
process_image(image_input, unit)
|
| 114 |
-
|
| 115 |
|
| 116 |
with gr.Blocks(css=css, title="家庭医生AI助手", theme="soft") as iface:
|
| 117 |
with gr.Accordion(""):
|
|
@@ -129,11 +130,14 @@ with gr.Blocks(css=css, title="家庭医生AI助手", theme="soft") as iface:
|
|
| 129 |
text_input = gr.Textbox(label="输入") # Create a text input box
|
| 130 |
with gr.Row():
|
| 131 |
submit_btn = gr.Button("🚀 确认") # Create a submit button
|
|
|
|
| 132 |
clear_btn = gr.ClearButton([output_box, image_input, text_input], value="🗑️ 清空") # Create a clear button
|
| 133 |
-
|
| 134 |
|
| 135 |
# Set up the event listeners
|
| 136 |
submit_btn.click(main, inputs=[text_input, image_input, unit], outputs=output_box)
|
|
|
|
|
|
|
| 137 |
|
| 138 |
|
| 139 |
gr.Markdown(LICENSE)
|
|
|
|
| 22 |
<p>🩺一个帮助您分析症状和检验报告的家庭医生(AI诊疗助手)。</p>
|
| 23 |
<p>🔎 选择您需要咨询的科室医生,在输入框中输入症状描述或者体检信息等;您也可以在图片框中上传检测报告图。</p>
|
| 24 |
<p>🦕 请注意生成信息可能不准确,且不具备任何实际参考价值,如有需要请联系专业医生。</p>
|
| 25 |
+
<p>💾 由于网络环境问题,如果长时间未出现分析内容,您可以点击刷新,尝试获取结果。</p>
|
| 26 |
</div>
|
| 27 |
'''
|
| 28 |
|
|
|
|
| 57 |
response = job.result()
|
| 58 |
print(response)
|
| 59 |
result = response[1][0][1]
|
| 60 |
+
|
| 61 |
|
| 62 |
def process_image(image_input, unit):
|
| 63 |
global result, json_path
|
|
|
|
| 100 |
|
| 101 |
threading.Thread(target=update).start()
|
| 102 |
|
| 103 |
+
def fetch_result():
|
| 104 |
+
return result
|
| 105 |
|
| 106 |
def reset_result():
|
| 107 |
result = 0
|
|
|
|
| 112 |
process_text(text_input, unit)
|
| 113 |
elif image_input is not None:
|
| 114 |
process_image(image_input, unit)
|
| 115 |
+
return result
|
| 116 |
|
| 117 |
with gr.Blocks(css=css, title="家庭医生AI助手", theme="soft") as iface:
|
| 118 |
with gr.Accordion(""):
|
|
|
|
| 130 |
text_input = gr.Textbox(label="输入") # Create a text input box
|
| 131 |
with gr.Row():
|
| 132 |
submit_btn = gr.Button("🚀 确认") # Create a submit button
|
| 133 |
+
fresh_btn = gr.Button("✨ 刷新")
|
| 134 |
clear_btn = gr.ClearButton([output_box, image_input, text_input], value="🗑️ 清空") # Create a clear button
|
| 135 |
+
|
| 136 |
|
| 137 |
# Set up the event listeners
|
| 138 |
submit_btn.click(main, inputs=[text_input, image_input, unit], outputs=output_box)
|
| 139 |
+
fresh_btn.click(fn=fetch_result, outputs=output_box)
|
| 140 |
+
clear_btn.click(fn=reset_result)
|
| 141 |
|
| 142 |
|
| 143 |
gr.Markdown(LICENSE)
|