Spaces:
Build error
Build error
Commit ·
e980426
1
Parent(s): f160696
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,13 +42,25 @@ def predict_class(image):
|
|
| 42 |
return predicted_class
|
| 43 |
|
| 44 |
# UI Design
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
def classify_image(image):
|
| 46 |
-
|
| 47 |
-
output =
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
return output
|
| 49 |
|
|
|
|
|
|
|
| 50 |
inputs = gr.inputs.Image(label="Upload an image")
|
| 51 |
-
outputs = gr.outputs.HTML(
|
|
|
|
| 52 |
|
| 53 |
title = "<h1 style='text-align: center;'>Image Classifier</h1>"
|
| 54 |
description = "Upload an image and get the predicted class."
|
|
|
|
| 42 |
return predicted_class
|
| 43 |
|
| 44 |
# UI Design
|
| 45 |
+
# def classify_image(image):
|
| 46 |
+
# predicted_class = predict_class(image)
|
| 47 |
+
# output = f"<h2>Predicted Class: <span style='text-transform:uppercase';>{predicted_class}</span></h2>"
|
| 48 |
+
# return output
|
| 49 |
+
|
| 50 |
def classify_image(image):
|
| 51 |
+
results = predict_class(image)
|
| 52 |
+
output = {}
|
| 53 |
+
for prediction in results:
|
| 54 |
+
predicted_label = prediction['label']
|
| 55 |
+
score = prediction['score']
|
| 56 |
+
output[predicted_label] = score
|
| 57 |
return output
|
| 58 |
|
| 59 |
+
|
| 60 |
+
|
| 61 |
inputs = gr.inputs.Image(label="Upload an image")
|
| 62 |
+
# outputs = gr.outputs.HTML()
|
| 63 |
+
outputs = gr.outputs.Label(num_top_classes=10)
|
| 64 |
|
| 65 |
title = "<h1 style='text-align: center;'>Image Classifier</h1>"
|
| 66 |
description = "Upload an image and get the predicted class."
|