mediapipe icon indicating copy to clipboard operation
mediapipe copied to clipboard

Why mediapipe v0.10.15 depends on numpy (<2) and v0.10.14 doesn't?

Open alanwilter opened this issue 1 year ago • 13 comments

My code is working fine with MP v0.10.14 and numpy v2.0.2. I can't update to numpy v2.1.1 yet because I use numba, whose v0.60.0, is not yet updated for latest numpy.

Anyway, when I was trying to update to latest MP, I got this warning.

Because mediapipe (0.10.15) depends on numpy (<2)

Was this pinning introduced on purpose to address some particular issue?

alanwilter avatar Sep 06 '24 07:09 alanwilter

Hello @alanwilter The Numpy version was downgraded to <2 in this commit. This was done for the stability of the package across all platform architectures. With newer features coming to MediaPipe, we internally encountered issues packet propagation in MP graph with numpy 2.0.2 and hence downgrade was required.

ayushgdev avatar Sep 16 '24 09:09 ayushgdev

Many thanks for that. Do you have an idea when numpy 2.1.x will be supported?

alanwilter avatar Sep 16 '24 10:09 alanwilter

@alanwilter This will depend on factors like the dependent packages used in MediaPipe(similar to numba package in your project), the stability(as we have already encountered), the performance and acceptable accuracy for each of the supported tasks.

Hence, we cannot comment on the timeline for the time being.

ayushgdev avatar Sep 17 '24 09:09 ayushgdev

This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

github-actions[bot] avatar Sep 25 '24 01:09 github-actions[bot]

How can we prevent this ticket to be automatically closed by the the GitHub Bot?

alanwilter avatar Sep 25 '24 07:09 alanwilter

Hi @alanwilter,

This can be marked as a feature request for supporting NumPy versions>2. We will share it with the team, and based on future demand and discussions, we may proceed with implementation if everything aligns on our end.

Thank you!!

kuaashish avatar Sep 25 '24 09:09 kuaashish

Hi, numba 0.61 was released recently. But I am still stuck with mediapipe 0.10.14. Is there a way I can help mediapipe to be compatible with numpy 2.x?

alanwilter avatar Jan 31 '25 19:01 alanwilter

I would like to bump up this issue, mediapipe is beginning to be the only package that is not supporting it in the ML industry. Is there any progress, please, @kuaashish?

danielkonecny avatar Feb 10 '25 15:02 danielkonecny

Is there any update on this? Now a couple months later, are there any issues with numpy 2 support in mediapipe?

cchadowitz avatar Apr 04 '25 23:04 cchadowitz

@kuaashish @schmidt-sebastian @ayushgdev hoping someone can provide some info on this. We're currently having to work around this with pip tricks and it'd be good to know if there are still issues with packet propagation in MP graph, or any other issues with numpy 2?

cchadowitz avatar Apr 21 '25 16:04 cchadowitz

i manually manage my package library so i have installed numpy<2 entirely manually and changed all of mediapipe's import statements accordingly. i didn't think too much about it but a lot of people are having issues, for me right now even more when im working with a few other people on a project. hope this dependency issue gets resolved soon

parametricCHAOS avatar Apr 27 '25 01:04 parametricCHAOS

Anyone working on this yet? Numpy 2.2.6 compatibility would be really helpful.

Vagenda avatar May 31 '25 14:05 Vagenda

A workaround would be to use uv which supports global overrides for dependencies:

dependencies = [
    "mediapipe"
]

[tool.uv]
override-dependencies = [
    "numpy>2"
]

However, this is not a feasible solution since a lot of the Python environment still relies on pip and wheels. That's why I created a simple script to download all MediaPipe wheels, remove the numpy<2 constraint, and rename the package to avoid conflicts in pip repositories.

You can find it here, with pre-built binaries already available in the releases: https://github.com/cansik/mediapipe-numpy2

I haven't pushed it to PyPI (yet), as I don't want to maintain an altered version of MediaPipe again...

@ayushgdev & @kuaashish Any updates on the progress, or at least a "we're working on it"? This is quite a blocker for libraries that depend on MediaPipe.

Update: The package is released on pypi mediapype-numpy2:

pip install mediapipe-numpy2

cansik avatar Jun 15 '25 20:06 cansik

Unfortunately the outdated numpy v1 dependency caused so many conflicts when trying to use mediapipe in existing code bases that I ended up having to refactor it out into an external executable in order to access it via out of process calls (e.g uv run script.py). Not a fan of the pkg bloat and perf hit but IMHO was the only workable solution after wasting so much time dealing with broken dependencies.

I'd love to replace this hacky workaround if anyone knows of an alternative audio classification python package for audio labeling?

mythz avatar Aug 30 '25 11:08 mythz

Quick update to my previous post:

The numpy2 compatible package is released now on pypi mediapype-numpy2:

pip install mediapipe-numpy2

cansik avatar Aug 31 '25 08:08 cansik

@cansik You're a hero.

Axagthoth avatar Sep 10 '25 09:09 Axagthoth

Could we make numpy<2 optional? It seems that many people are having success with numpy>=2. If someone has an issue with numpy>=2, they could add numpy<2 to their dependencies.

btakita avatar Sep 17 '25 16:09 btakita

Thank you Cansik, for making the numpy2 modification :)

If I want to test the examples for raspberry pi https://github.com/google-ai-edge/mediapipe-samples/tree/main/examples/face_landmarker/raspberry_pi

Is it mandatory to build the wheels with: https://ai.google.dev/edge/mediapipe/solutions/build_python

robertojguerra avatar Nov 02 '25 22:11 robertojguerra