This is an overview of the codes for V2ReID. The codes find their inspiration from VOLO and TransReID. Each .py file contains further descriptions. Please do not hesitate to contact us if have any questions or suggestions! 😊
datasets directory contains modules related to reading and sampling the input datasets.
Please refer to the configs under DATALOADER
and INPUT
to choose the the desired parameters:
- bases.py retrieves the information of the ReID dataset (train, query and gallery), such as number of vehicle IDs, number of images, number of camera IDs (not used in training), and the image paths for data loading.
- make_dataloader.py loads the train, query and gallery data and applies data augmentation such as resizing, padding, flips, etc.
- sampler.py implements the random identity sampler, that's used when training with the triplet loss. The data needs to be sampled in a specific way, such that we have k instances for each N vehicle identity per batch.
- veri.py specifically reads VeRi-776. For other datasets, e.g. VehicleID, you'll need to modify it.
loss directory contains modules related to the different losses (ID, triplet and center). Please refer to the configs under LOSS
to choose the desired parameters.
- center_loss.py implements the centre loss.
- make_loss.py builds the loss.
- triplet_loss.py implements the triplet loss.
The total loss is formulated as
where
- using the ID loss only: set
TIRPLET_LOSS
andCENTER_LOSS
toFalse
- using the ID and triplet loss: set
TIRPLET_LOSS
toTrue
andCENTER_LOSS
toFalse
- using the three losses: set
TIRPLET_LOSS
andCENTER_LOSS
toTrue
The weights can be adjusted withID_LOSS_WEIGHT
,TRIPLET_LOSS_WEIGHT
andCENTER_LOSS_WEIGHT
.
models directory contains modules related to the backbone architecture (VOLO). Please refer to the configs under MODEL
.
- volo.py: implementation of VOLO. We added a snippet for overlapping patches, the batch normalization/layer normalization neck and how to create your own model with your own settings.
solver directory contains modules related to the optimization and optimization scheduler (i.e. learning rate scheduler). Please refer to the configs under SOLVER
.
- cosine_lr.py implementats the cosine LR scheduler
- make_optimizer.py creates the optimizer
- scheduler_factory.py creates the LR scheduler (cosine or step)
- scheduler.py base class used to schedule optimizer parameter groups
- step_lr.py implements the step LR scheduler
tools directory contains the training options (with and without center loss)
- train_with_center.py: training with center loss
- train_without_center.py: training without center loss
utils directory contains modules related to the evaluation and logging the process.
- logger.py: set up a logger
- meter.py: computes and stores a meter
- metrics.py: computes the mAP and CMC
- utils.py: for loading the pretrained weights