Giter Site home page Giter Site logo

lcenarthas / cvwc2019-amur-tiger-re-id Goto Github PK

View Code? Open in Web Editor NEW
116.0 5.0 22.0 1.27 MB

:trophy: Code for 1st Place Soluition in both the Tiger Re-ID in the plain track and Tiger Re-ID in the wild track (CVWC) @ ICCV19 Workshop.

License: Apache License 2.0

Python 100.00%

cvwc2019-amur-tiger-re-id's Introduction

CVWC2019-Amur-Tiger-Re-ID

Example result of Rank-7 .

๐Ÿ†Code for 1st Place Soluition in both the Tiger Re-ID in the plain track and Tiger Re-ID in the wild trackCVWC2019 @ICCV19 Workshop.

๐Ÿ”–Paper: Part-Pose Guided Amur Tiger Re-Identification


๐Ÿƒ Getting Started

1๏ธโƒฃ Clone the repo:

git clone https://github.com/LcenArthas/CWCV2019-Amur-Tiger-Re-ID.git

2๏ธโƒฃ Dependencies

Tested under python3.6 Ubantu16.04

  • python packages
    • pytorch=1.0.1
    • torchvision==0.2.1
    • pytorch-ignite=0.1.2 (Note: V0.2.0 may result in an error)
    • yacs==0.1.6
    • tensorboardx
    • h5py==2.9.0
    • imgaug==0.2.9
    • matplotlib==3.1.0
    • numpy==1.16.4
    • opencv==4.1.0.15
    • pillow==6.0.0
    • scikit-image==0.15.0
    • scipy==1.3.0
    • tensorboardx==1.6
    • tqdm==4.32.1
    • yacs==0.1.6

๐Ÿ‘‰ Section1 The Tiger Plain Re-ID:

๐Ÿƒ Train

1๏ธโƒฃ Data Prearation

๐Ÿ”ธ Download the train dataset and put them(atrw_reid_train, atrw_anno_reid_train) into the {repo_root}/process_data/.

๐Ÿ”ธ Transform the data style for the model

python data_process.py

2๏ธโƒฃ Pre-trained weight

๐Ÿ”ธ Creat a new folder named /pretrained_model/ under the {repo_root}/:

cd data
mkdir pretrained_model

๐Ÿ”ธ Download the pre-trained weighte and put them into the {repo_root}/pretrained_model/.

And make sure the repo files as the following structure:

{repo_root}
 โ”œโ”€โ”€ config
 โ”œโ”€โ”€ configs
 โ”œโ”€โ”€ data
 |   โ”œโ”€โ”€ AmurTiger
 โ”‚   โ”‚   โ”œโ”€โ”€ flod0
 โ”‚   โ”‚   โ””โ”€โ”€ flod1
 โ”‚   โ”‚   โ”œโ”€โ”€ flod2
 โ”‚   โ”‚   โ””โ”€โ”€ flod3
 โ”‚   โ”œโ”€โ”€ datasets
 โ”‚ย ย  โ”œโ”€โ”€ samplers
 โ”‚ย ย  โ””โ”€โ”€ ...
 โ”œโ”€โ”€ engine
 โ”œโ”€โ”€ layers
 โ”œโ”€โ”€ modeling
 โ”œโ”€โ”€ pre_data
 โ”œโ”€โ”€ pretrained_model
 โ”œโ”€โ”€ solver
 โ”œโ”€โ”€ tests
 โ”œโ”€โ”€ utils
 โ”œโ”€โ”€ check_result.py
 โ”œโ”€โ”€ data_process.py
 โ”œโ”€โ”€ medo.py
 โ”œโ”€โ”€ medo_wide.py
 โ”œโ”€โ”€ test.py
 โ””โ”€โ”€ train.py

๐Ÿ‘ Train Now!

In this competition, I use 4-fold to train and ues the Resnet152 for the backbone.

python train.py --config_file ./configs/tiger_b_resnet152_34.yml --index_flod 0
python train.py --config_file ./configs/tiger_b_resnet152_34.yml --index_flod 1
python train.py --config_file ./configs/tiger_b_resnet152_34.yml --index_flod 2
python train.py --config_file ./configs/tiger_b_resnet152_34.yml --index_flod 3

Eventually the trained model will be saved in {repo_root}/tiger_out/b_resnet152_34/


