WearIT Garment Mask is a specialized image segmentation pipeline for generating precise garment masks suitable for virtual try-on and image inpainting applications. The model combines three state-of-the-art computer vision models to create intelligent, variable-shaped masks around garments while protecting sensitive body areas (face, hands, feet).
Key Features
Multi-garment support: Upper body, lower body, and full-body garments
Smart protection zones: Automatically protects face, hands, and feet from masking
Variable mask shapes: Three strategies (ellipse, box, polygon) for diverse mask generation
Batch processing: Efficient processing of multiple images
Intelligent cropping: DensePose-based smart cropping around detected persons
Inpainting-ready: Outputs optimized for diffusion-based inpainting models
Model Architecture
The pipeline orchestrates three deep learning models:
DensePose (Detectron2 R_50_FPN_s1x): Dense human pose estimation with 24 body part classes
SCHP-ATR (ResNet101): Human parsing on ATR dataset (18 clothing classes)
SCHP-LIP (ResNet101): Human parsing on LIP dataset (20 clothing classes)
The models work in synergy to detect body parts and garment regions, then generate precise masks using morphological operations and geometric transformations.
Intended Uses
Primary Use Cases
Virtual Try-On: Generate masks for swapping garments in fashion e-commerce
Fashion Image Editing: Edit specific clothing items while preserving person identity
Dataset Augmentation: Create training data for fashion-related computer vision tasks
Image Inpainting: Prepare masks for diffusion model-based garment replacement
Out-of-Scope Uses
Real-time video processing (not optimized for speed)
Medical imaging or body analysis
Surveillance or person identification
Processing images without clear frontal human poses
1from transformers import pipeline
23# Load the pipeline4pipe = pipeline(5"image-segmentation",6 model="your-username/wearit-garment-mask",7 trust_remote_code=True,8 device="cuda:0"# or "cpu"9)1011# Generate masks for a single image12results = pipe(13"person.jpg",14 garment_types="upper"# or ["upper", "lower", "dress"]15)1617# Access the results18for result in results:19 image_id = result["image_id"]20 standardized_image = result["image_standardized"]2122# Get mask for upper garment23 upper_mask = result["masks"]["upper"]["person_mask"]24 upper_mask.save(f"{image_id}_upper_mask.png")
Advanced Usage
python
1# Process multiple images with different garment types2results = pipe(3["person1.jpg","person2.jpg"],4 garment_types=["upper","lower"],# Generate both types for each image5 image_ids=["img_001","img_002"],# Custom IDs for deterministic seeds6 output_dir="./output"# Save intermediate results7)89# Custom configuration10from pipeline import GarmentMaskPipeline
1112custom_pipe = GarmentMaskPipeline(13 device="cuda:0",14 output_height=1024,15 process_size=512,16 use_convex_hull=True,17 allowed_strategies=["ellipse","box"],# Restrict mask strategies18 save_images=True19)2021results = custom_pipe("person.jpg", garment_types="dress")