Update app.py
Browse files
app.py
CHANGED
|
@@ -12,7 +12,7 @@ with fs.open(efficientnet_model_path, 'rb') as f:
|
|
| 12 |
|
| 13 |
# Load the EfficientNet model onto the CPU
|
| 14 |
efficientnet_model_file = io.BytesIO(efficientnet_model_content)
|
| 15 |
-
|
| 16 |
|
| 17 |
# Authenticate and download your custom model from Hugging Face
|
| 18 |
custom_model_path = 'dhhd255/efficient_net_parkinsons/best_model.pth'
|
|
@@ -21,7 +21,13 @@ with fs.open(custom_model_path, 'rb') as f:
|
|
| 21 |
|
| 22 |
# Load your custom model onto the CPU
|
| 23 |
custom_model_file = io.BytesIO(custom_model_content)
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
model.eval()
|
| 26 |
|
| 27 |
# Define a function that takes an image as input and uses the model for inference
|
|
|
|
| 12 |
|
| 13 |
# Load the EfficientNet model onto the CPU
|
| 14 |
efficientnet_model_file = io.BytesIO(efficientnet_model_content)
|
| 15 |
+
efficientnet_model = torch.load(efficientnet_model_file, map_location=torch.device('cpu'))
|
| 16 |
|
| 17 |
# Authenticate and download your custom model from Hugging Face
|
| 18 |
custom_model_path = 'dhhd255/efficient_net_parkinsons/best_model.pth'
|
|
|
|
| 21 |
|
| 22 |
# Load your custom model onto the CPU
|
| 23 |
custom_model_file = io.BytesIO(custom_model_content)
|
| 24 |
+
custom_model_state_dict = torch.load(custom_model_file, map_location=torch.device('cpu'))
|
| 25 |
+
|
| 26 |
+
# Create a new instance of your model
|
| 27 |
+
model = MyModel()
|
| 28 |
+
|
| 29 |
+
# Load your custom model into the new instance
|
| 30 |
+
model.load_state_dict(custom_model_state_dict)
|
| 31 |
model.eval()
|
| 32 |
|
| 33 |
# Define a function that takes an image as input and uses the model for inference
|