By using cv2.resize the ratio of width to height isn't maintained stretching and distorting the image and the face in it in a way that the bot wasn't trained for and that isn't seen in the bot's training data.
The created PR adds the resize_with_pad function to more accurately resize the image by resizing the maximum dimension assuming the goal size is a box and maximum dimension comparatively when it isn't (dimension divided by each dimension's corresponding goal dimension) to the needed size and then padding the rest in the same way the training data does it and uses that for preprocess_image instead.
By using
cv2.resize
the ratio of width to height isn't maintained stretching and distorting the image and the face in it in a way that the bot wasn't trained for and that isn't seen in the bot's training data.The created PR adds the
resize_with_pad
function to more accurately resize the image by resizing the maximum dimension assuming the goal size is a box and maximum dimension comparatively when it isn't (dimension divided by each dimension's corresponding goal dimension) to the needed size and then padding the rest in the same way the training data does it and uses that forpreprocess_image
instead.