├── README.md ├── manylinux_aarch64 ├── README.md └── mediapipe-0.8.1-cp38-cp38-manylinux2014_aarch64.whl ├── mediapipe-0.8.1-cp38-cp38-linux_aarch64.whl └── mediapipe-0.8.4-cp38-cp38-linux_aarch64.whl /README.md: -------------------------------------------------------------------------------- 1 | # MediaPipe Python on aarch64 Ubuntu 20.04 2 | 3 | *[Experimental] Only tested on Raspberry Pi 4 and Jeton Xavier NX.* 4 | 5 | ## Step to build MediaPipe Python on aarch64 Ubuntu 20.04 6 | 7 | 1. Clone [the MediaPipe repo](https://github.com/google/mediapipe) and follow 8 | the instruction to setup Bazel. 9 | 10 | 2. Install build dependencies. 11 | 12 | ```bash 13 | $ sudo apt install -y python3-dev 14 | $ sudo apt install -y cmake 15 | ``` 16 | 17 | 3. Install proto compiler. 18 | 19 | ``` 20 | $ sudo apt install -y protobuf-compiler 21 | ``` 22 | 23 | If you see a missing any.proto error later, which means the protoc might be 24 | too old, you can download the latest protoc-3.x.x-linux-aarch_64.zip from 25 | [GitHub](https://github.com/protocolbuffers/protobuf/releases) and copy the 26 | "bin" and "include/google" directories to the system libraries. Then, modify 27 | `mediapipe/setup.py` like the following: 28 | 29 | ```python 30 | diff --git a/setup.py b/setup.py 31 | index 61848de..462d91d 100644 32 | --- a/setup.py 33 | +++ b/setup.py 34 | @@ -208,7 +208,7 @@ class GeneratePyProtos(setuptools.Command): 35 | sys.stderr.write('cannot find required file: %s\n' % source) 36 | sys.exit(-1) 37 | 38 | - protoc_command = [self._protoc, '-I.', '--python_out=.', source] 39 | + protoc_command = [self._protoc, '-I.', '-I/usr/local/include', '--python_out=.', source] 40 | if subprocess.call(protoc_command) != 0: 41 | sys.exit(-1) 42 | 43 | ``` 44 | 45 | 4. Go to the MediaPipe directory. 46 | 47 | ```bash 48 | ~$ cd mediapipe 49 | ``` 50 | 51 | 5. Remove unnecessary OpenCV modules and linker flags. 52 | 53 | ```bash 54 | sed -i -e "/\"imgcodecs\"/d;/\"calib3d\"/d;/\"features2d\"/d;/\"highgui\"/d;/\"video\"/d;/\"videoio\"/d" third_party/BUILD 55 | sed -i -e "/-ljpeg/d;/-lpng/d;/-ltiff/d;/-lImath/d;/-lIlmImf/d;/-lHalf/d;/-lIex/d;/-lIlmThread/d;/-lrt/d;/-ldc1394/d;/-lavcodec/d;/-lavformat/d;/-lavutil/d;/-lswscale/d;/-lavresample/d" third_party/BUILD 56 | ``` 57 | 58 | 6. Disable carotene_o4t in `third_party/BUILD`. 59 | 60 | ``` 61 | diff --git a/third_party/BUILD b/third_party/BUILD 62 | index ef408e4..51e1104 100644 63 | --- a/third_party/BUILD 64 | +++ b/third_party/BUILD 65 | @@ -110,6 +104,8 @@ cmake_external( 66 | "WITH_ITT": "OFF", 67 | "WITH_JASPER": "OFF", 68 | "WITH_WEBP": "OFF", 69 | + "ENABLE_NEON": "OFF", 70 | + "WITH_TENGINE": "OFF", 71 | ``` 72 | 73 | 7. Build the package. 74 | 75 | ```bash 76 | ~/mediapipe$ python3 setup.py gen_protos && python3 setup.py bdist_wheel 77 | ``` 78 | 79 | ## Steps to run MediaPipe Python on aarch64 Ubuntu 20.04 80 | 81 | 1. Install MediaPipe package. 82 | 83 | ```bash 84 | ~$ python3 -m pip install cython 85 | ~$ python3 -m pip install numpy 86 | ~$ python3 -m pip install pillow 87 | ~$ python3 -m pip install mediapipe/dist/mediapipe-0.8-cp38-cp38-linux_aarch64.whl 88 | or 89 | ~$ python3 -m pip install mediapipe-python-aarch64/mediapipe-0.8.4-cp38-cp38-linux_aarch64.whl 90 | ``` 91 | 92 | Append `--no-deps` flag if any dependency Python packages cannot be installed. 93 | 94 | 2. Run the example code. 95 | 96 | ```python 97 | import mediapipe as mp 98 | import numpy as np 99 | import PIL.Image as Image 100 | mp_holistic = mp.solutions.holistic 101 | 102 | holistic = mp_holistic.Holistic(static_image_mode=True) 103 | for idx, file in enumerate(['/path/to/pic.jpg', '/path/to/pic2.jpg']): 104 | pic = Image.open(file) 105 | image_data = np.frombuffer(pic.tobytes(), dtype=np.uint8) 106 | image = np.copy(image_data.reshape((image_height, image_width, 3))[:,:,::-1]) 107 | image_height, image_width, _ = image.shape 108 | results = holistic.process(image) 109 | if results.pose_landmarks: 110 | print( 111 | f'Nose coordinates: (' 112 | f'{results.pose_landmarks.landmark[mp_holistic.PoseLandmark.NOSE]\ 113 | .x * image_width}, ' 114 | f'{results.pose_landmarks.landmark[mp_holistic.PoseLandmark.NOSE]\ 115 | .y * image_height})' 116 | ) 117 | holistic.close() 118 | ``` 119 | -------------------------------------------------------------------------------- /manylinux_aarch64/README.md: -------------------------------------------------------------------------------- 1 | *[Experimental]* 2 | 3 | "mediapipe-0.8.1-cp38-cp38-manylinux2014_aarch64.whl" works on Ubuntu for Raspberry Pi. 4 | However, Jetson Xavier NX can't install this unsupported wheel. Still investigating... 5 | -------------------------------------------------------------------------------- /manylinux_aarch64/mediapipe-0.8.1-cp38-cp38-manylinux2014_aarch64.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiuqiant/mediapipe_python_aarch64/4d3ed79dded0d038c4ce87425fd11939abaac241/manylinux_aarch64/mediapipe-0.8.1-cp38-cp38-manylinux2014_aarch64.whl -------------------------------------------------------------------------------- /mediapipe-0.8.1-cp38-cp38-linux_aarch64.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiuqiant/mediapipe_python_aarch64/4d3ed79dded0d038c4ce87425fd11939abaac241/mediapipe-0.8.1-cp38-cp38-linux_aarch64.whl -------------------------------------------------------------------------------- /mediapipe-0.8.4-cp38-cp38-linux_aarch64.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiuqiant/mediapipe_python_aarch64/4d3ed79dded0d038c4ce87425fd11939abaac241/mediapipe-0.8.4-cp38-cp38-linux_aarch64.whl --------------------------------------------------------------------------------