Download sd-webui-controlnet/scripts/preprocessor/mobile_sam.py from Nybus/forge-extensions: direct link, hf CLI and curl.
- Browser
- Download file 748 Bytes
-
https://huggingface.co/datasets/Nybus/forge-extensions/resolve/main/sd-webui-controlnet/scripts/preprocessor/mobile_sam.py
- Command line
-
hf download hf://datasets/Nybus/forge-extensions/sd-webui-controlnet/scripts/preprocessor/mobile_sam.py
-
curl -L -o mobile_sam.py https://huggingface.co/datasets/Nybus/forge-extensions/resolve/main/sd-webui-controlnet/scripts/preprocessor/mobile_sam.py
748 Bytes
| 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()) |