File size: 4,025 Bytes
bc4546e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
---
license: apache-2.0
tags:
- image-classification
- multi-label
- fashion
- apparel
- manufacturing
- quality-control
- siglip2
datasets:
- Fashionpedia
metrics:
- f1
- average-precision
pipeline_tag: image-classification
library_name: transformers
---

# garment-attributes

Multi-label classification of fine-grained garment construction attributes
from a garment crop: silhouette, length, neckline/collar/sleeve/pocket type,
opening/closure type, waistline, textile pattern, finishing techniques, and
fabric appearance. SigLIP2 vision encoder (Apache 2.0) with a classification
head, fine-tuned on per-instance attribute annotations from
[Fashionpedia](https://fashionpedia.github.io/home/) (CC BY 4.0).

Label space: the 218 Fashionpedia attributes with β‰₯100
training instances (the full list with supergroups and support counts ships
in `label_space.json` and in `config.json` `id2label`). Attributes map to
tech pack fields β€” e.g. *opening type* β†’ construction/closure, *textile
pattern* β†’ BOM/fabric β€” per the pipeline's `docs/taxonomy.md`.

Loads with stock `transformers` β€” no remote code:

```python
from transformers import AutoImageProcessor, AutoModelForImageClassification
import torch
from PIL import Image

model = AutoModelForImageClassification.from_pretrained("resoa/garment-attributes")
proc = AutoImageProcessor.from_pretrained("resoa/garment-attributes")
img = Image.open("garment_crop.jpg")  # crop of ONE garment, not a full scene
probs = torch.sigmoid(model(**proc(images=img, return_tensors="pt")).logits)[0]
for i, p in enumerate(probs):
    if p > 0.5:
        print(model.config.id2label[i], round(p.item(), 3))
```

## Intended use

- Estimate visible construction characteristics of a manufactured garment
  from a photo (crop the garment first β€” use `garment-detector-seg`).
- Cross-check a sample against tech pack attributes ("single-breasted",
  "welt pockets", "no distressing").

**Important:** input must be a single-garment crop. Full-scene inputs
degrade accuracy sharply; that is what the detector stage is for.

**Out of scope:** fiber content, GSM, measurements, stitch class, color
(color is measured deterministically in the pipeline, not classified).

## Training

- Base: `google/siglip2-base-patch16-224` (Apache 2.0).
- Data: 156,937 Fashionpedia per-instance crops with attribute labels
  (`scripts/prepare_attribute_data.py`; 8% bbox padding, min crop 48 px,
  attributes with 100+ train instances).
- Objective: sigmoid BCE (`problem_type="multi_label_classification"`).
- Recipe: `scripts/train_attributes.py` with `configs/attributes_mac.yaml`
  (4 epochs, batch 32, lr 2e-5, cosine schedule, trained on Apple-silicon
  MPS in ~4.5 hours; val metrics improved monotonically each epoch).

## Evaluation (Fashionpedia val2020 instances)

| Metric | Value |
|---|---|
| macro mAP | 0.442 |
| micro F1 @ 0.5 | 0.710 |
| macro F1 @ 0.5 | 0.306 |
| eval instances | 3,711 |
| evaluable labels | 212 of 218 |

**Read the per-attribute table** (`per_attribute.md`, shipped in this repo)
before using any single attribute for QC decisions: performance varies
widely by attribute, and rare attributes (support near the cutoff) can be
substantially weaker. We publish the full table, including the bad rows,
on purpose.

## Known limitations & biases

- Multi-label confidences are not calibrated probabilities; the reference
  pipeline routes 0.5–0.7 confidence predictions to human review.
- Absence of a prediction is weak evidence of absence (occlusion, angle).
- Trained on worn-garment street photos; flat-lay/factory photos are
  out-of-domain β€” fine-tune on in-domain crops for production use.
- Attribute definitions follow Fashionpedia's expert ontology, which may
  differ from a specific factory's terminology; the supergroup mapping in
  `label_space.json` is the bridge.

## License & attribution

Weights: Apache 2.0. Data: Fashionpedia, CC BY 4.0 β€” cite Jia et al.,
ECCV 2020. Base model: SigLIP2 (Google, Apache 2.0), Tschannen et al., 2025.