Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -51,18 +51,18 @@ def predict_class(image):
|
|
51 |
return prediction[0]
|
52 |
|
53 |
# UI Design for single class output
|
54 |
-
def classify_image(image):
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
|
59 |
|
60 |
# UI Design for multy class output
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
|
67 |
|
68 |
inputs = gr.components.Image(type="pil", label="Upload an image")
|
|
|
51 |
return prediction[0]
|
52 |
|
53 |
# UI Design for single class output
|
54 |
+
# def classify_image(image):
|
55 |
+
# predicted_class = predict_class(image)
|
56 |
+
# output = f"<h2>Predicted Class: <span style='text-transform:uppercase';>{predicted_class}</span></h2>"
|
57 |
+
# return output
|
58 |
|
59 |
|
60 |
# UI Design for multy class output
|
61 |
+
def classify_image(image):
|
62 |
+
results = predict_class(image)
|
63 |
+
output = {labels.get(i): float(results[i]) for i in range(len(results))}
|
64 |
+
result = output if max(output.values()) >=0.98 else {"NO_CIFAR10_CLASS": 1}
|
65 |
+
return result[0]
|
66 |
|
67 |
|
68 |
inputs = gr.components.Image(type="pil", label="Upload an image")
|