You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I have a small issue with the code.
First of all, thanks so much for providing us with this code!
In the demo.py the code looks as follows:
#Get BGR in order for the detector to work.
input_img = cv2.cvtColor(img.astype('uint8'), cv2.COLOR_GRAY2BGR)
detected = detector(input_img, 1)
img_h, img_w, _ = np.shape(input_img)
faces = np.empty((len(detected), img_size, img_size, 3))
for i, d in enumerate(detected):
x1, y1, x2, y2, w, h = d.left(), d.top(), d.right() + 1, d.bottom() + 1, d.width(), d.height()
xw1 = max(int(x1 - 0.4 * w), 0)
yw1 = max(int(y1 - 0.4 * h), 0)
xw2 = min(int(x2 + 0.4 * w), img_w - 1)
yw2 = min(int(y2 + 0.4 * h), img_h - 1)
cv2.rectangle(input_img, (x1, y1), (x2, y2), (255, 0, 0), 2)
faces[i, :, :, :] = cv2.resize(input_img[yw1:yw2 + 1, xw1:xw2 + 1, :], (img_size, img_size))
# predict ages and genders of the detected faces
results = model.predict(faces)
However, is there any way to use the model.predict(faces) on the input image?
This is because in an earlier stage, I already detected and extracted the faces of the subject that I am working with. This is the input image that I am trying to feed in. This means it is a time loss to do this again, and sometimes the faces can't be detected due to it already being cropped.
When I use the model.predict on the original image, I of course get an error; being:
Error when checking : expected input_11 to have 4 dimensions, but got array with shape (224, 224, 3)
Which is expected. However, is there a simple way to get past this?
Hello, I have a small issue with the code.
First of all, thanks so much for providing us with this code!
In the demo.py the code looks as follows:
However, is there any way to use the
model.predict(faces)
on the input image?This is because in an earlier stage, I already detected and extracted the faces of the subject that I am working with. This is the input image that I am trying to feed in. This means it is a time loss to do this again, and sometimes the faces can't be detected due to it already being cropped.
When I use the model.predict on the original image, I of course get an error; being:
Error when checking : expected input_11 to have 4 dimensions, but got array with shape (224, 224, 3)
Which is expected. However, is there a simple way to get past this?
The algorithm I am workng with has as output:
Thanks so much
The text was updated successfully, but these errors were encountered: