segment-geospatial icon indicating copy to clipboard operation
segment-geospatial copied to clipboard

Initialise FastSAM is not working

Open riokt opened this issue 2 years ago • 7 comments

Environment Information

  • samgeo version: 0.10.2
  • Python version: 3.11
  • Operating System: Google Colab

Description

why can't I initialize the FastSAM model? image

What I Did

Change to this but not working

sam = SamGeo(model="FastSAM-x.pt", checkpoint_dir="content/FastSAM-x.pt")

riokt avatar Jan 11 '24 03:01 riokt

Hi @riokt I have the same issue in Google Collab for Samgeo vit_h when importing SamGeo like from samgeo.hq_sam import SamGeo

sam = SamGeo(
    model_type="vit_h",
    automatic=False,
    sam_kwargs=None,
)

Yields:

Model checkpoint for `vit_h `not found.
Access denied with the following error:

 	Cannot retrieve the public link of the file. You may need to change
	the permission to 'Anyone with the link', or have had many accesses. 

But if I just import SamGeo like from samgeo import SamGeo I do not have an issue - so maybe see if that helps progress you?

In regards to the issue with importing from samgeo.hq_sam maybe this is unexpected behavior - I believe the error comes from the gdown module that is responsible for handling downloading content into Google Collab so I am curious if its something with segment-geospatial or some limitations with Google Collab handling that large download

johngeoscrub avatar Jan 16 '24 07:01 johngeoscrub

[johngeoscrub](/johngeoscI

I have similar problem, the model from Samgeo.hq and FastSam , can not be downloaded automatically by system. And when i try to call the model (already downloaded in my laptop), it always failed. If you have solution, please share here. thank you

ihsan2805 avatar Jan 16 '24 08:01 ihsan2805

Same problem

grannycola avatar Jan 16 '24 09:01 grannycola

@ihsan2805 @grannycola this is not a complete fix but can maybe unblock you for the time being - do you still have issues if you import SamGeo like this from samgeo import SamGeo instead of from samgeo.hq_sam import SamGeo ?

johngeoscrub avatar Jan 16 '24 17:01 johngeoscrub

@johngeoscrub I used this:

from samgeo.fast_sam import SamGeo
sam = SamGeo(model="FastSAM-x.pt")

If i use from samgeo import SamGeo it works just fine.

grannycola avatar Jan 16 '24 17:01 grannycola

@johngeoscrub yes, everything is normal when i use from samgeo import SamGeo

ihsan2805 avatar Jan 17 '24 08:01 ihsan2805

If the automatic download fails, you can download the checkpoints manually and put them in the directory ~/.cache/torch/hub/checkpoints. Alternatively, you can pass in the checkpoint_dir parameter pointing to your checkpoints directory when initializing SamGeo

  • FastSAM-x.pt: https://drive.google.com/file/d/1m1sjY4ihXBU1fZXdQ-Xdj-mDltW-2Rqv/view?usp=sharing
  • FastSAM-s.pt: https://drive.google.com/file/d/10XmSj6mmpmRb8NhXbtiuO9cTTBwR_9SV/view?usp=sharing

giswqs avatar Jan 18 '24 04:01 giswqs