Skip to content

GarmentIQ Python v0.0.4.11

Latest

Choose a tag to compare

@lygitdata lygitdata released this 11 Sep 11:02
· 2 commits to main since this release

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_model hardcoded cuda if available else cpu, and predict defaulted 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 for small and base) and Matting Anything (SAM-prompt-guided, no trimap). Includes generate_trimap, matte, composite, and load_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. Includes ground_text_to_boxes and a dedicated load_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 prompt dictionary accepting points, labels, boxes, and text. 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_tracker reassembles 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 device argument.
  • Optional alpha matting via do_matte=True, with save_matting_image producing matte_image and matte_composite_image outputs.
  • 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_resources was replaced with importlib.resources. Since setuptools is no longer installed by default, import garmentiq could 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, and detect never moved its input tensor.
  • Fixed MPS detection in extract, which used is_cuda and 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.notebook to tqdm.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

  • transformers floor raised from 4.50.3 to 5.0.0, which SAM 3 requires.
  • Added requests; removed the unused scipy.

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 pdoc build.