LovnishVerma commited on
Commit
cd66699
·
verified ·
1 Parent(s): 5aaa444

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -64,9 +64,10 @@ def process_frame(frame):
64
  for (x, y, w, h) in faces:
65
  roi_gray = gray_frame[y:y+h, x:x+w]
66
  roi_color = frame[y:y+h, x:x+w]
67
- face_roi = cv2.resize(roi_color, (img_shape, img_shape))
68
- face_roi = np.expand_dims(face_roi, axis=0)
69
- face_roi = face_roi / float(img_shape)
 
70
 
71
  # Emotion detection
72
  predictions = model.predict(face_roi)
 
64
  for (x, y, w, h) in faces:
65
  roi_gray = gray_frame[y:y+h, x:x+w]
66
  roi_color = frame[y:y+h, x:x+w]
67
+ face_roi = cv2.resize(roi_color, (img_shape, img_shape)) # Resize to 48x48
68
+ face_roi = cv2.cvtColor(face_roi, cv2.COLOR_BGR2RGB) # Convert to RGB (3 channels)
69
+ face_roi = np.expand_dims(face_roi, axis=0) # Add batch dimension
70
+ face_roi = face_roi / 255.0 # Normalize the image
71
 
72
  # Emotion detection
73
  predictions = model.predict(face_roi)