Deepface not being accurate in TD

Hello!

I am currently working on a project to integrate Deepface for facial expression recognition. I got it running perfectly with Pycharm, and it works really well. The problem is that when I try implementing it with TD it is dramatically less accurate.

I suspect this has to do with the preprocessing I am doing in TD, maybe I am doing something wrong. What I am essentially doing is taking the webcam operator and turning it to a numpy array so Deepface can work with it, so it should be pretty simple. I also tried Mediapipe hand gesture recognition and I had similar results (inside of TD it gets less accurate) so I really think I am doing the pre-processing wrong.

Here is a simple project file where if you press the button it will process a frame with deepface:
Deepface Forum.2.toe (7.3 KB)

Deepface Github:

NOTE: deepface is super easy to install, just pip install Deepface and it has pretty much everything it needs as dependencies. I just had to add Scipy I think. Of course, you probably want to install it in a conda environment or something to not mess with the modules TD uses. here is a startup execute on the project to set up your environment.

Thank you so much for your help in advance!

2 Likes

I’m trying to do the same thing but getting an issue with OpenCV inside TD not finding the haarcascade file, which is not included in the embedded Python. I got it running by just manually copying the files inside the TD app, but this is not an ideal solutoin.

How did you get around this issue? Is there some way to force TD to use opencv from another location?

I’m also getting only 3fps, but a workaround that I’m doing is to run it inside the Engine COMP so that the rest of the project can run at 60fps.

Figured out the answer to my own question:
In TouchDesigner Settings → deselect “Search External Python Past Last” and it will use the external version of opencv.

Ehi, I just started to implement deepface in touchdesigner. Have you solved the inaccuracy problem?

Did you find a fix at all to improve the accuracy?