Spaces:
Runtime error
Runtime error
Create utils.py
Browse files
utils.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
+
import plotly.graph_objects as go
|
| 4 |
+
|
| 5 |
+
patient_info = {"id": "", "description": ""}
|
| 6 |
+
qa_count = 0
|
| 7 |
+
patient_number = 0
|
| 8 |
+
|
| 9 |
+
def normalize_path(path):
|
| 10 |
+
return os.path.normpath(path).replace('\\', '/')
|
| 11 |
+
|
| 12 |
+
def reset_patient():
|
| 13 |
+
global patient_info, qa_count, patient_number
|
| 14 |
+
patient_info = {"id": "", "description": ""}
|
| 15 |
+
qa_count = 0
|
| 16 |
+
patient_number += 1
|
| 17 |
+
return (
|
| 18 |
+
"", # patient_desc
|
| 19 |
+
gr.update(value=""), # qa_desc
|
| 20 |
+
gr.update(visible=True), # patient_input
|
| 21 |
+
gr.update(visible=False), # qa_interface
|
| 22 |
+
gr.update(visible=False), # change_patient_btn
|
| 23 |
+
"", # question_input
|
| 24 |
+
"", # answer_output
|
| 25 |
+
None, # image_output
|
| 26 |
+
go.Figure() # graph_output (empty Plotly figure)
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
def set_patient(patient_description):
|
| 30 |
+
global patient_info, qa_count
|
| 31 |
+
patient_info["description"] = patient_description
|
| 32 |
+
qa_count = 0
|
| 33 |
+
return (
|
| 34 |
+
f"Patient Description: {patient_description}",
|
| 35 |
+
gr.update(visible=True),
|
| 36 |
+
gr.update(visible=False),
|
| 37 |
+
"", # question_input
|
| 38 |
+
"", # answer_output
|
| 39 |
+
None, # image_output
|
| 40 |
+
go.Figure(), # graph_output (empty Plotly figure)
|
| 41 |
+
gr.update(visible=True), # ask_another_question_btn
|
| 42 |
+
gr.update(visible=True) # change_patient_btn
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
def ask_another_question():
|
| 46 |
+
return "", "", None, go.Figure(), gr.update(visible=True), gr.update(visible=False)
|