-
-
Notifications
You must be signed in to change notification settings - Fork 351
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Environment Information
- samgeo version: 0.12.6
- Python version: 3.10
- Operating System: Ubuntu 22
Description
I cannot instantiate a SAM HQ model, apparently related to the lack of .pth although it has downloaded it.
What I Did
Following the examples, I have run
from samgeo.hq_sam import SamGeo, show_image, download_file, overlay_images, tms_to_geotiff
sam_kwargs = {
"points_per_side": 32,
"pred_iou_thresh": 0.86,
"stability_score_thresh": 0.92,
"crop_n_layers": 1,
"crop_n_points_downscale_factor": 2,
"min_mask_region_area": 100,
}
sam = SamGeo(
model_type="vit_h",
sam_kwargs=sam_kwargs,
)
However, it downloads the model but does not unzip it, and thus does not get the .pth.
Model checkpoint for vit_h not found.
Downloading...
From: https://github.com/opengeos/datasets/releases/download/models/sam_hq_vit_h.zip
To: [/home/tda/.cache/torch/hub/checkpoints/sam_hq_vit_h.zip](http://localhost:8888/home/tda/.cache/torch/hub/checkpoints/sam_hq_vit_h.zip)
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1.02G[/1.02G](http://localhost:8888/1.02G) [02:07<00:00, 8.04MB[/s](http://localhost:8888/s)]
Downloading...
From: https://github.com/opengeos/datasets/releases/download/models/sam_hq_vit_h.z01
To: [/home/tda/.cache/torch/hub/checkpoints/sam_hq_vit_h.z01](http://localhost:8888/home/tda/.cache/torch/hub/checkpoints/sam_hq_vit_h.z01)
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1.36G[/1.36G](http://localhost:8888/1.36G) [02:43<00:00, 8.34MB[/s](http://localhost:8888/s)]
INFO patool: Extracting [/home/tda/.cache/torch/hub/checkpoints/sam_hq_vit_h.zip](http://localhost:8888/home/tda/.cache/torch/hub/checkpoints/sam_hq_vit_h.zip) ...
The unzipped files might already exist. Skipping extraction.
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
Cell In[7], line 1
----> 1 sam = SamGeo(
2 model_type="vit_h",
3 sam_kwargs=sam_kwargs,
4 )
File ~/CARLA/DigitalTwins/RasterParser/.venv/lib/python3.10/site-packages/samgeo/hq_sam.py:100, in SamGeo.__init__(self, model_type, automatic, device, checkpoint_dir, hq, sam_kwargs, **kwargs)
97 self.logits = None
99 # Build the SAM model
--> 100 self.sam = sam_model_registry[self.model_type](checkpoint=self.checkpoint)
101 self.sam.to(device=self.device)
102 # Use optional arguments for fine-tuning the SAM model
File ~/CARLA/DigitalTwins/RasterParser/.venv/lib/python3.10/site-packages/segment_anything_hq/build_sam.py:15, in build_sam_vit_h(checkpoint)
14 def build_sam_vit_h(checkpoint=None):
---> 15 return _build_sam(
16 encoder_embed_dim=1280,
17 encoder_depth=32,
18 encoder_num_heads=16,
19 encoder_global_attn_indexes=[7, 15, 23, 31],
20 checkpoint=checkpoint,
21 )
File ~/CARLA/DigitalTwins/RasterParser/.venv/lib/python3.10/site-packages/segment_anything_hq/build_sam.py:159, in _build_sam(encoder_embed_dim, encoder_depth, encoder_num_heads, encoder_global_attn_indexes, checkpoint)
157 sam.eval()
158 if checkpoint is not None:
--> 159 with open(checkpoint, "rb") as f:
160 state_dict = torch.load(f)
161 info = sam.load_state_dict(state_dict, strict=False)
FileNotFoundError: [Errno 2] No such file or directory: '[/home/tda/.cache/torch/hub/checkpoints/sam_hq_vit_h.pth](http://localhost:8888/home/tda/.cache/torch/hub/checkpoints/sam_hq_vit_h.pth)'
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working