Spaces:
Sleeping
Sleeping
busebaser
commited on
Commit
·
4a1b9e9
1
Parent(s):
49fadad
Fix: Convert boolean prediction to 'Cat' or 'Dog'
Browse files
app.py
CHANGED
@@ -23,11 +23,14 @@ def predict(image):
|
|
23 |
|
24 |
# Run prediction
|
25 |
pred, _, probs = model.predict(image)
|
|
|
|
|
|
|
26 |
confidence = float(probs.max()) # Convert Tensor to float
|
27 |
|
28 |
-
print(f"✅ Prediction successful: {
|
29 |
|
30 |
-
return f"Prediction: {
|
31 |
|
32 |
except Exception as e:
|
33 |
print(f"❌ Error during prediction: {e}")
|
|
|
23 |
|
24 |
# Run prediction
|
25 |
pred, _, probs = model.predict(image)
|
26 |
+
|
27 |
+
# Convert boolean prediction to "Cat" or "Dog"
|
28 |
+
label = "Cat" if pred else "Dog"
|
29 |
confidence = float(probs.max()) # Convert Tensor to float
|
30 |
|
31 |
+
print(f"✅ Prediction successful: {label}, Confidence: {confidence:.2f}")
|
32 |
|
33 |
+
return f"Prediction: {label} (Confidence: {confidence:.2f})"
|
34 |
|
35 |
except Exception as e:
|
36 |
print(f"❌ Error during prediction: {e}")
|