zjykzj / multigrain-pytorch

MultiGrain: a unified image embedding for classes and instances

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Language: 🇺🇸 🇨🇳

«MultiGrain» re-implements the paper MultiGrain: a unified image embedding for classes and instances

Table of Contents

Background

MultiGrain provides a unified framework to simultaneously train classification and retrieval tasks. In addition, it also provides source code implementation - facebookresearch/multigrain. This warehouse is modified on the original basis to deepen the understanding and use of the MultiGrain framework.

Installation

...

Usage

cd multigrain
export PYTHONPATH=.
  • Base Operation
# One-GPU
python3 train.py --model resnet50 --lr 1e-2 --data-path /data/imagenet/ --output-dir ./outputs --ra-reps 1 --batch-size 128 --epochs 120
# Multi-GPU
torchrun --nproc_per_node=8 train.py --model resnet50 --lr 1e-2 --data-path /data/imagenet/ --output-dir ./outputs --ra-reps 1 --batch-size 128 --epochs 120
  • Use DistributedSampler (Multi-GPU)
torchrun --nproc_per_node=8 train.py --model resnet50 --lr 0.2 --data-path /data/imagenet/ --output-dir ./outputs --batch-size 256 --epochs 120 --classify-weight 0.5 --pooling-exponent 3 --ra-reps 3 --amp --lr-warmup-epochs 5 --lr-warmup-method linear
Epoch: [117] Acc@1 75.816 Acc@5 92.600
  • Use RASampler (Multi-GPU)
torchrun --nproc_per_node=8 train.py --model resnet50 --lr 0.2 --data-path /data/imagenet/ --output-dir ./outputs --batch-size 256 --epochs 120 --classify-weight 0.5 --pooling-exponent 3 --ra-sampler --ra-reps 3 --amp --lr-warmup-epochs 5 --lr-warmup-method linear
Epoch: [114] Acc@1 75.634 Acc@5 92.686

Maintainers

  • zhujian - Initial work - zjykzj

Thanks

@ARTICLE{2019arXivMultiGrain,
       author = {Berman, Maxim and J{\'e}gou, Herv{\'e} and Vedaldi Andrea and
         Kokkinos, Iasonas and Douze, Matthijs},
        title = "{{MultiGrain}: a unified image embedding for classes and instances}",
      journal = {arXiv e-prints},
         year = "2019",
        month = "Feb",
}

Contributing

Anyone's participation is welcome! Open an issue or submit PRs.

Small note:

License

Apache License 2.0 © 2022 zjykzj

About

MultiGrain: a unified image embedding for classes and instances

License:Apache License 2.0


Languages

Language:Python 100.0%