Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -65,10 +65,25 @@ async def load_model():
|
|
| 65 |
t0 = time.time()
|
| 66 |
|
| 67 |
import torch
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
|
| 74 |
@app.get("/")
|
|
|
|
| 65 |
t0 = time.time()
|
| 66 |
|
| 67 |
import torch
|
| 68 |
+
checkpoint = torch.load(MODEL_PATH, map_location=DEVICE, weights_only=False)
|
| 69 |
+
|
| 70 |
+
# Checkpoint se model nikalo
|
| 71 |
+
if isinstance(checkpoint, dict):
|
| 72 |
+
if 'model' in checkpoint:
|
| 73 |
+
model = checkpoint['model']
|
| 74 |
+
elif 'state_dict' in checkpoint:
|
| 75 |
+
model = checkpoint['state_dict']
|
| 76 |
+
else:
|
| 77 |
+
# Sirf weights hain — keys print karo debug ke liye
|
| 78 |
+
print(f"Checkpoint keys: {list(checkpoint.keys())}")
|
| 79 |
+
model = checkpoint
|
| 80 |
+
else:
|
| 81 |
+
model = checkpoint
|
| 82 |
+
|
| 83 |
+
if hasattr(model, 'eval'):
|
| 84 |
+
model.eval()
|
| 85 |
+
|
| 86 |
+
print(f"✅ Model loaded in {time.time()-t0:.2f}s")
|
| 87 |
|
| 88 |
|
| 89 |
@app.get("/")
|