๐Ÿƒ Inference

1๏ธโƒฃ Data Preparation

๐Ÿ”ธ Creat a new folder named /reid_test/ under the {repo_root}/data/AmurTiger/:

cd data
cd AmurTiger
mkdir reid_test

๐Ÿ”ธ Put the test images in the {repo_root}/data/AmurTiger/reid_test/.

2๏ธโƒฃ Download Pretrained Model

The trained weights are following:

Download it and create a new folder under the {repo_root} named /trained_weight/

mkdir trained_weight

Unzip the model.zip(there will be 8 trained weights) and put them in the {repo_root}/trained_weight/.

And make sure the repo files as the following structure:

  {repo_root}
  โ”œโ”€โ”€ config
  โ”œโ”€โ”€ configs
  โ”œโ”€โ”€ data
  |   โ”œโ”€โ”€ AmurTiger
  โ”‚   โ”‚   โ”œโ”€โ”€ flod0
  โ”‚   โ”‚   โ””โ”€โ”€ reid_test
  โ”‚   โ”‚       โ”œโ”€โ”€ 000000.jpg
  โ”‚   โ”‚       โ”œโ”€โ”€ 000004.jpg
  โ”‚   โ”‚       โ”œโ”€โ”€ 000005.jpg
  โ”‚   โ”‚       โ”œโ”€โ”€ 000006.jpg
  โ”‚   โ”‚       โ”œโ”€โ”€ 000008.jpg
  โ”‚   โ”‚       โ””โ”€โ”€ ...
  โ”‚ย ย  โ”œโ”€โ”€ datasets
  โ”‚ย ย  โ”œโ”€โ”€ samplers
  โ”‚ย ย  โ””โ”€โ”€ ...
  โ”œโ”€โ”€ engine
  โ”œโ”€โ”€ layers
  โ”œโ”€โ”€ modeling
  โ”œโ”€โ”€ solver
  โ”œโ”€โ”€ tests
  โ”œโ”€โ”€ trained_weight
  โ”‚   โ”œโ”€โ”€ resnet101-bsize_model_100.pth
  โ”‚   โ”œโ”€โ”€ resnet101-bsize_model_300.pth       
  โ”‚   โ”œโ”€โ”€ resnet101-bsize_model_301.pth
  โ”‚   โ”œโ”€โ”€ resnet101-bsize_model_400.pth
  โ”‚   โ””โ”€โ”€...
  โ”œโ”€โ”€ utils
  โ”œโ”€โ”€ check_result.py
  โ”œโ”€โ”€ medo.py
  โ”œโ”€โ”€ medo_wide.py
  โ”œโ”€โ”€ test.py
  โ””โ”€โ”€ train.py
      

๐Ÿ‘ Inference Now!

python demo.py

This process will take about 6 minutes, just a moment, please.

It will generate a submission in the {repo_root/}:

  • submission_plain.json โ€”-you can submit to the Tiger Plain Re-ID track.

๐Ÿ‘‰ Section2ย  Theย Tiger Wild Re-ID

๐Ÿƒ Train

Same thing up here

๐Ÿƒ Inference

In this task, it's a two-step process: Detection and Re-id

1๏ธโƒฃ Detection

๐Ÿ”ธ Please follow this repo: CWCV2019-Amur-Tiger-Detection

Note that the two repos depend on different environments(Re-ID is pytorch==1.0.1, Detection is pytorch==0.4.1)

๐Ÿ”ธ Run scrip in above repo will generate 3 files in the {repo_root/}:

  • det_submission.json

  • wide_box.json

  • reid_test(a folder) --it contains images that have been detected and croped.

This wide_box.json and reid_test(a folder) are what we need next.

2๏ธโƒฃ Re-ID

Use this reop.

๐Ÿ”ธ Data Preparation

Put wide_box.json and reid_test(a folder)(created by the detector above) under the {repo_root}/data/AmurTiger/.

๐Ÿ”ธ Download Pretrained Model(Same as the plain re-id)

The trained weight is following:

Download it and create a new folder under the {repo_root} named /trained_weight/

mkdir trained_weight

Unzip the model.zip and put them into the {repo_root}/trained_weight/.

