File size: 2,051 Bytes
d13852c
 
 
 
 
 
 
 
 
abec1a5
 
d13852c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: mit
tags:
  - fashion
  - image-retrieval
  - resnet50
  - triplet-loss
  - deepfashion
---
# Full Project with frontend backend
https://github.com/ShushanSS/TopK_Similar_Images_Retrieval

# DeepFashion Retrieval — Fine-tuned ResNet50 Embedder

Fine-tuned ResNet50 image embedder for fashion item retrieval, trained with
batch-hard triplet loss and a category-aware PK sampler on the DeepFashion
In-shop Clothes Retrieval dataset.

## Contents

| File | Description |
|---|---|
| `embedder_full_train_epoch_6.pt` | Fine-tuned ResNet50 weights (epoch 6) |
| `faiss_index.bin` | FAISS index built over embedded gallery images *(if included)* |
| `metadata.json` / `config.json` | Embedding dim, class list, preprocessing params *(if included)* |

## Setup

```bash
pip install -r requirements.txt
python download_weights.py
```

This downloads the files above into `./weights` in your project root.

## Generating metadata locally

The metadata CSVs are **not included** in this repo since they're derived
from the raw DeepFashion images, which you need to download separately.

1. Download the DeepFashion (In-shop Clothes Retrieval) high-res images.
2. Update `DATASET_PATH` in `prepare_metadata.py` to point to your local copy,
   preserving the original folder structure:
   ```
   <DATASET_PATH>/<gender>/<clothing_category>/<item_id>/<image>.jpg
   ```
3. Run:
   ```bash
   python prepare_metadata.py
   ```
   This produces `original_metadata.csv`, `full_metadata.csv`, and
   `original_metadata_filtered.csv` in your working directory.

## Model details

- **Backbone:** ResNet50, fine-tuned with batch-hard triplet loss
- **Sampler:** CategoryAwarePKSampler
- **Retrieval baseline (CLIP zero-shot):** Hit Rate@5 = 0.546
- **Fine-tuned ResNet50:** Hit Rate@5 = 0.819 on controlled test set

## Usage

```python
from huggingface_hub import snapshot_download

snapshot_download(
    repo_id="ShushanSS/DeepFashionRetrieval",
    local_dir="./weights",
    local_dir_use_symlinks=False,
)
```

## License

MIT (update if different)