Code Monkey home page Code Monkey logo

deep-person-reid's Introduction

Torchreid

Torchreid is a library built on PyTorch for deep-learning person re-identification.

It features:

  • multi-GPU training
  • support both image- and video-reid
  • end-to-end training and evaluation
  • incredibly easy preparation of reid datasets
  • multi-dataset training
  • cross-dataset evaluation
  • standard protocol used by most research papers
  • highly extensible (easy to add models, datasets, training methods, etc.)
  • implementations of state-of-the-art deep reid models
  • access to pretrained reid models
  • advanced training techniques
  • visualization of ranking results

Documentation: https://kaiyangzhou.github.io/deep-person-reid/.

News

24-03-2019: Torchreid documentation is out!

Installation

The code works with both python2 and python3.

Option 1

  1. Install PyTorch and torchvision following the official instructions.
  2. Clone deep-person-reid to your preferred directory
$ git clone https://github.com/KaiyangZhou/deep-person-reid.git
  1. cd to deep-person-reid and install dependencies
$ cd deep-person-reid/
$ pip install -r requirements.txt
  1. Install torchreid
$ python setup.py install # or python3
$ # If you wanna modify the source code without
$ # the need to rebuild it, you can do
$ # python setup.py develop

Option 2 (with conda)

We also provide an environment.yml file for easy setup with conda.

  1. Clone deep-person-reid to your preferred directory
$ git clone https://github.com/KaiyangZhou/deep-person-reid.git
  1. cd to deep-person-reid and create an environment (named torchreid)
$ cd deep-person-reid/
$ conda env create -f environment.yml

In doing so, the dependencies will be automatically installed.

  1. Install PyTorch and torchvision (select the proper cuda version to suit your machine)
$ conda activate torchreid
$ conda install pytorch torchvision cudatoolkit=9.0 -c pytorch
  1. Install torchreid
$ python setup.py install
$ # If you wanna modify the source code without
$ # the need to rebuild it, you can do
$ # python setup.py develop

Get started: 30 seconds to Torchreid

  1. Import torchreid
import torchreid
  1. Load data manager
datamanager = torchreid.data.ImageDataManager(
    root='reid-data',
    sources='market1501',
    height=256,
    width=128,
    batch_size=32,
    market1501_500k=False
)

3 Build model, optimizer and lr_scheduler

model = torchreid.models.build_model(
    name='resnet50',
    num_classes=datamanager.num_train_pids,
    loss='softmax',
    pretrained=True
)

model = model.cuda()

optimizer = torchreid.optim.build_optimizer(
    model,
    optim='adam',
    lr=0.0003
)

scheduler = torchreid.optim.build_lr_scheduler(
    optimizer,
    lr_scheduler='single_step',
    stepsize=20
)
  1. Build engine
engine = torchreid.engine.ImageSoftmaxEngine(
    datamanager,
    model,
    optimizer=optimizer,
    scheduler=scheduler,
    label_smooth=True
)
  1. Run training and test
engine.run(
    save_dir='log/resnet50',
    max_epoch=60,
    eval_freq=10,
    print_freq=10,
    test_only=False
)

A unified interface

In "deep-person-reid/scripts/", we provide a unified interface including a default parser file default_parser.py and the main script main.py. For example, to train an image reid model on Market1501 using softmax, you can do

python main.py \
--root path/to/reid-data \
--app image \
--loss softmax \
--label-smooth \
-s market1501 \
-a resnet50 \
--optim adam \
--lr 0.0003 \
--max-epoch 60 \
--stepsize 20 40 \
--batch-size 32 \
--save-dir log/resnet50-market-softmax \
--gpu-devices 0

Please refer to default_parser.py and main.py for more details.

Datasets

Image-reid datasets

Video-reid datasets

Models

ImageNet classification models

Lightweight models

ReID-specific models

Losses

Citation

If you find this code useful to your research, please link this repository in your paper.

deep-person-reid's People

Contributors

kaiyangzhou avatar yu-wu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.