Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make sam2 optional#393

Closed
giswqs wants to merge 3 commits into
mainfrom
sam2
Closed

Make sam2 optional#393
giswqs wants to merge 3 commits into
mainfrom
sam2

Conversation

@giswqs

@giswqs giswqs commented Mar 20, 2025

Copy link
Copy Markdown
Member

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

aruncveli commented Mar 22, 2025

Copy link
Copy Markdown

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

giswqs commented Mar 22, 2025

Copy link
Copy Markdown
Member Author

@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

aruncveli commented Mar 22, 2025

Copy link
Copy Markdown

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

aruncveli commented Mar 23, 2025

Copy link
Copy Markdown

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

rbavery commented Mar 24, 2025

Copy link
Copy Markdown

@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

giswqs commented Mar 25, 2025

Copy link
Copy Markdown
Member Author

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)

@giswqs giswqs closed this Mar 25, 2025
@giswqs giswqs deleted the sam2 branch December 18, 2025 02:54
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