truens66 commited on
Commit
8304756
·
verified ·
1 Parent(s): 8c6a131

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
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
- # Initialize ResNet-34 model with random weights
135
- def create_model():
136
- model = models.resnet34(pretrained=False)
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