Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,11 +33,11 @@ transform = transforms.Compose([
|
|
| 33 |
def classify_image(image):
|
| 34 |
image = transform(image).unsqueeze(0).to(device) # Preprocess image
|
| 35 |
with torch.no_grad():
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
|
| 42 |
return f"Predicted Class: {class_labels[predicted_class]}"
|
| 43 |
|
|
|
|
| 33 |
def classify_image(image):
|
| 34 |
image = transform(image).unsqueeze(0).to(device) # Preprocess image
|
| 35 |
with torch.no_grad():
|
| 36 |
+
output = model(image)
|
| 37 |
+
# ✅ Extract first element if output is a tuple
|
| 38 |
+
if isinstance(output, tuple):
|
| 39 |
+
output = output[1]
|
| 40 |
+
predicted_class = torch.argmax(output, dim=1).item()
|
| 41 |
|
| 42 |
return f"Predicted Class: {class_labels[predicted_class]}"
|
| 43 |
|