Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mediapipe package #479

Open
Anirudh1681 opened this issue Apr 12, 2021 · 32 comments
Open

Mediapipe package #479

Anirudh1681 opened this issue Apr 12, 2021 · 32 comments
Labels

Comments

@Anirudh1681
Copy link

Will the Mediapipe python package be added in the repository of Chaquopy?
If yes, Thanks in advance
If no, Is there anybody working on using python script in android studio?

@mhsmith
Copy link
Member

mhsmith commented Apr 12, 2021

Thanks for the report. This package isn't currently a priority, but you can subscribe to this issue for any future updates. And if anyone else wants it too, please click the thumbs-up button above.

@abhay6694
Copy link

I am also using mediapipe library in one of my project. I wanted to run android app with python code and mediapipe is the only library which didn't get download. When can we expect support for this or what is the alternative for this?

@mhsmith
Copy link
Member

mhsmith commented May 10, 2021

Chaquopy supports several other image processing and machine learning libraries including OpenCV, TensorFlow and PyTorch.

Alternatively, you could use the Chaquopy Python API to access the MediaPipe Java API from Python. Unfortunately it looks like they don't release a pre-built AAR, and the process for building one yourself is quite complex.

@abhay6694
Copy link

So what is the procedure to support mediapipe in chaquopy library. Is it something we can do in few days because my entire project is dependant on it and changing it will be very difficult as we want to launch the product asap.
Please guide me through this.

@mhsmith
Copy link
Member

mhsmith commented May 10, 2021

Do you mean your project depends on the MediaPipe Python API? If the options I mentioned above aren't acceptable for you, then you could try using our package build tool, which was used to build everything in our native package repository. For more details, see #175 (comment).

However, I've had a quick look at the MediaPipe Python build process, and it looks fairly complex, so getting it working with our build tool may not be easy. I can provide an example of how to use the tool with a Bazel-based project, but I have no specific knowledge of MediaPipe itself, so if you choose to go this way I could only provide general support.

Also, I should warn you that even if you do manage to make a Python build of MediaPipe, it probably wouldn't be able to work directly with the Android camera system in the same way as the Java builds apparently do, and an indirect workaround would probably give much worse performance.

@UtsaChattopadhyay
Copy link

Is there any updates on this?
Can I install mediapipe and run in android studio?
Thanks

@mhsmith
Copy link
Member

mhsmith commented Aug 16, 2022

It still isn't available, but if you'd like to try building it yourself, the package build tool is now open-source. Follow the instructions here, and if you're successful, please make a pull request so we can add the package to the public repository.

@badchewie
Copy link

I still can't install mediapipe via .whl method. in my app level gradle under default config I have ;

python {
pip {
install "/home/master/mediapipe-0.9.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

}
}

but when I run the project I get this error.

could not find a version that satisfies the requirement mediapipe=0.9.0.1

@mhsmith
Copy link
Member

mhsmith commented Jan 10, 2023

Linux wheels cannot be installed on Android. If you want to use this package, you'll have to try one of the suggestions mentioned above.

@badchewie
Copy link

badchewie commented Jan 10, 2023 via email

@mhsmith
Copy link
Member

mhsmith commented Jan 10, 2023

Sorry, I don't know anything more about this package except what's written above. But if you want to try one of those approaches, I'll be happy to help you with any issues that come up.

@badchewie
Copy link

Hello there ,
I'd like to try and build mediapipe package by myself via using your build package tool , but I did not understand the following intsructions in https://github.com/chaquo/build-wheel . Can you guide me through it ?

@mhsmith
Copy link
Member

mhsmith commented Jan 11, 2023

What part didn't you understand?

@mhsmith
Copy link
Member

mhsmith commented Feb 22, 2023

Please don't post "+1" comments with no useful content. They won't make us work on the issue any sooner, and they'll spam everyone who's subscribed to it. Click the thumbs up button at the top of the page instead.

@chaquo chaquo deleted a comment from quantiantechnologies Feb 22, 2023
@chaquo chaquo deleted a comment from MayurQuantian Feb 22, 2023
@chaquo chaquo deleted a comment from KUSHAL-JAIN-au9 Feb 22, 2023
@chaquo chaquo deleted a comment from AshweeniKulkarni21 Feb 22, 2023
@chaquo chaquo deleted a comment from ChetanAlmelkar Feb 22, 2023
@rolandeke
Copy link

I am also trying to install mediapipe on my android project using chaquo library but I get the same error message that there's no version found for mediapipe, is there a way that the team can see how best they can include this so it would be easier for developers using your library to install mediapipe?

