Make huggingface_hub soft dependency

This commit is contained in:
Niels
2024-08-05 09:37:53 +02:00
parent 0c28c630c2
commit 6aeee34775
3 changed files with 24 additions and 4 deletions

View File

@@ -13,7 +13,6 @@ import torch
from PIL.Image import Image
from sam2.modeling.sam2_base import SAM2Base
from sam2.build_sam import build_sam2_hf
from sam2.utils.transforms import SAM2Transforms
@@ -74,6 +73,8 @@ class SAM2ImagePredictor:
Returns:
(SAM2ImagePredictor): The loaded model.
"""
from sam2.build_sam import build_sam2_hf
sam_model = build_sam2_hf(model_id, **kwargs)
return cls(sam_model)