This repository serves as the official PyTorch implementation for the paper: Globally Correlation-Aware Hard Negative Generation.
It offers source code for replicating the experiments conducted on four benchmark datasets (CUB-200-2011, Cars196, SOP, and InShop) and releases the pretrained metric models.
- Python 3.8
- PyTorch 1.8.1+cu111
- torch_scatter 2.0.9
- numpy
- tqdm
- tensorboardX
- scikit-learn
- scipy
- Download four benchmark datasets.
- Extract the tgz or zip file into
./data/dataset_name/original/
folder and run the data convert scripts to transform data format. In particular, the InShop dataset does not require any data transformation.
python scripts/data_process/xxx_convert.py
- The data folder is constructed as followed:
data:
├── CUB200/CARS196/SOP
│ └── class
│ ├── train
│ │ ├── Catrgory 1
│ │ ├── Catrgory ...
│ │ └── Catrgory M
│ └── test
│ ├── Catrgory 1
│ ├── Catrgory ...
│ └── Catrgory N
└── IN_SHOP
├── img
│ ├── MEN
│ └── WOMEN
└── list_eval_partition.txt
Run the training process by designating the corresponding yml file.
python train.py --cfg scripts/cfgs/xxx.yml
The released metric model is available at Google Drive.
Given the (full model/ metric model) with pretrained weights, run the evaluation process as follows:
python eval.py --cfg scripts/cfgs/xxx.yml --model_path xxx.pth