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

Make sam2 optional #393

Closed
wants to merge 3 commits into from
Closed

Make sam2 optional #393

wants to merge 3 commits into from

Conversation

giswqs
Copy link
Member

@giswqs giswqs commented Mar 20, 2025

Some recent Colab updates break the sam2 installation. As a result, sam2 can no longer be installed. This PR makes sam2 an optional dependency.

@aruncveli
Copy link

aruncveli commented Mar 22, 2025

Could this be related #394?

The fix for that seems to be limiting setuptools<75.9, according to JinsuaFeito-dev/segment-anything-2#1. Installing sam2 from local directory with that fix, then installing samgeo seems to work in Colab.

@giswqs
Copy link
Member Author

giswqs commented Mar 22, 2025

@aruncveli Colab has setuptools v75.1.0 preinstalled, which meets setuptools<75.9. I just tested it with setuptools 75.8.2, and sam2 does not install.

image

@aruncveli
Copy link

aruncveli commented Mar 22, 2025

Yes, sorry, I didn't test properly. Was randomly trying things to get the install to work.

I'd installed a patched version of sam2 from source, with the setuptools version constraint patched in that, before installing samgeo.

@aruncveli
Copy link

aruncveli commented Mar 23, 2025

pip install segment-geospatial --no-build-isolation seems to succeed in Colab, since the build dependencies of everything in samgeo's requirements.txt (maybe just sam2/pytorch is relevant) are available in the Colab runtime.

@rbavery
Copy link

rbavery commented Mar 24, 2025

@giswqs just installing the different setuptools version won't work, you need to install sam2 from an isolated build with the new setuptools version (tested and confirmed working by me with uv) or install from my git commit. I've tested and this works, we're using it JinsuaFeito-dev/segment-anything-2#1

Once that PR is merged and a new sam2 release is made then you can pin to that new sam2 version

@giswqs
Copy link
Member Author

giswqs commented Mar 25, 2025

The breaking changes introduced by setuptools have been reverted. If you upgrade setuptools to the latest version v0.78.0.2, sam2 can be installed now.
pypa/setuptools#4870 (comment)

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

Successfully merging this pull request may close these issues.

Installation of segment-geospatial fails in Google Colab due to sam2 dependency error
3 participants