(self, device)
| 801 | |
| 802 | class Segmenting: |
| 803 | def __init__(self, device): |
| 804 | print(f"Inintializing Segmentation to {device}") |
| 805 | self.device = device |
| 806 | self.torch_dtype = torch.float16 if 'cuda' in device else torch.float32 |
| 807 | self.model_checkpoint_path = os.path.join("checkpoints","sam") |
| 808 | |
| 809 | self.download_parameters() |
| 810 | self.sam = build_sam(checkpoint=self.model_checkpoint_path).to(device) |
| 811 | self.sam_predictor = SamPredictor(self.sam) |
| 812 | self.mask_generator = SamAutomaticMaskGenerator(self.sam) |
| 813 | |
| 814 | self.saved_points = [] |
| 815 | self.saved_labels = [] |
| 816 | |
| 817 | def download_parameters(self): |
| 818 | url = "https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth" |
nothing calls this directly
no test coverage detected