File size: 748 Bytes
c31821c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | from annotator.mobile_sam import SamDetector_Aux
from scripts.supported_preprocessor import Preprocessor
class PreprocessorMobileSam(Preprocessor):
def __init__(self):
super().__init__(name="mobile_sam")
self.tags = ["Segmentation"]
self.model = None
def __call__(
self,
input_image,
resolution,
slider_1=None,
slider_2=None,
slider_3=None,
**kwargs
):
if self.model is None:
self.model = SamDetector_Aux.from_pretrained()
result = self.model(input_image, detect_resolution=resolution, image_resolution=resolution, output_type="cv2")
return result
Preprocessor.add_supported_preprocessor(PreprocessorMobileSam()) |