Skip to content

Commit

Permalink
patch: emotion dimension.
Browse files Browse the repository at this point in the history
  • Loading branch information
h-alice committed Jan 13, 2025
1 parent 72b6db1 commit a23893a
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions deepface/models/demography/Emotion.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,7 @@ def predict(self, img: Union[np.ndarray, List[np.ndarray]]) -> np.ndarray:
# Preprocessing input image or image list.
imgs = self._preprocess_batch_or_single_input(img)

if imgs.shape[0] == 1:
# Preprocess single image and add channel dimension for grayscale images
processed_imgs = np.expand_dims(np.array([self._preprocess_image(img) for img in imgs]), axis=0)
else:
# Preprocess batch of images and add channel dimension for grayscale images
processed_imgs = np.expand_dims(np.array([self._preprocess_image(img) for img in imgs]), axis=-1)
# Reshape input for model (expected shape=(n, 48, 48, 1)), where n is the batch size
processed_imgs = processed_imgs.reshape(processed_imgs.shape[0], 48, 48, 1)
processed_imgs = np.expand_dims(np.array([self._preprocess_image(img) for img in imgs]), axis=-1)

# Prediction
predictions = self._predict_internal(processed_imgs)
Expand Down

0 comments on commit a23893a

Please sign in to comment.