Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -51,25 +51,25 @@ def predict_class(image):
|
|
51 |
return prediction[0]
|
52 |
|
53 |
# UI Design for single class output
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
|
59 |
|
60 |
# UI Design for multy class output
|
61 |
-
def classify_image(image):
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
|
69 |
|
70 |
inputs = gr.components.Image(type="pil", label="Upload an image")
|
71 |
-
|
72 |
-
outputs = gr.components.Label(num_top_classes=4)
|
73 |
|
74 |
title = "<h1 style='text-align: center;'>Image Classifier</h1>"
|
75 |
description = "Upload an image and get the predicted class."
|
|
|
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 |
+
# print("results is ...", results)
|
64 |
+
# output = {labels.get(i): float(results[i]) for i in range(len(results))}
|
65 |
+
# print("output is ...", output)
|
66 |
+
# result = output if max(output.values()) >=0.98 else {"NO_CIFAR10_CLASS": 1}
|
67 |
+
# return result
|
68 |
|
69 |
|
70 |
inputs = gr.components.Image(type="pil", label="Upload an image")
|
71 |
+
outputs = gr.outputs.HTML() #uncomment for single class output
|
72 |
+
# outputs = gr.components.Label(num_top_classes=4)
|
73 |
|
74 |
title = "<h1 style='text-align: center;'>Image Classifier</h1>"
|
75 |
description = "Upload an image and get the predicted class."
|