NativeSensors / EyeGestures

gaze tracking software
GNU General Public License v3.0
161 stars 14 forks source link

Face object has no landmarks attribute #24

Closed valenotary closed 2 months ago

valenotary commented 3 months ago

Trying the "V2 Machine Learning Approach" on the main README of the repository on an M3 Max. Even after sorting out the runtime dependencies manually (e.g. opencv and mediapipe needed to be installed manually for some reason instead of being included as a part of the pip install), I get the following error logs.

WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1721759351.041874  601204 gl_context.cc:357] GL version: 2.1 (2.1 Metal - 89.3), renderer: Apple M3 Max
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
W0000 00:00:1721759351.042729  601299 inference_feedback_manager.cc:114] Feedback manager requires a model with a single signature inference. Disabling support for feedback tensors.
W0000 00:00:1721759351.046010  601297 inference_feedback_manager.cc:114] Feedback manager requires a model with a single signature inference. Disabling support for feedback tensors.
Traceback (most recent call last):
  File "/Users/valenotary/PycharmProjects/math-olympiad-solver/src/eye-tracking.py", line 14, in <module>
    event, cevent = gestures.step(frame,
                    ^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/pytorch-env/lib/python3.11/site-packages/eyeGestures/eyegestures.py", line 110, in step
    classic_point, key_points, blink, fixation, cevent = self.getLandmarks(frame,
                                                         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/pytorch-env/lib/python3.11/site-packages/eyeGestures/eyegestures.py", line 56, in getLandmarks
    event, cevent = self.gestures.step(
                    ^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/pytorch-env/lib/python3.11/site-packages/eyeGestures/eyegestures.py", line 216, in step
    event = self.gaze.estimate(image,
            ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/pytorch-env/lib/python3.11/site-packages/eyeGestures/gazeEstimator.py", line 133, in estimate
    print(self.face.landmarks)
          ^^^^^^^^^^^^^^^^^^^
AttributeError: 'Face' object has no attribute 'landmarks'. Did you mean: '_landmarks'?

I see that Face.landmarks does not even get defined until Face.process is called, but I can't find where Face.process is called first... Also maybe it's just some Mac limitation but I'm pretty sure I've given the right permission for my process to access the camera (running this through Pycharm).

Also, at the point that we get the AttributeError, the app is still running, although it just hangs until I use a KeyboardInterrupt to get out of it and back to my terminal.

PeterWaIIace commented 2 months ago

Thanks for reporting this.

1) That is odd that mediapipe is not installed. Will look into this. 2) I will check why Face.landmarks are not defined.

Could you share your code sample?

PeterWaIIace commented 2 months ago

It is extremely weird. @valenotary did you change anything in source code, I cannot find line causing issue, there seem to be no such print statements.

Which version of the library are you using?

PeterWaIIace commented 2 months ago

If you can test it with 2.5.4. Let me know if it works.

valenotary commented 2 months ago

@PeterWaIIace I was testing with 2.4.2 when I logged the issue, which was the latest release according to the GitHub repo.

Just retested the same project with eyeGestures==2.5.4 as you recommended... The code sample I'm using is just the one that is one the README of the repository.

So now I'm not having the same issue as originally stated with this newer version, but there is another AttributeError (not sure if it's an issue with the example or the library):

WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1722989930.886810 5113341 gl_context.cc:357] GL version: 2.1 (2.1 Metal - 89.3), renderer: Apple M3 Max
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
W0000 00:00:1722989930.888410 5113400 inference_feedback_manager.cc:114] Feedback manager requires a model with a single signature inference. Disabling support for feedback tensors.
W0000 00:00:1722989930.892134 5113397 inference_feedback_manager.cc:114] Feedback manager requires a model with a single signature inference. Disabling support for feedback tensors.
Traceback (most recent call last):
  File "/Users/valenotary/PycharmProjects/math-olympiad-solver/src/eye-tracking.py", line 20, in <module>
    cursor_x, cursor_y = event.point[0], event.point[1]
                         ^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'point'
Exception ignored in: <module 'threading' from '/opt/anaconda3/envs/pytorch-env/lib/python3.11/threading.py'>
Traceback (most recent call last):
  File "/opt/anaconda3/envs/pytorch-env/lib/python3.11/threading.py", line 1583, in _shutdown
    lock.acquire()

The first set of warnings are the same as before but the latest Traceback log points to the Event returned by gestures.step being None...

PeterWaIIace commented 2 months ago

@valenotary

Oh yes, warnings are produced by dependencies. However, it seems that previous errors have gone away with recent fixes, so that is good. Output works fine: no detection of face, so it produces None.

I will think about changing to variant value/error type in the future, but for now, the correct approach is to check against if event and cevent are None.

PeterWaIIace commented 2 months ago

Also updated readme code with same check.

I would recommend you to first try using examples as well as they should be much more functional. Readme is more of sample/overview, but it does not cover every edge case. If examples do not work for you then it will be weird.

PeterWaIIace commented 2 months ago

@valenotary

If there is no more issues I will close this thread in about week. You can reach me via discord too: https://discord.gg/BFE5rTNY