Code Monkey home page Code Monkey logo

pytorch_yolof's Introduction

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

pytorch_yolof's People

Contributors

guohanli avatar hit-k544 avatar yjh0410 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

Watchers

 avatar  avatar

pytorch_yolof's Issues

标签生成函数写得有问题

源码中的标签生成逻辑是:
1.利用预测框与gt的l1距离筛选出topk个锚点,再利用锚点与gt的l1距离筛选出topk个锚点,将之作为预选正例锚点。
2.将预选正例锚点依据iou与gt匹配,滤除与锚点iou小于0.15的预选正例锚点
3.将gt与预测框iou<=0.7的预测框对应锚点设置为负例锚点
(而您只用了锚点,没有预选,也没用预测框)

regarding training

if I want to do custom training. should I mark each and every human in a frame with some class label? in my case (suppose try to build a running action detection), in every frame, there are 5-10 people. but only 1-2 are running. should I annotate others also?

您好,

请问是否只能在训练过程中计算mAP,如何只在测试中计算mAP呢,谢谢

请问如何训练自己的数据集?

我按照yolov5的提示,将数据集转换为了COCO格式,但是是这样的目录:
RSOD

  • images
    - train2017
    - val2017
    - test2017
  • lables
    - train2017
    - val2017
    - test2017

请教一下pascal voc上的结果

大佬你好,我自己也复现了一下YOLOF,但我是在tf上写的,然后在pascal voc07上训练,然后测试的ap0.5只有0.66左右,这个结果是远远低于retinanet(0.7左右)的,甚至比FCOS还低(0.68左右),所以想问下你有在voc上做过实验吗,然后结果咋样呢

demo时卡顿

image

可视化文件夹图像时,只能检测一张,便卡顿无反应了,应当如何解决?

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.