@rolandeke
Copy link

I am trying to build mediapipe following the instruction that was given in the README file in the repository https://github.com/chaquo/build-wheel. I am faced with the following error

Traceback (most recent call last):
  File "./build-wheel.py", line 810, in <module>
    BuildWheel().main()
  File "./build-wheel.py", line 97, in main
    self.unpack_and_build()
  File "./build-wheel.py", line 107, in unpack_and_build
    self.find_target()
  File "./build-wheel.py", line 198, in find_target
    versions = [ver for ver in os.listdir(target_dir) if ver.startswith(self.python)]
FileNotFoundError: [Errno 2] No such file or directory: '/home/username/IMOTECH/Projects/chaquopy/maven/com/chaquo/python/target'

I downloaded the maven target using the command that was stated and the .zip files are all available in the required folder target/download-target.sh maven/com/chaquo/python/target/3.8.16-0.

Can I please get help as to where I am going wrong? We really need Chaquopy to support media pipe. Thank you

@mhsmith
Copy link
Member

mhsmith commented Aug 7, 2023

The download command in the README assumes your working directory is the root of the repository. If you run it from a different directory, you'll have to modify the path to maven.

@rolandeke
Copy link

rolandeke commented Aug 7, 2023

I guess that was exactly what I did but now I am getting a different error when I run the build code

./build-wheel.py --python 3.8 --abi x86_64 ./packages/scipy

build-wheel.py: mkdir -p /home/user/IMOTECH/Projects/chaquopy/server/pypi/packages/scipy/build/1.4.1
build-wheel.py: cd /home/user/IMOTECH/Projects/chaquopy/server/pypi/packages/scipy/build/1.4.1
build-wheel.py: mkdir -p /home/user/IMOTECH/Projects/chaquopy/server/pypi/packages/scipy/build/1.4.1/cp38-cp38-android_21_x86_64
build-wheel.py: python3.8 /home/user/IMOTECH/Projects/chaquopy/server/pypi/create-build-env.py /home/user/IMOTECH/Projects/chaquopy/server/pypi/packages/scipy/build/1.4.1/cp38-cp38-android_21_x86_64/env
Traceback (most recent call last):
  File "/home/user/IMOTECH/Projects/chaquopy/server/pypi/create-build-env.py", line 26, in <module>
    pip_whl, = glob(f"{ensurepip.__path__[0]}/_bundled/pip-*.whl")  # Note comma
ValueError: not enough values to unpack (expected 1, got 0)
build-wheel.py: Error: Command returned exit status 1

Can you please provide a clear explanation as to how to go about this and if the README file needs to be updated then please see how best we can be provided with the updated version.

@mhsmith
Copy link
Member

mhsmith commented Aug 7, 2023

Please run python3.8 and post the output of the following commands:

>>> import ensurepip
>>> import os
>>> ensurepip.__path__
>>> list(os.walk(ensurepip.__path__[0]))

Please also let me know :

  • Your Linux distribution name and version
  • Where you got your copy of python3.8

@rolandeke
Copy link

image

python3.8

Python 3.8.10 (default, Mar 13 2023, 10:26:41)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ensurepip
>>> import os
>>> ensurepip.__path__
['/usr/lib/python3.8/ensurepip']
>>> list(os.walk(ensurepip.__path__[0]))
[('/usr/lib/python3.8/ensurepip', ['__pycache__'], ['__main__.py', '_uninstall.py', '__init__.py']), ('/usr/lib/python3.8/ensurepip/__pycache__', [], ['__init__.cpython-38.pyc', '_uninstall.cpython-38.pyc', '__main__.cpython-38.pyc'])]
>>>

cat /etc/os-release

NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

I download my python3.8 from using the apt package manager, and I am running my Linux Distribution on WSL on a Windows 11 Host.

@mhsmith
Copy link
Member

mhsmith commented Aug 8, 2023

