ved1beta
commited on
Commit
·
84c6ebc
1
Parent(s):
7d86658
images
Browse files- app.py +1 -4
- example.jpeg +0 -0
- example2.jpeg +0 -0
app.py
CHANGED
@@ -59,7 +59,6 @@ def predict(img):
|
|
59 |
outputs = model(img)
|
60 |
probabilities = F.softmax(outputs, dim=1)[0]
|
61 |
|
62 |
-
# Create dictionary with all classes and their probabilities
|
63 |
predictions = {
|
64 |
classes[i]: float(probabilities[i]) * 100 # Convert to percentage
|
65 |
for i in range(len(classes))
|
@@ -70,15 +69,13 @@ def predict(img):
|
|
70 |
|
71 |
return sorted_predictions
|
72 |
|
73 |
-
# Create Gradio interface
|
74 |
iface = gr.Interface(
|
75 |
fn=predict,
|
76 |
inputs=gr.Image(type="pil"),
|
77 |
outputs=gr.Label(num_top_classes=10), # Show all 10 classes
|
78 |
-
examples=[["example1.
|
79 |
title="CIFAR-10 Image Classifier",
|
80 |
description="Upload an image to classify it into one of these categories: plane, car, bird, cat, deer, dog, frog, horse, ship, or truck. Results show prediction confidence for all classes as percentages."
|
81 |
)
|
82 |
|
83 |
-
# Launch the app
|
84 |
iface.launch()
|
|
|
59 |
outputs = model(img)
|
60 |
probabilities = F.softmax(outputs, dim=1)[0]
|
61 |
|
|
|
62 |
predictions = {
|
63 |
classes[i]: float(probabilities[i]) * 100 # Convert to percentage
|
64 |
for i in range(len(classes))
|
|
|
69 |
|
70 |
return sorted_predictions
|
71 |
|
|
|
72 |
iface = gr.Interface(
|
73 |
fn=predict,
|
74 |
inputs=gr.Image(type="pil"),
|
75 |
outputs=gr.Label(num_top_classes=10), # Show all 10 classes
|
76 |
+
examples=[["example1.jpeg"], ["example2.jpeg"]], # Optional: Add example images
|
77 |
title="CIFAR-10 Image Classifier",
|
78 |
description="Upload an image to classify it into one of these categories: plane, car, bird, cat, deer, dog, frog, horse, ship, or truck. Results show prediction confidence for all classes as percentages."
|
79 |
)
|
80 |
|
|
|
81 |
iface.launch()
|
example.jpeg
ADDED
![]() |
example2.jpeg
ADDED
![]() |