autodistill / autodistill-grounded-sam-2

Use Segment Anything 2, grounded with Florence-2, to auto-label data for use in training vision models.
https://docs.autodistill.com
Apache License 2.0
80 stars 5 forks source link

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

Open casabelle42 opened 4 weeks ago

casabelle42 commented 4 weeks ago

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 commented 4 weeks ago

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 commented 4 weeks ago

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 commented 3 weeks ago

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

walternat1ve commented 3 weeks ago

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