Difference between revisions of "MediaPipe for TouchDesigner"
(Created page with "# MediaPipe for TouchDesigner ### On Apple Silicon (M1) using Rosetta2 We will install an emulated x86_64 brew using Rosetta2 alongside native Apple Silicon brew. This way w...") |
|||
Line 1: | Line 1: | ||
− | + | == MediaPipe for TouchDesigner == | |
− | + | === On Apple Silicon (M1) using Rosetta2 === | |
We will install an emulated x86_64 brew using Rosetta2 alongside native Apple Silicon brew. This way we can install the by TouchDesigner expected python3.7 while also installing the MediaPipe module. | We will install an emulated x86_64 brew using Rosetta2 alongside native Apple Silicon brew. This way we can install the by TouchDesigner expected python3.7 while also installing the MediaPipe module. | ||
Line 8: | Line 8: | ||
− | + | === Install brew x86_64 using Rosetta2 === | |
− | + | <syntaxhighlight lang=c style="border:1px dashed black; max-width: 950px;"> | |
$ arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" | $ arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" | ||
− | + | </syntaxhighlight> | |
− | + | === 2. Make alias for x86_64 brew === | |
Add this to rc file (.bashrc, .zshrc etc) | Add this to rc file (.bashrc, .zshrc etc) | ||
− | + | <syntaxhighlight lang=c style="border:1px dashed black; max-width: 950px;"> | |
alias ibrew="arch -x86_64 /usr/local/bin/brew" | alias ibrew="arch -x86_64 /usr/local/bin/brew" | ||
− | + | </syntaxhighlight> | |
− | + | === 3. Install python3.7 === | |
− | + | <syntaxhighlight lang=c style="border:1px dashed black; max-width: 950px;"> | |
$ ibrew install python@3.7 | $ ibrew install python@3.7 | ||
− | + | </syntaxhighlight> | |
− | + | ||
− | + | === 4. Alias for python@3.7 and pip3 === | |
Add to rc file | Add to rc file | ||
− | + | <syntaxhighlight lang=c style="border:1px dashed black; max-width: 950px;"> | |
alias iPY37=/usr/local/opt/python@3.7/bin/python3 | alias iPY37=/usr/local/opt/python@3.7/bin/python3 | ||
alias iPIP37=/usr/local/opt/python@3.7/bin/pip3 | alias iPIP37=/usr/local/opt/python@3.7/bin/pip3 | ||
− | + | </syntaxhighlight> | |
Now you can use `iPY37` to run x86_64 python@3.7 and `iPIP37` to install packages. | Now you can use `iPY37` to run x86_64 python@3.7 and `iPIP37` to install packages. | ||
− | + | === 5. Install Mediapipe for python@3.7 x86_64 === | |
− | + | <syntaxhighlight lang=c style="border:1px dashed black; max-width: 950px;"> | |
$ iPIP37 install mediapipe | $ iPIP37 install mediapipe | ||
− | + | </syntaxhighlight> | |
− | + | === 6. Find python@3.7 x86_64 module path === | |
Find the Python Module path of installed x86_64 python@3.7 | Find the Python Module path of installed x86_64 python@3.7 | ||
− | + | <syntaxhighlight lang=c style="border:1px dashed black; max-width: 950px;"> | |
$ ibrew --prefix | $ ibrew --prefix | ||
/usr/local | /usr/local | ||
− | + | </syntaxhighlight> | |
Append `/lib/python3.7/site-packages` to this path to get `/usr/local/lib/python3.7/site-packages`. This is the *Python 64-bit Module Path* you need to fill in TouchDesigner by going to `Preferences -> general -> Python 64-bit Module Path` | Append `/lib/python3.7/site-packages` to this path to get `/usr/local/lib/python3.7/site-packages`. This is the *Python 64-bit Module Path* you need to fill in TouchDesigner by going to `Preferences -> general -> Python 64-bit Module Path` | ||
− | + | === 7. Restart TouchDesigner === | |
Mediapipe should be installed! To verify the installation go to `Dialogs -> Textport and DATs`, import the MediaPipe module; `import mediapipe as mp` and list the components; `print(dir(mp.solutions))` | Mediapipe should be installed! To verify the installation go to `Dialogs -> Textport and DATs`, import the MediaPipe module; `import mediapipe as mp` and list the components; `print(dir(mp.solutions))` | ||
− | + | == Windows == | |
For windows we need to have a parallel copy of the same Python version on the harddrive. TouchDesigner expects us to work with Python3.7.x so grab this version from the [Python website](https://www.python.org/downloads/windows/). I used [Python 3.7.9](https://www.python.org/ftp/python/3.7.9/python-3.7.9-amd64.exe) for this tutorial. | For windows we need to have a parallel copy of the same Python version on the harddrive. TouchDesigner expects us to work with Python3.7.x so grab this version from the [Python website](https://www.python.org/downloads/windows/). I used [Python 3.7.9](https://www.python.org/ftp/python/3.7.9/python-3.7.9-amd64.exe) for this tutorial. | ||
− | + | === 1. Install excecutable === | |
Double-click the downloaded executable file and install Python to the `DataStorage` drive `E:/` in a folder named `Python` | Double-click the downloaded executable file and install Python to the `DataStorage` drive `E:/` in a folder named `Python` | ||
− | + | === 2. Installing MediaPipe === | |
To install MediaPipe for our newly installed Python, open Windows PowerShell and run the following commands | To install MediaPipe for our newly installed Python, open Windows PowerShell and run the following commands | ||
− | + | <syntaxhighlight lang=c style="border:1px dashed black; max-width: 950px;"> | |
$ python | $ python | ||
Line 81: | Line 81: | ||
$ exit() | $ exit() | ||
− | + | </syntaxhighlight> | |
*Note: Check if the Python version corresponds with the Python you've installed in step 1.* | *Note: Check if the Python version corresponds with the Python you've installed in step 1.* | ||
Line 87: | Line 87: | ||
Install mediapipe using pip package manager: | Install mediapipe using pip package manager: | ||
− | + | <syntaxhighlight lang=c style="border:1px dashed black; max-width: 950px;"> | |
$ pip install mediapipe | $ pip install mediapipe | ||
− | + | </syntaxhighlight> | |
− | + | === 3. Open TouchDesigner starter === | |
Download the [MediaPipe starter project](http://interactionstation.wdka.hro.nl/mediawiki/images/a/a5/Mp-starter-toe.zip), unzip it and double-click to open the project in TouchDesigner. If you installed Python3.7 in a different folder than `E:\Python\Lib\site-packages` you need to change the `pythonpath` variable within the `DAT Excecute` OP to the correct folder. | Download the [MediaPipe starter project](http://interactionstation.wdka.hro.nl/mediawiki/images/a/a5/Mp-starter-toe.zip), unzip it and double-click to open the project in TouchDesigner. If you installed Python3.7 in a different folder than `E:\Python\Lib\site-packages` you need to change the `pythonpath` variable within the `DAT Excecute` OP to the correct folder. | ||
To check if you can use MediaPipe in TouchDesigner, navigate to `Dialogs -> Textport and DATs`, import the MediaPipe module; `import mediapipe as mp` and list the components; `print(dir(mp.solutions))`. | To check if you can use MediaPipe in TouchDesigner, navigate to `Dialogs -> Textport and DATs`, import the MediaPipe module; `import mediapipe as mp` and list the components; `print(dir(mp.solutions))`. |
Revision as of 16:09, 10 May 2022
MediaPipe for TouchDesigner
On Apple Silicon (M1) using Rosetta2
We will install an emulated x86_64 brew using Rosetta2 alongside native Apple Silicon brew. This way we can install the by TouchDesigner expected python3.7 while also installing the MediaPipe module.
There is a MediaPipe module build for Apple Silicon (M1) machines found at [this Github issue](https://github.com/google/mediapipe/issues/3277), but I couldn't find a native Python 3.7 build for Apple Silicon to run in TouchDesigner.
Install brew x86_64 using Rosetta2
$ arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
2. Make alias for x86_64 brew
Add this to rc file (.bashrc, .zshrc etc)
alias ibrew="arch -x86_64 /usr/local/bin/brew"
3. Install python3.7
$ ibrew install python@3.7
4. Alias for python@3.7 and pip3
Add to rc file
alias iPY37=/usr/local/opt/python@3.7/bin/python3
alias iPIP37=/usr/local/opt/python@3.7/bin/pip3
Now you can use `iPY37` to run x86_64 python@3.7 and `iPIP37` to install packages.
5. Install Mediapipe for python@3.7 x86_64
$ iPIP37 install mediapipe
6. Find python@3.7 x86_64 module path
Find the Python Module path of installed x86_64 python@3.7
$ ibrew --prefix
/usr/local
Append `/lib/python3.7/site-packages` to this path to get `/usr/local/lib/python3.7/site-packages`. This is the *Python 64-bit Module Path* you need to fill in TouchDesigner by going to `Preferences -> general -> Python 64-bit Module Path`
7. Restart TouchDesigner
Mediapipe should be installed! To verify the installation go to `Dialogs -> Textport and DATs`, import the MediaPipe module; `import mediapipe as mp` and list the components; `print(dir(mp.solutions))`
Windows
For windows we need to have a parallel copy of the same Python version on the harddrive. TouchDesigner expects us to work with Python3.7.x so grab this version from the [Python website](https://www.python.org/downloads/windows/). I used [Python 3.7.9](https://www.python.org/ftp/python/3.7.9/python-3.7.9-amd64.exe) for this tutorial.
1. Install excecutable
Double-click the downloaded executable file and install Python to the `DataStorage` drive `E:/` in a folder named `Python`
2. Installing MediaPipe
To install MediaPipe for our newly installed Python, open Windows PowerShell and run the following commands
$ python
...
Python 3.7.9
...
$ exit()
- Note: Check if the Python version corresponds with the Python you've installed in step 1.*
Install mediapipe using pip package manager:
$ pip install mediapipe
3. Open TouchDesigner starter
Download the [MediaPipe starter project](http://interactionstation.wdka.hro.nl/mediawiki/images/a/a5/Mp-starter-toe.zip), unzip it and double-click to open the project in TouchDesigner. If you installed Python3.7 in a different folder than `E:\Python\Lib\site-packages` you need to change the `pythonpath` variable within the `DAT Excecute` OP to the correct folder.
To check if you can use MediaPipe in TouchDesigner, navigate to `Dialogs -> Textport and DATs`, import the MediaPipe module; `import mediapipe as mp` and list the components; `print(dir(mp.solutions))`.