Spaces:
Runtime error
Runtime error
Updated to work with heic images.
Browse files
app.py
CHANGED
|
@@ -37,6 +37,9 @@ def predict_multi_out(input):
|
|
| 37 |
{ventedType[i]['label']:
|
| 38 |
ventedType[i]['confidence'] for i in range(len(ventedType))})
|
| 39 |
|
|
|
|
|
|
|
|
|
|
| 40 |
# %% Create the interface
|
| 41 |
label_singleOut = gr.components.Label(label='Mask')
|
| 42 |
label_manufacturer = gr.components.Label(label='Manufacturer')
|
|
@@ -53,6 +56,7 @@ examples = ["NoMask.jpg",
|
|
| 53 |
|
| 54 |
title = "Mask Classifier"
|
| 55 |
|
|
|
|
| 56 |
single_out = gr.Interface(
|
| 57 |
fn=predict_single_out,
|
| 58 |
inputs=gr.Image(type="filepath"),
|
|
@@ -61,6 +65,10 @@ single_out = gr.Interface(
|
|
| 61 |
title="Single Output Mask Classifier",
|
| 62 |
live=True)
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
multi_out = gr.Interface(
|
| 65 |
fn=predict_multi_out,
|
| 66 |
inputs=gr.Image(type="filepath"),
|
|
@@ -68,7 +76,11 @@ multi_out = gr.Interface(
|
|
| 68 |
examples=examples,
|
| 69 |
title="Multi Output Mask Classifier",
|
| 70 |
live=True)
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
intf = gr.TabbedInterface([single_out, multi_out], ["Single Output", "Multi Output"], title)
|
| 73 |
|
| 74 |
if __name__ == "__main__":
|
|
|
|
| 37 |
{ventedType[i]['label']:
|
| 38 |
ventedType[i]['confidence'] for i in range(len(ventedType))})
|
| 39 |
|
| 40 |
+
def identity_fn(img):
|
| 41 |
+
return img
|
| 42 |
+
|
| 43 |
# %% Create the interface
|
| 44 |
label_singleOut = gr.components.Label(label='Mask')
|
| 45 |
label_manufacturer = gr.components.Label(label='Manufacturer')
|
|
|
|
| 56 |
|
| 57 |
title = "Mask Classifier"
|
| 58 |
|
| 59 |
+
# Single Out Interface
|
| 60 |
single_out = gr.Interface(
|
| 61 |
fn=predict_single_out,
|
| 62 |
inputs=gr.Image(type="filepath"),
|
|
|
|
| 65 |
title="Single Output Mask Classifier",
|
| 66 |
live=True)
|
| 67 |
|
| 68 |
+
with single_out:
|
| 69 |
+
image_single_out.upload(fn=identity_fn, inputs=image_single_out, outputs=image_single_out)
|
| 70 |
+
|
| 71 |
+
# Multi Out Interface
|
| 72 |
multi_out = gr.Interface(
|
| 73 |
fn=predict_multi_out,
|
| 74 |
inputs=gr.Image(type="filepath"),
|
|
|
|
| 76 |
examples=examples,
|
| 77 |
title="Multi Output Mask Classifier",
|
| 78 |
live=True)
|
| 79 |
+
|
| 80 |
+
with multi_out:
|
| 81 |
+
image_multi_out.upload(fn=identity_fn, inputs=image_multi_out, outputs=image_multi_out)
|
| 82 |
+
|
| 83 |
+
# Combined interface
|
| 84 |
intf = gr.TabbedInterface([single_out, multi_out], ["Single Output", "Multi Output"], title)
|
| 85 |
|
| 86 |
if __name__ == "__main__":
|