Image Segmentation
Transformers
English
clipseg
segmentation
construction
drywall
quality-assurance
text-conditioned
binary-mask
Instructions to use youngPhilosopher/drywall-qa-clipseg with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use youngPhilosopher/drywall-qa-clipseg with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-segmentation", model="youngPhilosopher/drywall-qa-clipseg")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("youngPhilosopher/drywall-qa-clipseg", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download src/model/clipseg_wrapper.py from youngPhilosopher/drywall-qa-clipseg: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/youngPhilosopher/drywall-qa-clipseg/resolve/main/src/model/clipseg_wrapper.py
- Command line
-
hf download hf://youngPhilosopher/drywall-qa-clipseg/src/model/clipseg_wrapper.py
-
curl -L -o clipseg_wrapper.py https://huggingface.co/youngPhilosopher/drywall-qa-clipseg/resolve/main/src/model/clipseg_wrapper.py
1.04 kB
| """CLIPSeg model loading and freezing utilities.""" | |
| from transformers import CLIPSegForImageSegmentation, CLIPSegProcessor | |
| def load_model_and_processor(model_name: str = "CIDAS/clipseg-rd64-refined", freeze_backbone: bool = True): | |
| """Load CLIPSeg model and processor, optionally freezing the backbone.""" | |
| model = CLIPSegForImageSegmentation.from_pretrained(model_name) | |
| processor = CLIPSegProcessor.from_pretrained(model_name) | |
| if freeze_backbone: | |
| trainable, frozen = 0, 0 | |
| for name, param in model.named_parameters(): | |
| if "decoder" in name: | |
| param.requires_grad = True | |
| trainable += param.numel() | |
| else: | |
| param.requires_grad = False | |
| frozen += param.numel() | |
| print(f"Parameters — trainable (decoder): {trainable:,} | frozen (backbone): {frozen:,}") | |
| else: | |
| trainable = sum(p.numel() for p in model.parameters()) | |
| print(f"Parameters — all trainable: {trainable:,}") | |
| return model, processor | |