Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,14 +38,14 @@ try:
|
|
| 38 |
except Exception as e:
|
| 39 |
print(f"⚠️ Error loading model from best.pt: {e}")
|
| 40 |
try:
|
| 41 |
-
# Fallback to checkpoints directory
|
| 42 |
-
model.load_state_dict(torch.load('checkpoints/
|
| 43 |
-
print("✅ Multi-class model loaded successfully from checkpoints/
|
| 44 |
except Exception as e2:
|
| 45 |
print(f"❌ CRITICAL ERROR: Could not load model from any location!")
|
| 46 |
print(f" - best.pt error: {e}")
|
| 47 |
-
print(f" - checkpoints/
|
| 48 |
-
raise RuntimeError("Model file not found! Please ensure best.pt is uploaded to the Space.")
|
| 49 |
|
| 50 |
model = model.to(device)
|
| 51 |
model.eval()
|
|
@@ -622,4 +622,3 @@ if __name__ == "__main__":
|
|
| 622 |
server_port=7860,
|
| 623 |
show_error=True
|
| 624 |
)
|
| 625 |
-
|
|
|
|
| 38 |
except Exception as e:
|
| 39 |
print(f"⚠️ Error loading model from best.pt: {e}")
|
| 40 |
try:
|
| 41 |
+
# Fallback to checkpoints directory (where best.pt is actually stored)
|
| 42 |
+
model.load_state_dict(torch.load('checkpoints/best.pt', map_location=device))
|
| 43 |
+
print("✅ Multi-class model loaded successfully from checkpoints/best.pt!")
|
| 44 |
except Exception as e2:
|
| 45 |
print(f"❌ CRITICAL ERROR: Could not load model from any location!")
|
| 46 |
print(f" - best.pt error: {e}")
|
| 47 |
+
print(f" - checkpoints/best.pt error: {e2}")
|
| 48 |
+
raise RuntimeError("Model file not found! Please ensure best.pt is uploaded to the Space (in /checkpoints or root).")
|
| 49 |
|
| 50 |
model = model.to(device)
|
| 51 |
model.eval()
|
|
|
|
| 622 |
server_port=7860,
|
| 623 |
show_error=True
|
| 624 |
)
|
|
|