Repository navigation
GarmentIQ 0.0.4.11
⚠️ Breaking change: hardware acceleration is now opt-in
GarmentIQ no longer auto-detects a GPU. Every model loader and inference function takes a device argument that defaults to "cpu".
- Previously,
classification.load_modelhardcodedcuda if available else cpu, andpredictdefaulted to the same. - If you rely on automatic CUDA, you must now pass
device="cuda"explicitly, or your code will silently run on CPU. - In exchange, Apple Silicon works: pass
device="mps". - Accelerator cache is released after each inference call, for CUDA and MPS alike.
New modules
garmentiq.matting— refines a hard mask into a soft alpha matte for natural edges. Supports ViTMatte (trimap-guided, configs bundled forsmallandbase) and Matting Anything (SAM-prompt-guided, no trimap). Includesgenerate_trimap,matte,composite, andload_model.garmentiq.grounding— turns a natural-language phrase into bounding boxes via Grounding DINO, which is what gives SAM 1 and SAM 2 text-prompted segmentation. Includesground_text_to_boxesand a dedicatedload_grounding_model.
Segmentation: SAM 1, SAM 2, and SAM 3
- Added SAM 2.1 (all four Hiera sizes) and SAM 3, alongside the existing SAM 1.
- All prompts now travel through one unified
promptdictionary acceptingpoints,labels,boxes, andtext. Nesting differences between SAM generations are normalized automatically. - Native text prompts on SAM 3; on SAM 1 and SAM 2 a text prompt is routed through Grounding DINO transparently.
load_sam3_trackerreassembles SAM 3's tracker from the same checkpoint, giving point and label prompts that the SAM 3 detector does not support.- New introspection helpers:
sam_capabilities,sam_family,sam_model_class. - Configs, processors, and tokenizers for every SAM variant are bundled, so models load fully offline — only weights need downloading.
Tailor pipeline
- New
deviceargument. - Optional alpha matting via
do_matte=True, withsave_matting_imageproducingmatte_imageandmatte_composite_imageoutputs. - When matting is enabled, landmark detection runs on the alpha composite rather than the hard cutout.
- Configuration is validated up front, so a missing matting model or processor fails immediately instead of part way through a batch.
Fixes
- Fixed a latent crash on Python 3.12+:
pkg_resourceswas replaced withimportlib.resources. Since setuptools is no longer installed by default,import garmentiqcould fail outright. - Fixed SAM on Apple Silicon: processors emit float64 tensors, which MPS cannot hold, so every SAM prompt raised
TypeError. Inputs are now narrowed to float32 on MPS only, leaving CPU and CUDA numerics unchanged. - Fixed landmark detection on GPU: the model was never moved to the device before
DataParallel, anddetectnever moved its input tensor. - Fixed MPS detection in
extract, which usedis_cudaand so treated MPS as CPU. - Mismatched checkpoints now warn instead of silently returning a randomly initialized model.
- Fixed a hard failure without ipywidgets by switching from
tqdm.notebooktotqdm.auto. - ViTMatte no longer double-rescales the trimap, which produced an all-zero alpha.
- Grounding DINO has a dedicated loader; the generic one left 285 tied tensors randomly initialized.
Dependencies
transformersfloor raised from 4.50.3 to 5.0.0, which SAM 3 requires.- Added
requests; removed the unusedscipy.
Documentation
- Seven tutorial notebooks and three advanced-usage notebooks, all renamed and restructured with introductions and tables of contents. Every one is verified by execution.
- README reduced to an index with two Colab tables; full explanations now live in the notebooks.
- Complete module-level docstrings across all 64 modules, and a clean
pdocbuild.