Spaces:
Runtime error
Runtime error
Commit ·
1cd0cab
1
Parent(s): 2b21ef9
asdf
Browse files
app.py
CHANGED
|
@@ -24,6 +24,11 @@ def classify_image(img):
|
|
| 24 |
result[key] = {"color": color_result.get(key, 0.0), "shape": shape_result.get(key, 0.0)}
|
| 25 |
return result
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
image = gr.inputs.Image(shape=(256, 256))
|
| 29 |
label = gr.outputs.Label()
|
|
@@ -34,8 +39,7 @@ intf = gr.Interface(
|
|
| 34 |
outputs=label,
|
| 35 |
examples="",
|
| 36 |
title="Lego Brick Classifier",
|
| 37 |
-
layout="vertical"
|
|
|
|
| 38 |
)
|
| 39 |
intf.launch()
|
| 40 |
-
|
| 41 |
-
|
|
|
|
| 24 |
result[key] = {"color": color_result.get(key, 0.0), "shape": shape_result.get(key, 0.0)}
|
| 25 |
return result
|
| 26 |
|
| 27 |
+
def postprocess(prediction):
|
| 28 |
+
result = {}
|
| 29 |
+
for key in prediction.keys():
|
| 30 |
+
result[key] = max(prediction[key].items(), key=lambda x: x[1])[0]
|
| 31 |
+
return result
|
| 32 |
|
| 33 |
image = gr.inputs.Image(shape=(256, 256))
|
| 34 |
label = gr.outputs.Label()
|
|
|
|
| 39 |
outputs=label,
|
| 40 |
examples="",
|
| 41 |
title="Lego Brick Classifier",
|
| 42 |
+
layout="vertical",
|
| 43 |
+
postprocess=postprocess
|
| 44 |
)
|
| 45 |
intf.launch()
|
|
|
|
|
|