YOLOX-Paddle - A reproduction of YOLOX by PaddlePaddle

Overview

YOLOX-Paddle

A reproduction of YOLOX by PaddlePaddle

数据集准备

下载COCO数据集,准备为如下路径

/home/aistudio
|-- COCO
|   |-- annotions
|   |-- train2017
|   |-- val2017

除了常用的图像处理库,需要安装额外的包

pip install gputil==1.4.0 loguru pycocotools

进入仓库根目录,编译安装(推荐使用AIStudio

cd YOLOX-Paddle
pip install -v -e .

如果使用本地机器出现编译失败,需要修改YOLOX-Paddle/yolox/layers/csrc/cocoeval/cocoeval.h中导入pybind11的include文件为本机目录,使用如下命令获取pybind11include目录

>>> import pybind11
>>> pybind11.get_include()
'/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/pybind11/include'

AIStudio路径

#include </opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/pybind11/include/pybind11/numpy.h>
#include </opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/pybind11/include/pybind11/pybind11.h>
#include </opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/pybind11/include/pybind11/stl.h>
#include </opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/pybind11/include/pybind11/stl_bind.h>

成功后使用pip list可看到安装模块

yolox    0.1.0    /home/aistudio/YOLOX-Paddle

设置YOLOX_DATADIR环境变量\或者`ln -s /path/to/your/COCO ./datasets/COCO`来指定COCO数据集位置

export YOLOX_DATADIR=/home/aistudio/

训练

python tools/train.py -n yolox-nano -d 1 -b 64

得到的权重保存至./YOLOX_outputs/nano/yolox_nano.pdparams

验证

python tools/eval.py -n yolox-nano -c ./YOLOX_outputs/nano/yolox_nano.pdparams -b 64 -d 1 --conf 0.001
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.259
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.416
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.269
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.083
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.274
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.413
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.242
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.384
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.419
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.154
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.470
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.632

并提供了官方预训练权重,code:ybxc

Model size mAPval
0.5:0.95
mAPtest
0.5:0.95
Speed V100
(ms)
Params
(M)
FLOPs
(G)
YOLOX-s 640 40.5 40.5 9.8 9.0 26.8
YOLOX-m 640 46.9 47.2 12.3 25.3 73.8
YOLOX-l 640 49.7 50.1 14.5 54.2 155.6
YOLOX-x 640 51.1 51.5 17.3 99.1 281.9
YOLOX-Darknet53 640 47.7 48.0 11.1 63.7 185.3

推理

python tools/demo.py image -n yolox-nano -c ./YOLOX_outputs/nano/yolox_nano.pdparams --path assets/dog.jpg --conf 0.25 --nms 0.45 --tsize 640 --save_result

推理结果如下所示

Train Custom Data

相信这是大部分开发者最关心的事情,本章节参考如下仓库,本仓库现已集成

  • Converting darknet or yolov5 datasets to COCO format for YOLOX: YOLO2COCO from Daniel

数据准备

我们同样以YOLOv5格式的光栅数据集为例,可在此处下载 进入仓库根目录,下载解压,数据集应该具有如下目录:

YOLOX-Paddle
|-- guangshan
|   |-- images
|      |-- train
|      |-- val
|   |-- labels
|      |-- train
|      |-- val

现在运行如下命令

bash prepare.sh

然后添加一个classes.txt,你应该得到如下目录,并在生成的YOLOV5_COCO_format得到COCO数据格式的数据集:

YOLOX-Paddle/YOLO2COCO/dataset
|-- YOLOV5
|   |-- guangshan
|   |   |-- images
|   |   |-- labels
|   |-- train.txt
|   |-- val.txt
|   |-- classes.txt
|-- YOLOV5_COCO_format
|   |-- train2017
|   |-- val2017
|   |-- annotations

可参考YOLOV5_COCO_format下的README.md

训练、验证、推理

配置custom训练文件YOLOX-Paddle/exps/example/custom/nano.py,修改self.num_classes为你的类别数,其余配置可根据喜好调参,使用如下命令启动训练

python tools/train.py -f ./exps/example/custom/nano.py -n yolox-nano -d 1 -b 8

使用如下命令启动验证

python tools/eval.py -f ./exps/example/custom/nano.py -n yolox-nano -c ./YOLOX_outputs_custom/nano/best_ckpt.pdparams -b 64 -d 1 --conf 0.001

使用如下命令启动推理

python tools/demo.py image -f ./exps/example/custom/nano.py -n yolox-nano -c ./YOLOX_outputs_custom/nano/best_ckpt.pdparams --path test.jpg --conf 0.25 --nms 0.45 --tsize 640 --save_result

其余部分参考COCO数据集,整个训练文件保存在YOLOX_outputs_custom文件夹

关于作者

姓名 郭权浩
学校 电子科技大学研2020级
研究方向 计算机视觉
CSDN主页 Deep Hao的CSDN主页
GitHub主页 Deep Hao的GitHub主页
如有错误,请及时留言纠正,非常蟹蟹!
后续会有更多论文复现系列推出,欢迎大家有问题留言交流学习,共同进步成长!
You might also like...
SplineConv implementation for Paddle.

SplineConv implementation for Paddle This module implements the SplineConv operators from Matthias Fey, Jan Eric Lenssen, Frank Weichert, Heinrich Mül

Sparse-dense operators implementation for Paddle

Sparse-dense operators implementation for Paddle This module implements coo, csc and csr matrix formats and their inter-ops with dense matrices. Feel

Paddle pit - Rethinking Spatial Dimensions of Vision Transformers
Paddle pit - Rethinking Spatial Dimensions of Vision Transformers

基于Paddle实现PiT ——Rethinking Spatial Dimensions of Vision Transformers,arxiv 官方原版代

Paddle-Skeleton-Based-Action-Recognition - DecoupleGCN-DropGraph, ASGCN, AGCN, STGCN

Paddle-Skeleton-Action-Recognition DecoupleGCN-DropGraph, ASGCN, AGCN, STGCN. Yo

A  pytorch reproduction of { Co-occurrence Feature Learning from Skeleton Data for Action Recognition and Detection with Hierarchical Aggregation }.
A pytorch reproduction of { Co-occurrence Feature Learning from Skeleton Data for Action Recognition and Detection with Hierarchical Aggregation }.

A PyTorch Reproduction of HCN Co-occurrence Feature Learning from Skeleton Data for Action Recognition and Detection with Hierarchical Aggregation. Ch

Reproduction process of AlexNet

PaddlePaddle论文复现杂谈 背景 注:该repo基于PaddlePaddle,对AlexNet进行复现。时间仓促,难免有所疏漏,如果问题或者想法,欢迎随时提issue一块交流。 飞桨论文复现赛地址:https://aistudio.baidu.com/aistudio/competitio

Mae segmentation - Reproduction of semantic segmentation using masked autoencoder (mae)

ADE20k Semantic segmentation with MAE Getting started Install the mmsegmentation

Object detection and instance segmentation toolkit based on PaddlePaddle.
Object detection and instance segmentation toolkit based on PaddlePaddle.

Object detection and instance segmentation toolkit based on PaddlePaddle.

A PaddlePaddle version image model zoo.

Paddle-Image-Models English | 简体中文 A PaddlePaddle version image model zoo. Install Package Install by pip: $ pip install ppim Install by wheel package

Owner
QuanHao Guo
Master at UESTC
QuanHao Guo
Classical OCR DCNN reproduction based on PaddlePaddle framework.

Paddle-SVHN Classical OCR DCNN reproduction based on PaddlePaddle framework. This project reproduces Multi-digit Number Recognition from Street View I

null 1 Nov 12, 2021
YOLOv5🚀 reproduction by Guo Quanhao using PaddlePaddle

YOLOv5-Paddle YOLOv5 ?? reproduction by Guo Quanhao using PaddlePaddle 支持AutoBatch 支持AutoAnchor 支持GPU Memory 快速开始 使用AIStudio高性能环境快速构建YOLOv5训练(PaddlePa

QuanHao Guo 20 Nov 14, 2022
YOLOX-CondInst - Implement CondInst which is a instances segmentation method on YOLOX

YOLOX CondInst -- YOLOX 实例分割 前言 本项目是自己学习实例分割时,复现的代码. 通过自己编程,让自己对实例分割有更进一步的了解。 若想

DDGRCF 16 Nov 18, 2022
Yolox-bytetrack-sample - Python sample of MOT (Multiple Object Tracking) using YOLOX and ByteTrack

yolox-bytetrack-sample YOLOXとByteTrackを用いたMOT(Multiple Object Tracking)のPythonサン

KazuhitoTakahashi 12 Nov 9, 2022
PaddleRobotics is an open-source algorithm library for robots based on Paddle, including open-source parts such as human-robot interaction, complex motion control, environment perception, SLAM positioning, and navigation.

简体中文 | English PaddleRobotics paddleRobotics是基于paddle的机器人开源算法库集,包括人机交互、复杂运动控制、环境感知、slam定位导航等开源算法部分。 人机交互 主动多模交互技术TFVT-HRI 主动多模交互技术是通过视觉、语音、触摸传感器等输入机器人

null 185 Dec 26, 2022
用强化学习DQN算法,训练AI模型来玩合成大西瓜游戏,提供Keras版本和PARL(paddle)版本

用强化学习玩合成大西瓜 代码地址:https://github.com/Sharpiless/play-daxigua-using-Reinforcement-Learning 用强化学习DQN算法,训练AI模型来玩合成大西瓜游戏,提供Keras版本、PARL(paddle)版本和pytorch版本

null 72 Dec 17, 2022
Paddle implementation for "Highly Efficient Knowledge Graph Embedding Learning with Closed-Form Orthogonal Procrustes Analysis" (NAACL 2021)

ProcrustEs-KGE Paddle implementation for Highly Efficient Knowledge Graph Embedding Learning with Orthogonal Procrustes Analysis ?? A more detailed re

Lincedo Lab 4 Jun 9, 2021
Paddle implementation for "Cross-Lingual Word Embedding Refinement by ℓ1 Norm Optimisation" (NAACL 2021)

L1-Refinement Paddle implementation for "Cross-Lingual Word Embedding Refinement by ℓ1 Norm Optimisation" (NAACL 2021) ?? A more detailed readme is co

Lincedo Lab 4 Jun 9, 2021
x-transformers-paddle 2.x version

x-transformers-paddle x-transformers-paddle 2.x version paddle 2.x版本 https://github.com/lucidrains/x-transformers 。 requirements paddlepaddle-gpu==2.2

yujun 7 Dec 8, 2022
This is the paddle code for SeBoW(Self-Born wiring for neural trees), a kind of neural tree born form a large search space

SeBoW: Self-Born Wiring for neural trees(PaddlePaddle version) This is the paddle code for SeBoW(Self-Born wiring for neural trees), a kind of neural

HollyLee 13 Dec 8, 2022