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

Is there any way to stop segment anything 2 from reinstalling itself every time its called? #4

Open
casabelle42 opened this issue Aug 16, 2024 · 5 comments

Comments

@casabelle42
Copy link

When I call on GroundedSAM2 with the ontology, it reinstalls SAM2 every time I run the program. Is there some sort of flag I can set that would stop that behavior? It will reinstall SAM2 with the same version even if I have previously run it moments ago.

@MC-devel-staudt
Copy link

Same issue. I get,

fatal: destination path 'segment-anything-2' already exists and is not an empty directory.

And then it proceeds to reinstall. There should probably be a simple check in GroundedSAM2 from autodistill_grounded_sam_2 that needs to be changed if the library was already built.

@nihirv
Copy link

nihirv commented Aug 16, 2024

in helpers.py there's this check which mistakenly always performs a re-installation:

    if not os.path.isdir("~/.cache/autodistill/segment_anything_2/segment-anything-2"):
        subprocess.run(
            [
                "git",
                "clone",
                "https://github.com/facebookresearch/segment-anything-2.git",
            ]
        )

        os.chdir("segment-anything-2")

        subprocess.run(["pip", "install", "-e", "."])

This is called in grounded_sam_2.py.

Simplest workaround is to copy the grounded_sam_2 file to your local workspace and also create your own load_SAM() function which removes the check (or has the correct check)

This also has the benefit of you being able to control which SAM model to use!

@octavflorescu
Copy link

if not os.path.exists(os.path.expanduser("~/.cache/autodistill/segment_anything_2/segment-anything-2")):

@walternat1ve
Copy link

yeah, this is really in bad shape. already the installation was not straight forward as expected. had to install many dependencies manually.

aam-at added a commit to aam-at/autodistill-grounded-sam-2 that referenced this issue Oct 10, 2024
aam-at added a commit to aam-at/autodistill-grounded-sam-2 that referenced this issue Oct 10, 2024
@pwernette
Copy link

pwernette commented Nov 19, 2024

Has there been any update on this issue? I recently installed autodistill and have been trying to use Grounded SAM 2 but still appear to be having this issue. Whatever the supposed fix was does not appear to have taken. Using WSL2 on Windows 11 with GPU configured.
Screenshot 2024-11-19 094113

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

No branches or pull requests

6 participants