Update app.py
Browse files
app.py
CHANGED
@@ -131,13 +131,9 @@ mp_face_mesh = mp.solutions.face_mesh
|
|
131 |
face_detection = mp_face_detection.FaceDetection(model_selection=1, min_detection_confidence=0.5)
|
132 |
face_mesh = mp_face_mesh.FaceMesh(static_image_mode=False, max_num_faces=1, min_detection_confidence=0.5)
|
133 |
|
134 |
-
#
|
135 |
-
|
136 |
-
|
137 |
-
model.fc = torch.nn.Linear(model.fc.in_features, 2)
|
138 |
-
return model
|
139 |
-
|
140 |
-
model = create_model()
|
141 |
model.eval()
|
142 |
|
143 |
# Define transformation for face images
|
|
|
131 |
face_detection = mp_face_detection.FaceDetection(model_selection=1, min_detection_confidence=0.5)
|
132 |
face_mesh = mp_face_mesh.FaceMesh(static_image_mode=False, max_num_faces=1, min_detection_confidence=0.5)
|
133 |
|
134 |
+
# Load the model from the .pkl file
|
135 |
+
model = create_model() # Ensure architecture matches the saved model
|
136 |
+
model.load_state_dict(torch.load("resnet34.pkl", map_location=torch.device('cpu'))) # Use 'cuda' if loading on GPU
|
|
|
|
|
|
|
|
|
137 |
model.eval()
|
138 |
|
139 |
# Define transformation for face images
|