Spaces:
Sleeping
Sleeping
Fix: Version issue
Browse files
app.py
CHANGED
|
@@ -17,8 +17,8 @@ def load_model(model_path: str):
|
|
| 17 |
"""
|
| 18 |
Load the model.
|
| 19 |
"""
|
| 20 |
-
# Load the pre-trained ResNet50 model
|
| 21 |
-
model = models.resnet50(
|
| 22 |
|
| 23 |
# Load custom weights from a .pth file with CPU mapping
|
| 24 |
state_dict = torch.load(model_path, map_location=torch.device('cpu'))
|
|
@@ -37,7 +37,8 @@ def load_classes():
|
|
| 37 |
Load the classes.
|
| 38 |
"""
|
| 39 |
# Get ImageNet class names from ResNet50 weights
|
| 40 |
-
|
|
|
|
| 41 |
return classes
|
| 42 |
|
| 43 |
|
|
@@ -112,7 +113,7 @@ def main():
|
|
| 112 |
)
|
| 113 |
|
| 114 |
# Launch the demo
|
| 115 |
-
demo.launch(server_name="0.0.0.0", debug=True)
|
| 116 |
|
| 117 |
|
| 118 |
if __name__ == "__main__":
|
|
|
|
| 17 |
"""
|
| 18 |
Load the model.
|
| 19 |
"""
|
| 20 |
+
# Load the pre-trained ResNet50 model using the new weights parameter
|
| 21 |
+
model = models.resnet50(weights=None)
|
| 22 |
|
| 23 |
# Load custom weights from a .pth file with CPU mapping
|
| 24 |
state_dict = torch.load(model_path, map_location=torch.device('cpu'))
|
|
|
|
| 37 |
Load the classes.
|
| 38 |
"""
|
| 39 |
# Get ImageNet class names from ResNet50 weights
|
| 40 |
+
weights = models.ResNet50_Weights.IMAGENET1K_V2
|
| 41 |
+
classes = weights.meta["categories"]
|
| 42 |
return classes
|
| 43 |
|
| 44 |
|
|
|
|
| 113 |
)
|
| 114 |
|
| 115 |
# Launch the demo
|
| 116 |
+
demo.launch(server_name="0.0.0.0", debug=True, ssr=False)
|
| 117 |
|
| 118 |
|
| 119 |
if __name__ == "__main__":
|