mediapipe icon indicating copy to clipboard operation
mediapipe copied to clipboard

Facemesh.process() returns None after second image is sent to process.

Open Kutayykilic opened this issue 3 years ago • 11 comments

Please make sure that this is a solution issue. Hi there everyone I hope everyone is doing well. I was trying some solutions with mediapipe and noticed I found an interesting error. I think my implementation should be still viable but it is indeed a weird bug I would like to adress. First of all, let me specify my system. OS: Windows 10 Coding Language: Python Mediapipe version: 0.8.10 Solution: Mediapipe Facemesh

The standalone code to get the result.

import cv2
import mediapipe as mp
mp_face_mesh = mp.solutions.face_mesh
face_mesh = mp_face_mesh.FaceMesh(min_detection_confidence=0.5)

image1=(cv2.imread("image_path_1"))
image2=(cv2.imread(r"image_path_2"))
results = face_mesh.process(image1)
results_2=face_mesh.process(image2)
print(results.multi_face_landmarks,results_2.multi_face_landmarks)

Here what I tried was to read 2 images and then multiprocess them one after another. However, the results_2.multi_face_landmarks just returns none. In my code I was able to solve this issue by running face_mesh.process again if the result is null. But I don't think this is viable at all. I don't know what might be causing this issue. I tried to put a time.sleep() before results_2 process but the second landmark always returns None. What might be the problem here?

Kutayykilic avatar Jun 05 '22 10:06 Kutayykilic

I also want to note the image paths are definitely correct so there is no fault in there cause I can read images independently from the given path

Kutayykilic avatar Jun 05 '22 11:06 Kutayykilic

Hi @Kutayykilic , Could you share any reference video w.r.t above issue.

sureshdagooglecom avatar Jun 07 '22 04:06 sureshdagooglecom

Hi there,

This is not used on a video, instead it is used on the two single frame images should it not work that way?

Kutayykilic avatar Jun 12 '22 09:06 Kutayykilic

Hi @Kutayykilic , Two single frame images can not work for facemesh , please use single image.

sureshdagooglecom avatar Jun 13 '22 07:06 sureshdagooglecom

Okay let me improve on that with a little bit of work I have tried.

Initializing the face mesh module again after each image is processed seems to solve the issue if anyone is interested on making it work this way.

Otherwise I don't really get why it's not implemented to work with 2 single frame images, what's the reason behind this?

Kutayykilic avatar Jun 14 '22 05:06 Kutayykilic

Hi @Kutayykilic , We consider it as a great feature and share with internal team.

sureshdagooglecom avatar Jun 21 '22 08:06 sureshdagooglecom

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.

google-ml-butler[bot] avatar Jun 28 '22 09:06 google-ml-butler[bot]

Closing as stale. Please reopen if you'd like to work on this further.

google-ml-butler[bot] avatar Jul 05 '22 16:07 google-ml-butler[bot]

Are you satisfied with the resolution of your issue? Yes No

google-ml-butler[bot] avatar Jul 05 '22 16:07 google-ml-butler[bot]

Closing as stale. Please reopen if you'd like to work on this further.

google-ml-butler[bot] avatar Jul 19 '22 08:07 google-ml-butler[bot]

Are you satisfied with the resolution of your issue? Yes No

google-ml-butler[bot] avatar Jul 19 '22 08:07 google-ml-butler[bot]

@Kutayykilic The issue could not be reproduced at our end. Here is what I have done as reproduction steps.

  1. Copied the given gist to a jupyter notebook.
  2. Clicked two images from webcam of with variable camera distance and angles.
  3. Added their paths in the gist and ran the code.

The landmarks were correctly printed. So I suppose the problem could be with the images. Can you provide sample images so that we can investigate further?

ayushgdev avatar Dec 12 '22 08:12 ayushgdev

Hi,

Thanks for responding. I could not resolve the same issue with the latest version of mediapipe sadly. I have deleted the previous images I have been working and added two new pictures. I have also tried adding those pictures in a loop of a 10000 and run them many more times. But as you have said I can't replicate the issue here.

Kutayykilic avatar Dec 12 '22 10:12 Kutayykilic

@Kutayykilic Sorry for the late reply from our end in the first place. I suspect the problem must have been in the image size, since the FaceMesh model requires an image size of 192x192 pixels focusing the face. You can refer the model card here for more details on input, output, limitations and environmental conditions. However, since the issue is not replicable at your end as well, can you please close the issue? You are welcome to open another issue if you face any problem in future.

ayushgdev avatar Dec 12 '22 11:12 ayushgdev

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.

google-ml-butler[bot] avatar Dec 19 '22 11:12 google-ml-butler[bot]

Will do. Thank you for your help!

Kutayykilic avatar Dec 19 '22 12:12 Kutayykilic

Are you satisfied with the resolution of your issue? Yes No

google-ml-butler[bot] avatar Dec 19 '22 12:12 google-ml-butler[bot]