Fashion Segmentation β€” YOLO26s-seg

On-device clothing segmentation model trained on DeepFashion2. Designed for mobile deployment via ONNX Runtime Mobile in React Native.

Built as part of β€” an offline-first AI wardrobe app.


Model Details

Property Value
Architecture YOLO26s-seg
Task Instance Segmentation
Dataset DeepFashion2 (491K+ images)
Classes 13 clothing categories
mAP50 0.55
mAP50-95 0.43
Precision 0.50
Recall 0.54
Input size 416 Γ— 416
Inference (CPU, edge device) ~500ms
Inference (mid-range device) ~250ms
Model size (.pt) ~6.5MB
Model size (.onnx) ~11MB

Classes (13)

ID Class
0 short_sleeve_top
1 long_sleeve_top
2 short_sleeve_outwear
3 long_sleeve_outwear
4 vest
5 sling
6 shorts
7 trousers
8 skirt
9 short_sleeve_dress
10 long_sleeve_dress
11 vest_dress
12 sling_dress

Files

File Description
best.pt PyTorch weights β€” for fine-tuning or Python inference
best.onnx ONNX weights β€” for mobile / edge deployment
train_fashion_yolo.py Full training script
deepfashion2_data.yaml Dataset config used for training
results.png Training curves
confusion_matrix_normalized.png Per-class confusion matrix
val_batch2_pred.jpg Sample validation predictions

Usage β€” PyTorch

from ultralytics import YOLO

model = YOLO('best.pt')

results = model(
    'your_image.jpg',
    conf=0.50,
    iou=0.45,
    imgsz=640,
)

for result in results:
    if result.masks is not None:
        for i in range(len(result.masks)):
            mask  = result.masks.data[i].cpu().numpy()
            cls   = int(result.boxes.cls[i].item())
            conf  = float(result.boxes.conf[i].item())
            label = model.names[cls]
            print(f"{label} β€” {conf:.2f}")

Usage β€” ONNX Runtime (Python)

import onnxruntime as ort
import numpy as np
from PIL import Image

# Load model
session = ort.InferenceSession(
    'best.onnx',
    providers=['CPUExecutionProvider']
)

# Preprocess
img = Image.open('your_image.jpg').convert('RGB')
img = img.resize((640, 640))
img = np.array(img, dtype=np.float32) / 255.0
img = img.transpose(2, 0, 1)           # HWC β†’ CHW
img = np.expand_dims(img, axis=0)      # add batch dim

# Inference
input_name = session.get_inputs()[0].name
outputs = session.run(None, {input_name: img})

Usage β€” ONNX Runtime Mobile (React Native)

import { InferenceSession, Tensor } from 'onnxruntime-react-native';
import RNFS from 'react-native-fs';

const loadModel = async () => {
  const modelPath = `${RNFS.MainBundlePath}/best.onnx`;
  const session = await InferenceSession.create(modelPath);
  return session;
};

const runInference = async (session, imageData) => {
  // imageData: Float32Array of shape [1, 3, 640, 640]
  // normalized to [0, 1]
  const tensor = new Tensor('float32', imageData, [1, 3, 640, 640]);
  const feeds = { images: tensor };
  const results = await session.run(feeds);
  return results;
};

Apply Segmentation Mask

import numpy as np
from PIL import Image as PILImage

def apply_mask(image_path, mask):
    img = np.array(PILImage.open(image_path).convert('RGB'))

    # Resize mask to image size
    mask_resized = np.array(
        PILImage.fromarray(mask).resize(
            (img.shape[1], img.shape[0]),
            PILImage.NEAREST
        )
    )

    # Zero out background
    masked = img.copy()
    masked[mask_resized == 0] = 0

    # Crop to item bounds
    rows = np.any(mask_resized, axis=1)
    cols = np.any(mask_resized, axis=0)
    rmin, rmax = np.where(rows)[0][[0, -1]]
    cmin, cmax = np.where(cols)[0][[0, -1]]

    return masked[rmin:rmax, cmin:cmax]

Training Details

Base model:     YOLO26s-seg (pretrained COCO weights)
Dataset:        DeepFashion2
                491K total images
Epochs:         30
Image size:     416 Γ— 416
Batch size:     128
Optimizer:      AdamW
LR:             0.001
Hardware:       Kaggle T4 GPU
Framework:      Ultralytics 8.x

Training Curves

results

Validation Predictions

predictions

Confusion Matrix

confusion matrix


Intended Use

This model was built for the Digital Wardrobe app β€” an offline-first AI wardrobe assistant that runs entirely on-device.

All inference runs on-device. No data leaves the user's phone.


Limitations

  • Trained primarily on western clothing β€” performance may drop on Indian ethnic wear (kurta, saree, salwar)
  • mAP drops on complex scenes with overlapping items
  • Best results on single items against plain backgrounds
  • 13 classes only β€” does not cover all clothing types

Fine-tuning

To fine-tune on your own data:

from ultralytics import YOLO

model = YOLO('best.pt')
model.train(
    data='your_data.yaml',
    epochs=20,
    imgsz=416,
    batch=128,
    lr0=0.0001,       # low LR for fine-tuning
    freeze=10,        # freeze backbone
    optimizer='AdamW',
)

Citation

If you use this model in your work, please credit:

@misc{fashion-segmentation-yolo26s,
  author    = {Hasan Kabir},
  title     = {Fashion Segmentation β€” YOLO26s-seg},
  year      = {2026},
  publisher = {HuggingFace},
  url       = {https://huggingface.co/HasanKabir23/Yolov26s-DeepFashion2}
}

Author

Hasan Kabir


License

Apache 2.0 β€” free to use, modify, and distribute with attribution.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support