Spaces:
Runtime error
Runtime error
Commit ·
64f4123
1
Parent(s): 921874b
updated
Browse files
app/Hackathon_setup/exp_recognition.py
CHANGED
|
@@ -66,9 +66,12 @@ def get_expression(img):
|
|
| 66 |
model = torch.load(current_path + '/exp_recognition_net.t7', map_location=device)
|
| 67 |
face_det_net.load_state_dict(model['net_dict'])
|
| 68 |
face = detected_face(img)
|
| 69 |
-
|
|
|
|
| 70 |
face = Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2GRAY))
|
| 71 |
-
|
|
|
|
|
|
|
| 72 |
output = face_det_net(face)
|
| 73 |
|
| 74 |
# YOUR CODE HERE, return expression using your model
|
|
|
|
| 66 |
model = torch.load(current_path + '/exp_recognition_net.t7', map_location=device)
|
| 67 |
face_det_net.load_state_dict(model['net_dict'])
|
| 68 |
face = detected_face(img)
|
| 69 |
+
|
| 70 |
+
if face == 0:
|
| 71 |
face = Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2GRAY))
|
| 72 |
+
else:
|
| 73 |
+
face = torch.from_numpy(np.array(face)).to(device) # Convert to a PyTorch tensor and move it to the correct device
|
| 74 |
+
|
| 75 |
output = face_det_net(face)
|
| 76 |
|
| 77 |
# YOUR CODE HERE, return expression using your model
|