Spaces:
Sleeping
Sleeping
refactor: polish visibility logic
Browse files
app.py
CHANGED
@@ -56,28 +56,28 @@ with gr.Blocks() as demo:
|
|
56 |
timeout=600,
|
57 |
)
|
58 |
response.raise_for_status()
|
59 |
-
return
|
|
|
|
|
|
|
60 |
|
61 |
def get_alfred_from_dataframe(ecg_id):
|
62 |
response = requests.post(
|
63 |
f"{ALFRED_URL}/hf_demo/alfred", params={"ecg_id": ecg_id}, timeout=600
|
64 |
)
|
65 |
response.raise_for_status()
|
66 |
-
return
|
67 |
-
alfred_result: literal_eval(response.text),
|
68 |
-
gr_df: gr.Dataframe(visible=True),
|
69 |
-
}
|
70 |
|
71 |
gr_df.select(
|
72 |
fn=get_ecg_id_from_dataframe, inputs=gr_df, outputs=[ecg_id_output, gr_df]
|
73 |
)
|
74 |
ecg_id_output.change(
|
75 |
-
fn=get_ecg_image_from_dataframe,
|
|
|
|
|
76 |
)
|
77 |
ecg_id_output.change(
|
78 |
-
fn=get_alfred_from_dataframe,
|
79 |
-
inputs=ecg_id_output,
|
80 |
-
outputs=[alfred_result, gr_df],
|
81 |
)
|
82 |
|
83 |
demo.launch()
|
|
|
56 |
timeout=600,
|
57 |
)
|
58 |
response.raise_for_status()
|
59 |
+
return {
|
60 |
+
ecg_viewer: imread(BytesIO(response.content)),
|
61 |
+
gr_df: gr.Dataframe(visible=True),
|
62 |
+
}
|
63 |
|
64 |
def get_alfred_from_dataframe(ecg_id):
|
65 |
response = requests.post(
|
66 |
f"{ALFRED_URL}/hf_demo/alfred", params={"ecg_id": ecg_id}, timeout=600
|
67 |
)
|
68 |
response.raise_for_status()
|
69 |
+
return literal_eval(response.text)
|
|
|
|
|
|
|
70 |
|
71 |
gr_df.select(
|
72 |
fn=get_ecg_id_from_dataframe, inputs=gr_df, outputs=[ecg_id_output, gr_df]
|
73 |
)
|
74 |
ecg_id_output.change(
|
75 |
+
fn=get_ecg_image_from_dataframe,
|
76 |
+
inputs=ecg_id_output,
|
77 |
+
outputs=[ecg_viewer, gr_df],
|
78 |
)
|
79 |
ecg_id_output.change(
|
80 |
+
fn=get_alfred_from_dataframe, inputs=ecg_id_output, outputs=alfred_result
|
|
|
|
|
81 |
)
|
82 |
|
83 |
demo.launch()
|