Skip to content

A PyTorch version of You Only Look at One-level Feature object detector

Notifications You must be signed in to change notification settings

yjh0410/PyTorch_YOLOF

Repository files navigation

YOLOF: You Only Look At One-level Feature

This is a PyTorch version of YOLOF.

Requirements

  • We recommend you to use Anaconda to create a conda environment:
conda create -n yolof python=3.6
  • Then, activate the environment:
conda activate yolof
  • Requirements:
pip install -r requirements.txt 

We suggest that PyTorch should be higher than 1.9.0 and Torchvision should be higher than 0.10.3. At least, please make sure your torch is version 1.x.

My environment:

  • Torch = 1.9.1
  • Torchvision = 0.10.1

Main results on COCO-val

  • AP results of YOLOF
Model scale FPS AP AP50 Weight
YOLOF-R18-C5_1x 800,1333 100 32.6 51.3 github
YOLOF-R50-C5_1x 800,1333 50 37.5 57.4 github
YOLOF-R50-DC5_1x 800,1333 32 38.7 58.5 github
YOLOF-R101-C5_1x 800,1333 github
YOLOF-R101-DC5_1x 800,1333 github
YOLOF-RT-R50_3x 512,736 60 39.4 58.6 github

Limited by my computing resources, I cannot train YOLOF_R101_C5_1x, YOLOF_R101_DC5_1x. I would be very grateful if you used this project to train them and would like to share weight files.

  • Visualization

(YOLOF_R50-C5_1x)

image

  • AP results of FCOS
Model scale FPS AP AP50 Weight
FCOS-R18_1x 800,1333 42 33.0 51.3 github
FCOS-R50_1x 800,1333 30 38.2 58.0 github
FCOS-RT-R18_4x 512,736 83 33.8 51.5 github
FCOS-RT-R50_4x 512,736 60 38.7 58.0 github
FCOS-RT-R18-OTA_4x 512,736
FCOS-RT-R50-OTA_4x 512,736

FCOS-RT-R18-OTA_4x means that we use the SimOTA to train the FCOS-RT-R18.

  • AP results of RetiniaNet
Model scale FPS AP AP50 Weight
RetinaNet-R18_1x 800,1333 30.8 49.6 github
RetinaNet-R50_1x 800,1333
RetinaNet-RT-R18_4x 512,736
RetinaNet-RT-R50_4x 512,736

Train

  • Single GPU

You can run the following command:

python train.py \
        --cuda \
        -d coco \
        --root /mnt/share/ssd2/dataset/ \
        -v yolof-r50 \
        --batch_size 16 \
        --schedule 1x \
        --grad_clip_norm 4.0 \

or, you just run the script:

sh train.sh

You can change the configurations of train.sh, according to your own situation.

  • Multi GPUs

You can run the following command:

# 2 GPUs
python -m torch.distributed.run --nproc_per_node=2 train.py \
                                                    --cuda \
                                                    -dist \
                                                    -d coco \
                                                    --root /mnt/share/ssd2/dataset/ \
                                                    -v yolof-r50 \
                                                    --batch_size 8 \
                                                    --grad_clip_norm 4.0 \
                                                    --num_workers 4 \
                                                    --schedule 1x \

or, you just run the script:

sh train_ddp.sh

Test

python test.py -d coco \
               --cuda \
               -v yolof-r50 \
               --weight path/to/weight \
               --root path/to/dataset/ \
               --show

Evaluate

python eval.py -d coco-val \
               --cuda \
               -v yolof-r50 \
               --weight path/to/weight \
               --root path/to/dataset/ \

Our AP results of YOLOF-R50-C5-1x on COCO-val:

Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.375
Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.574
Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.399
Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.185
Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.421
Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.522
Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.312
Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.507
Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.552
Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.332
Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.625
Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.739

Demo

I have provide some images in data/demo/images/, so you can run following command to run a demo:

python demo.py --mode image \
               --path_to_img data/demo/images/ \
               -v yolof-r50 \
               --cuda \
               --weight path/to/weight \
               --show

If you want run a demo of streaming video detection, you need to set --mode to video, and give the path to video --path_to_vid

python demo.py --mode video \
               --path_to_img data/demo/videos/your_video \
               -v yolof-r50 \
               --cuda \
               --weight path/to/weight \
               --show

If you want run video detection with your camera, you need to set --mode to camera

python demo.py --mode camera \
               -v yolof-r50 \
               --cuda \
               --weight path/to/weight \
               --show

About

A PyTorch version of You Only Look at One-level Feature object detector

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •