Method
__init__
(self, checkpoint_path: str, bpe_path: str, device: str = None)
Source from the content-addressed store, hash-verified
| 215 | """SAM3模型封装""" |
| 216 | |
| 217 | def __init__(self, checkpoint_path: str, bpe_path: str, device: str = None): |
| 218 | super().__init__() |
| 219 | self.checkpoint_path = checkpoint_path |
| 220 | self.bpe_path = bpe_path |
| 221 | self.device = device or ("cuda" if torch.cuda.is_available() else "cpu") |
| 222 | self._processor = None |
| 223 | |
| 224 | # 图像状态缓存 |
| 225 | self._state_cache = OrderedDict() |
| 226 | self._max_cache_size = 3 |
| 227 | self._cache_lock = threading.Lock() |
| 228 | |
| 229 | def load(self): |
| 230 | """加载SAM3模型""" |
Tested by
no test coverage detected