Skip to content

icipvip/mmdetection

 
 

Repository files navigation

Installation

The code was tested with Python 3.6, CUDA 10.1, PyTorch 1.5.0 and torchvision 0.6.0.

  1. Install filterpy, lap, pandas.
pip install filterpy==1.4.5
pip install lap==0.4.0
pip install pandas
  1. Install pycocotools.
pip install "git+https://github.com/open-mmlab/cocoapi.git#subdirectory=pycocotools"
  1. Install pytorch 1.5.0, torchvision 0.6.0 compatible with cuda 10.1.
pip install torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
  1. Install mmcv-full 1.1.1, with compatibility for pytorch and cuda version.
pip install mmcv-full==1.1.1+torch1.5.0+cu101 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
  1. cd into the teamzodiac directory and Install mmdetection.
cd teamzodiac
pip install -e .

If you face any installation issues, please follow the mmdetection installation page

Test on an imagefolder

Suppose you want to run prediction on a folder of images, and store the results in submission format. Then cd into the teamzodiac folder of this codebase and run the following command:

cd teamzodiac
python vipcup/predict_imagefolder.py vipcup/custom_gfocal.py vipcup/finalmodel/epoch_2.pth  ${path_to_imagefolder}$  ${path_to_resultfolder}$
  • replace ${path_to_imagefolder}$ with the complete path to the folder containing all the images.
  • replace ${path_to_resultfolder}$ with the desired path to the folder where the results will be stored. The folder will be created if it doesn't exist.

This script makes prediction with a batch size of 1 and stores the result in submission format. It also prints the speed after every 50 prediction.

After running the script, an example output should look like this:

Done image [50 / 393], speed: 19.3 img/s
Done image [100/ 393], speed: 19.5 img/s
Done image [150/ 393], speed: 19.6 img/s
Done image [200/ 393], speed: 19.6 img/s
Done image [250/ 393], speed: 19.6 img/s
Done image [300/ 393], speed: 19.6 img/s
Done image [350/ 393], speed: 19.6 img/s

Done image [393/ 393]
Overall speed: 19.6 img/s

Reproduce Training

If you want to reproduce our training setup, you will need to organize the dataset.

ICIP 2020 Dataset

We assume that the privoded dataset is formatted as follows:

ICIP2020-fisheye-dataset-30072020
|--- fisheye-day-30072020
    |--- images
        |--- train
    |--- labels
        |--- train
|--- fisheye-night-30072020
    |--- images
    |--- labels
|--- fisheye-day-test-30072020
    |--- images
    |--- labels
|--- fisheye-night-test-30072020
    |--- images
    |--- labels

To compactly organize the data in train and test set we use the script organize_data.py. Please cd into the teamzodiac directory of this codebase and run the follwoing command:

cd teamzodiac
python vipcup/organize_data.py  ${path_to_icip_dataset}$  ./data

replace ${path_to_icip_dataset}$ with the complete path to where the ICIP2020-fisheye-dataset-30072020 folder is located.

running this script should create a data directory inside the teamzodiac folder. It will also merge the training data for night and day under data/train. Similarly, it will also merge the test data for night and day under data/test. After running the script, the folder structure should be as below:

teamzodiac
|--- ...
|--- configs
|--- data
    |--- train
        |--- images
        |--- labels
    |--- test
        |--- images
        |--- labels
| ...
|--- tests
|-- tools
|-- vipcup
    |--- custom_gfocal.py
    |--- yolo_to_coco.py
    |--- ...
| ...

The ground truths are provided in yolo format. But our codebase uses coco style json for training. To convert yolo format labels to coco formatted json, we have defined a script yolo_to_coco.py. It takes three command line arguments as follows:

python vipcup/yolo_to_coco.py  ${path_to_imagefolder}$  ${path_to_labelfolder}$  ${path_to_final_json}$

Assuming you are in the teamzodaic directory, run the following command to create the json for train set:

python vipcup/yolo_to_coco.py data/train/images data/train/labels data/train/labels_cocoformat.json

Similarly, create the json for test set:

python vipcup/yolo_to_coco.py data/test/images data/test/labels data/test/labels_cocoformat.json

Notice that, creating the json files may take some time as it requires to actually read all the images to find their height and width.

After running the above two commands the folder structure should be like this:

teamzodiac
|--- ...
|--- configs
|--- data
    |--- train
        |--- images
        |--- labels
        |--- labels_cocoformat.json
    |--- test
        |--- images
        |--- labels
        |--- labels_cocoformat.json
| ...
|--- tests
|-- tools
|-- vipcup
    |--- custom_gfocal.py
    |--- yolo_to_coco.py
    |--- ...
| ...

Train

At this point the data should be properly organized. Assuming you are in the teamzodiac directory, run the following command to reproduce our training results:

python tools/train.py vipcup/custom_gfocal.py --seed 1 --deterministic

This will train the network for 5 epochs. After each epoch, it runs evaluation on the test set and saves the checkpoint in vipcup/logdir folder. We found that the best result is achieved after epoch 2. This is the model we use for our final prediction and we save the weights in vipcup/finalmodel folder.

(Extra-1) Tracking

Given a folder of images, you can create tracking videos. To do so, cd into the teamzodiac directory and run the following command:

python vipcup/create_trackvideo.py vipcup/custom_gfocal.py vipcup/finalmodel/epoch_2.pth  ${path_to_imagefolder}$  ${path_to_videofolder}$
  • replace ${path_to_imagefolder}$ with the complete path to the folder containing all the images.
  • replace ${path_to_videofolder}$ with the desired path to the folder where the tracking videos will be stored. The folder will be created if it doesn't exist.

Notice that, to create tracking videos we assume that the filenames in the imagefolder follow a common format. That is: the last underscore separates the video name and frame id. For example: if a filename is 01_fisheye_day_test_000058.jpg, we asssume that this image belongs to a video named 01_fisheye_day_test and it is the 58th frame of that video. If your images in the imagefolder doesn't follow this naming convention, the tracker may produce ambigiuos output.

We submit example tracking videos along with our code submission. We used the following command to create the those videos:

python vipcup/create_trackvideo.py vipcup/custom_gfocal.py vipcup/finalmodel/epoch_2.pth data/test/images vipcup/track_videos

This creates the following 5 track videos in the vipcup/track_videos directory:

01_fisheye_day_test.avi
02_fisheye_day_test.avi
03_fisheye_day_test.avi
CLIP_20200628-210253.avi
CLIP_20200628-210808.avi

Acknowledgement

We biuld on top of MMDetection codebase. Thanks MMDetection team for the wonderful open source project!

Reference

About

OpenMMLab Detection Toolbox and Benchmark

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.9%
  • Other 0.1%