Spaces:
Build error
Build error
fadindashafira
commited on
Commit
·
d1ab033
1
Parent(s):
2cf7aba
update error handler (#2)
Browse files- add error handler (3267ce96c4e1d1b78d2102014505624682459aa0)
- app.py +6 -2
- index.html +2 -2
app.py
CHANGED
@@ -22,6 +22,10 @@ class_names = {
|
|
22 |
}
|
23 |
|
24 |
def classify_image(image_file, label_file):
|
|
|
|
|
|
|
|
|
25 |
data = {"image":image_file, "label":label_file}
|
26 |
batch = preprocess(data)
|
27 |
batch['image'] = batch['image']
|
@@ -66,8 +70,8 @@ with gr.Blocks(theme=gr.themes.Default(primary_hue=page_utils.KALBE_THEME_COLOR,
|
|
66 |
with gr.Row():
|
67 |
with gr.Column():
|
68 |
with gr.Row():
|
69 |
-
inp_img = gr.Image(type="filepath", image_mode="RGB")
|
70 |
-
label_img = gr.Image(type="filepath", image_mode="L")
|
71 |
with gr.Row():
|
72 |
clear_btn = gr.Button(value="Clear")
|
73 |
process_btn = gr.Button(value="Process", variant="primary")
|
|
|
22 |
}
|
23 |
|
24 |
def classify_image(image_file, label_file):
|
25 |
+
if image_file is None:
|
26 |
+
raise gr.Error("Need a histology image")
|
27 |
+
if label_file is None:
|
28 |
+
raise gr.Error("Need a label image")
|
29 |
data = {"image":image_file, "label":label_file}
|
30 |
batch = preprocess(data)
|
31 |
batch['image'] = batch['image']
|
|
|
70 |
with gr.Row():
|
71 |
with gr.Column():
|
72 |
with gr.Row():
|
73 |
+
inp_img = gr.Image(type="filepath", image_mode="RGB", label="Histology Image", show_label=True)
|
74 |
+
label_img = gr.Image(type="filepath", image_mode="L", label="Label Image", show_label=True)
|
75 |
with gr.Row():
|
76 |
clear_btn = gr.Button(value="Clear")
|
77 |
process_btn = gr.Button(value="Process", variant="primary")
|
index.html
CHANGED
@@ -34,8 +34,8 @@
|
|
34 |
</p>
|
35 |
<ul>
|
36 |
<li>Target: Nuclei</li>
|
37 |
-
<li>Task:
|
38 |
-
<li>Modality:
|
39 |
</ul>
|
40 |
</div>
|
41 |
</div>
|
|
|
34 |
</p>
|
35 |
<ul>
|
36 |
<li>Target: Nuclei</li>
|
37 |
+
<li>Task: Classification</li>
|
38 |
+
<li>Modality: Images (Histology and Label) </li>
|
39 |
</ul>
|
40 |
</div>
|
41 |
</div>
|