Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -95,17 +95,15 @@ keys_to_organ_kind = {
|
|
95 |
|
96 |
|
97 |
def update_organ_and_kind(selected_key):
|
98 |
-
"""根据选择的 Keys 更新 Organ 和 Kind"""
|
99 |
organs = keys_to_organ_kind[selected_key]["organs"]
|
100 |
-
|
101 |
-
kinds = keys_to_organ_kind[selected_key]["kinds"][
|
102 |
-
return gr.update(choices=organs, value=
|
103 |
|
104 |
|
105 |
def update_kind(selected_key, selected_organ):
|
106 |
-
"""根据选择的 Organ 更新 Kind"""
|
107 |
kinds = keys_to_organ_kind[selected_key]["kinds"][selected_organ]
|
108 |
-
return gr.update(choices=kinds, value=kinds
|
109 |
|
110 |
|
111 |
def generate_image(organ, kinds, keys):
|
@@ -134,19 +132,19 @@ with gr.Blocks() as demo:
|
|
134 |
output_image = gr.Image(label="Visualization")
|
135 |
generate_button.click(generate_image, inputs=[organ_dropdown, kind_checkbox, keys_dropdown], outputs=output_image)
|
136 |
|
137 |
-
# 使用 Examples 时更新组织和类型
|
138 |
-
gr.Examples(
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
)
|
151 |
|
152 |
demo.launch()
|
|
|
95 |
|
96 |
|
97 |
def update_organ_and_kind(selected_key):
|
|
|
98 |
organs = keys_to_organ_kind[selected_key]["organs"]
|
99 |
+
first_organ = organs[0] # 默认选第一个 organ
|
100 |
+
kinds = keys_to_organ_kind[selected_key]["kinds"][first_organ]
|
101 |
+
return gr.update(choices=organs, value=first_organ), gr.update(choices=kinds, value=kinds)
|
102 |
|
103 |
|
104 |
def update_kind(selected_key, selected_organ):
|
|
|
105 |
kinds = keys_to_organ_kind[selected_key]["kinds"][selected_organ]
|
106 |
+
return gr.update(choices=kinds, value=kinds)
|
107 |
|
108 |
|
109 |
def generate_image(organ, kinds, keys):
|
|
|
132 |
output_image = gr.Image(label="Visualization")
|
133 |
generate_button.click(generate_image, inputs=[organ_dropdown, kind_checkbox, keys_dropdown], outputs=output_image)
|
134 |
|
135 |
+
# # 使用 Examples 时更新组织和类型
|
136 |
+
# gr.Examples(
|
137 |
+
# examples=[
|
138 |
+
# ["CVC-ClinicDB", "polyp colonoscopy", ["polyp"]],
|
139 |
+
# ["BUSI", "breast ultrasound", ["breast tumor"]],
|
140 |
+
# ["LiTS2017", "abdomen CT scans", ["liver", "liver tumor"]],
|
141 |
+
# ["KiTS2019", "abdomen CT scans", ["kidney", "kidney tumor"]],
|
142 |
+
# ["ACDC", "cardiovascular ventricle mri", ["right ventricle", "myocardium", "left ventricle"]],
|
143 |
+
# ["AMOS2022", "abdomen CT scans", ["liver", "right kidney", "spleen"]]
|
144 |
+
# ],
|
145 |
+
# inputs=[keys_dropdown, organ_dropdown, kind_checkbox],
|
146 |
+
# outputs=[organ_dropdown, kind_checkbox],
|
147 |
+
# fn=update_organ_and_kind, # 通过 fn 更新 organ 和 kind
|
148 |
+
# )
|
149 |
|
150 |
demo.launch()
|