And make sure the repo files as the following structure:

 {repo_root}
 โ”œโ”€โ”€ config
 โ”œโ”€โ”€ configs
 โ”œโ”€โ”€ data
 |   โ”œโ”€โ”€ AmurTiger
 โ”‚   โ”‚   โ”œโ”€โ”€ flod0
 โ”‚   โ”‚   โ”œโ”€โ”€ wide_box.json
 โ”‚   โ”‚   โ””โ”€โ”€ reid_test
 โ”‚   โ”‚       โ”œโ”€โ”€ 000000.jpg
 โ”‚   โ”‚       โ”œโ”€โ”€ 000004.jpg
 โ”‚   โ”‚       โ”œโ”€โ”€ 000005.jpg
 โ”‚   โ”‚       โ”œโ”€โ”€ 000006.jpg
 โ”‚   โ”‚       โ”œโ”€โ”€ 000008.jpg
 โ”‚   โ”‚       โ””โ”€โ”€ ...
 โ”‚ย ย  โ”œโ”€โ”€ datasets
 โ”‚ย ย  โ”œโ”€โ”€ samplers
 โ”‚ย ย  โ””โ”€โ”€ ...
 โ”œโ”€โ”€ engine
 โ”œโ”€โ”€ layers
 โ”œโ”€โ”€ modeling
 โ”œโ”€โ”€ solver
 โ”œโ”€โ”€ tests
 โ”œโ”€โ”€ trained_weight
 โ”‚   โ”œโ”€โ”€ best_model.pth
 โ”‚   โ”œโ”€โ”€ resnet101-bsize_model_100.pth
 โ”‚   โ”œโ”€โ”€ resnet101-bsize_model_300.pth       
 โ”‚   โ”œโ”€โ”€ resnet101-bsize_model_301.pth
 โ”‚   โ”œโ”€โ”€ resnet101-bsize_model_400.pth
 โ”‚   โ””โ”€โ”€...
 โ”œโ”€โ”€ utils
 โ”œโ”€โ”€ check_result.py
 โ”œโ”€โ”€ medo.py
 โ”œโ”€โ”€ medo_wide.py
 โ”œโ”€โ”€ test.py
 โ””โ”€โ”€ train.py
     

๐Ÿ‘ Inference Now!

python demo_wide.py

This process will take about 15 minutes, just a moment, please.

It will generate a submission in the {repo_root/}:

  • submission_wide.json โ€”-you can submit to the Tiger Wide Re-ID track.

cvwc2019-amur-tiger-re-id's People

Contributors

lcenarthas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cvwc2019-amur-tiger-re-id's Issues

Inference part

Hi,
Can you explain how you can get the top-k results as on Figure 4 during the inference part ?
Do you compute a distance between the Dfull of all images ?

Thanks!

test.py

Traceback (most recent call last):
File "test.py", line 67, in
main()
File "test.py", line 61, in main
model.load_param(cfg.TEST.WEIGHT)
AttributeError: 'tuple' object has no attribute 'load_param'
่ฏท้—ฎไธ€ไธ‹๏ผŒไธบไป€ไนˆ่ฟ่กŒtest.pyๅ‡บ็ŽฐๆŠฅ้”™

the missing arguments

ๆ‚จๅฅฝ๏ผŒๅœจๅค็Žฐๆ‚จCVWC2019็š„ไธœๅŒ—่™Žre-idไปฃ็ ๆ—ถๅœจ็ฌฌไธ€ๆญฅ่ฎญ็ปƒๆ—ถๆŠฅ้”™ๅฐ‘ไบ†img_bodyๅ’Œimg_partไธคไธชๅ‚ๆ•ฐ๏ผŒ่ฎญ็ปƒ่ƒฝๆญฃๅธธ่ฟ›่กŒ๏ผŒไฝ†ๆ˜ฏlossๅ…จๅ˜ๆˆnanไบ†ใ€‚ๆ‰พๅˆฐไบ†่ฟ™ไธคไธชๅ‚ๆ•ฐ็š„ๆ–นๆณ•ๅœจpipeline.py๏ผŒไฝ†ๅฎžๅœจไธๆธ…ๆฅš่ฟ™ไธชไปฃ็ ๅ’Œtrain.pyไน‹้—ด็š„ๅ…ณ็ณป๏ผŒ่ฏท้—ฎๆ‚จ็Ÿฅ้“้—ฎ้ข˜ๅฏ่ƒฝๅ‡บ็Žฐๅœจๅ“ชๅ—

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.