OK, it appears that Debian-based distributions install the pip wheels in /usr/share/python-wheels rather than /usr/lib/python3.8/ensurepip/_bundled. build-wheel will have to be updated to handle this (#930).

Meanwhile, you can work around the problem by using a version of Python from miniconda, as described in the README.

@mhsmith
Copy link
Member

mhsmith commented Aug 8, 2023

But why are you trying to build SciPy? As mentioned at #648, that isn't currently possible, because we don't have a working Fortran compiler. But if all you need is a copy of SciPy to build another package against, that can be "downloaded manually from the public repository" as mentioned in the README.

@rolandeke
Copy link

But why are you trying to build SciPy? As mentioned at #648, that isn't currently possible, because we don't have a working Fortran compiler. But if all you need is a copy of SciPy to build another package against, that can be "downloaded manually from the public repository" as mentioned in the README.

I am not actually trying to build SciPy I was just using it to test out the build-wheel. I intend on building Mediapipe , as it is needed by the project that we are currently working on.

Also, if you can help me understand a little better when I used chaquopy in my build.gradle app level and pass the options "--extra-index-url", "https://pypi.org/". I am expecting that it should download the package from the Python package repository but I also get an error.

Lastly, I downloaded the mediapipe-0.10.3-cp38-cp38-win_amd64.whl file using pip download and referenced it in my pip block in my build.gradle file as mentioned in the documentation I still get an error building my project.

@mhsmith
Copy link
Member

mhsmith commented Aug 9, 2023

I am not actually trying to build SciPy I was just using it to test out the build-wheel

OK, then I suggest you start with the "examples of existing recipes" in the README.

when I used chaquopy in my build.gradle app level and pass the options "--extra-index-url", "https://pypi.org/". I am expecting that it should download the package from the Python package repository

PyPI is enabled by default, so you don't have to add it as an extra URL. But the only wheels that will work on Android are those built for the platforms android or any. Linux, Mac and Windows wheels will not work.

@rolandeke
Copy link

PyPI is enabled by default, so you don't have to add it as an extra URL. But the only wheels that will work on Android are those built for the platforms android or any. Linux, Mac and Windows wheels will not work.

Okay now I understand, but is there a way I can use your build-wheel tool to build .whl file for Mediapipe so it can run on Android? I guess this is the main idea as to why I am trying to get the build-wheel file to work.

I also encountered an error while executing the ./build-wheel.py --python 3.8 --abi x86_64 ./packages/matplotlib file which states

ERROR: Could not find a version that satisfies the requirement chaquopy-freetype==2.9.1 (from versions: none)
ERROR: No matching distribution found for chaquopy-freetype==2.9.1

@mhsmith
Copy link
Member

mhsmith commented Aug 10, 2023

is there a way I can use your build-wheel tool to build .whl file for Mediapipe so it can run on Android?

Yes, that's what the tool is for. But some packages require a lot of patching to build for Android. As mentioned above, Mediapipe uses the Bazel build system, and I've only encountered that before when building TensorFlow, which was extremely difficult. MediaPipe is probably not so difficult, but I wouldn't expect it to be easy.

So instead of building it yourself, it's worth looking into whether you could install MediaPipe for Android using their official instructions, and then access its Java API from Python using Chaquopy.

I also encountered an error while executing the ./build-wheel.py --python 3.8 --abi x86_64 ./packages/matplotlib

Please create a new issue and post the full build log.

@mhsmith
Copy link
Member

mhsmith commented Aug 17, 2023

OK, it appears that Debian-based distributions install the pip wheels in /usr/share/python-wheels rather than /usr/lib/python3.8/ensurepip/_bundled. build-wheel will have to be updated to handle this (#930).

This has now been fixed.

@rolandeke
Copy link

Issue has still not been fixed. Tried building the mediapipe module but I still can't get it to work on the application chaquopy still throw a Module Not Found Error, and I even try to download it from pip since it is available on pip but still to no avail. It would be really helpful if the chaquopy team can help resolve this issue so we can be able to install Mediapipe

@mhsmith
Copy link
Member

mhsmith commented Oct 9, 2023

I never said the availability of Mediapipe had been fixed, only that specific issue with the build-wheel tool.

@maq796113
Copy link

it's December 2023, yet no update

@dipenpadhiyar
Copy link

dipenpadhiyar commented Mar 27, 2024

I have read all the comments in this thread [March 27 2024], It is difficult to manage all the pacages in Chaquopy, @mhsmith.
I want to use MediaPipe in my project, and I have also read your suggestions.

It still isn't available, but if you'd like to try building it yourself, the package build tool is now open-source. Follow the instructions here, and if you're successful, please make a pull request so we can add the package to the public repository.

Most ML/Python developers want direct integration of the ML pipeline in Android, and MediaPipe is one of them because the developer wants to apply MediaPipe to images and video 😅.

So, can you help me guide the process, I know everyone's time is valuable; if you guys have any solutions, please share.

@mhsmith
Copy link
Member

mhsmith commented Mar 27, 2024

Sorry, I don't have time to look into this any further at the moment. Everything I know is in the comments above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants