Mediapipe process in Engine COMP doesn't work

Hello all,

I have a working script CHOP using medipipe python library to extract face bounding box parameters. Mediapipe library is installed automatically using td_pip. I want to have this computation in a separate process, but when I place the tox that has the script CHOP inside in an Engine COMP it says there are errors in the component. I wonder if its something related to the library import inside the Engine COMP with the actual location of the library… Here I share the zip file with the whole thing!

Thanks in advance,

Joan (32.8 KB)

Hi - just looking at your file, a couple of points:

  1. you will need to use td_pip in TouchEngine rather than in the host, so move that into the .tox you load
  2. you’ll need to move your Execute DAT too, to actually load mediapipe, but the onStart() callback won’t be called in TouchEngine - use the onCreate() callback instead (see Component Lifetime in the Engine COMP documentation)

We’d like to make using Python in the Engine COMP as simple as possible, we’ll look at improving support for this situation in a future release - we may be able to inherit imports from the host.

1 Like

As @bangnoise already said, you need to have TD-Pip in the tox.
Also (I hate that phrase), you are using it wrong. Instead of running Import_Module on startup, it is a dropin-replacement for import. If you want to use the startup-routine, use InstallPackage(“mediapipe”) instead. But the way you want to use it is like this:

import numpy as np
import cv2
#import mediapipe as mp
mp = op('td_pip').Import_Module("mediapipe") #only need to pass pip_name if they are different.
import math

This will download and import the module on demand, so no need for the tedious install procedure.

Attached is a working version.
mediapipe_tox.tox (6.7 KB)


Amazing, I tried this first and worked well I missed that info from the docs! Thanks again!!

1 Like

Thanks for the correction, indeed this is a much cleaner way! It worked straight away, thanks for sharing the tox!