Spaces:
Runtime error
Runtime error
Update model.py
Browse files
model.py
CHANGED
|
@@ -150,7 +150,7 @@ class Trainer:
|
|
| 150 |
|
| 151 |
def predict(self, inputs):
|
| 152 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 153 |
-
self.model.load_state_dict(torch.load('best_model.pth', weights_only=True))
|
| 154 |
self.model.to(device)
|
| 155 |
self.model.eval()
|
| 156 |
inputs = inputs.to(device)
|
|
@@ -158,11 +158,11 @@ class Trainer:
|
|
| 158 |
outputs = self.model(inputs)
|
| 159 |
return outputs
|
| 160 |
|
| 161 |
-
if __name__ == "__main__":
|
| 162 |
-
|
| 163 |
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
|
|
|
| 150 |
|
| 151 |
def predict(self, inputs):
|
| 152 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 153 |
+
self.model.load_state_dict(torch.load('best_model.pth', weights_only=True, map_location=torch.device('cpu'))
|
| 154 |
self.model.to(device)
|
| 155 |
self.model.eval()
|
| 156 |
inputs = inputs.to(device)
|
|
|
|
| 158 |
outputs = self.model(inputs)
|
| 159 |
return outputs
|
| 160 |
|
| 161 |
+
# if __name__ == "__main__":
|
| 162 |
+
# trainer = Trainer()
|
| 163 |
|
| 164 |
+
# # Test the model
|
| 165 |
+
# image_path = '6082308423334085331.jpg'
|
| 166 |
+
# image_tensor = trainer.image_to_tensor(image_path)
|
| 167 |
+
# prediction = trainer.predict(image_tensor)
|
| 168 |
+
# print(f"Predicted Beauty Score: {prediction.item() * 100}")
|