YOLOv5🚀 reproduction by Guo Quanhao using PaddlePaddle

Overview

YOLOv5-Paddle

YOLOv5 🚀 reproduction by Guo Quanhao using PaddlePaddle

Readme Card

  • 支持AutoBatch
  • 支持AutoAnchor
  • 支持GPU Memory

快速开始

使用AIStudio高性能环境快速构建YOLOv5训练(PaddlePaddle2.2.0-gpu version)

需要安装额外模块

pip install gputil==1.4.0
pip install pycocotools
COCO数据集

数据集已挂载至aistudio项目中,如果需要本地训练可以从这里下载数据集,和标签文件

Data
|-- coco
|   |-- annotions
|   |-- images
|      |-- train2017
|      |-- val2017
|      |-- test2017
|   |-- labels
|      |-- train2017
|      |-- val2017
|      |-- train2017.cache(初始解压可删除,训练时会自动生成)
|      |-- val2017.cache(初始解压可删除,训练时会自动生成)
|   |-- test-dev2017.txt
|   |-- val2017.txt
|   |-- train2017.txt
`   `-- validation

修改data/coco.yaml配置自己的coco路径,你可能需要修改path变量

path: /home/aistudio/Data/coco  # dataset root dir

训练

  • 考虑到AIStudio对于github的访问速度,预先提供了Arial.ttf

  • AIStudio后端不支持绘图,部分可视乎在AIStudio仓库被注释

training scratch for coco

mkdir /home/aistudio/.config/QuanhaoGuo/
cp /home/aistudio/Arial.ttf /home/aistudio/.config/QuanhaoGuo/
cd YOLOv5-Paddle
python train.py --img 896 --batch 8 --epochs 300 --data ./data/coco.yaml --cfg yolov5s.yaml --weights ''

验证

python val.py --img 640  --data ./data/coco.yaml --weights ./weights/yolov5s.pdparams --cfg yolov5s.yaml

通过--task [val/test]控制验证集和测试集

所有提供的模型验证精度如下,本仓库的所有资源文件包括预训练模型均可在百度云盘下载code:dng9

Model size
(pixels)
mAPval
0.5:0.95
mAPval
0.5
params
(M)
FLOPs
@640 (B)
mAPtest
0.5:0.95
mAPtest
0.5
YOLOv5n 640 28.4 46.5 1.9 4.5 28.1 46.2
YOLOv5s 640 37.2 56.4 7.2 16.5 37.1 56.1
YOLOv5m 640 45.1 64.2 21.2 49.0 45.4 64.3
YOLOv5l 640 48.6 67.4 46.5 109.1 48.9 67.5
YOLOv5x 640 50.6 69.1 86.7 205.7 0.507 0.690
YOLOv5n6 1280 34.0 51.1 3.2 4.6 34.3 51.7
YOLOv5s6 1280 44.5 63.4 16.8 12.6 44.3 63.0
YOLOv5m6 1280 50.9 69.4 35.7 50.0 51.1 69.5
YOLOv5l6 1280 53.5 71.8 76.8 111.4 53.7 71.8
YOLOv5x6
+ [TTA][TTA]
1280
1536
54.6
55.2
72.6
73.0
140.7
-
209.8
-
55.0
55.8
73.0
73.5

使用本地环境快速构建YOLOv5训练(PaddlePaddle2.2.0-gpu version)

git clone https://github.com/GuoQuanhao/YOLOv5-Paddle

然后按照使用AIStudio高性能环境快速构建YOLOv5训练执行

训练Custom Data

这里以一个类别的光栅数据集为例,数据集已上传至AIStudio

其组织结构如下:

Data
|-- guangshan
|   |-- images
|      |-- train
|      |-- val
|   |-- labels
|      |-- train
|      |-- val
|   |-- val.txt
|   |-- train.txt

另外你需要构建data/guangshan.yaml,相关文件已放入相关目录,主要用于指定数据集读取路径和模型配置。

# YOLOv5 reproduction 🚀 by GuoQuanhao

train: /home/aistudio/guangshan/images/train  # 118287 images
val: /home/aistudio/guangshan/images/val  # 5000 images
# number of classes
nc: 1
# class names
names: ['spectrum']

训练

python train.py --img 640 --batch 16 --epochs 100 --data ./data/guangshan.yaml --cfg yolov5s.yaml --weights ./weights/yolov5s.pdparams
Starting training for 100 epochs...

     Epoch   gpu_mem       box       obj       cls    labels  img_size
      0/99     4.19G    0.1039   0.04733         0        29       640: 100%|████████████████████████████████████████████████████████████████████| 9/9 [01:43<00:00, 11.50s/it]
               Class     Images     Labels          P          R     [email protected] [email protected]:.95: 100%|████████████████████████████████████████████████████| 1/1 [00:06<00:00,  6.64s/it]
                 all         16         29      0.266      0.379      0.226     0.0468

     Epoch   gpu_mem       box       obj       cls    labels  img_size
      1/99     4.41G   0.08177    0.0289         0        37       640: 100%|████████████████████████████████████████████████████████████████████| 9/9 [01:40<00:00, 11.20s/it]
               Class     Images     Labels          P          R     [email protected] [email protected]:.95: 100%|████████████████████████████████████████████████████| 1/1 [00:05<00:00,  5.49s/it]
                 all         16         29      0.462      0.445      0.398      0.109
......

完整的训练日志存在data/training.txt

利用VisualDL可视化训练过程

visualdl --logdir ./runs/train/exp

验证

python val.py --img 640  --data ./data/guangshan.yaml --cfg yolov5s.yaml --weights ./runs/train/exp/weights/best.pdparams

推理

python detect.py --weights ./runs/train/exp/weights/best.pdparams --cfg yolov5s.yaml --data ./data/guangshan.yaml --source ./data/images/guangshan.jpg

TODO

  • Multi-GPU Training ☘️
  • PaddleLite inference 🌟
  • Model to ONNX

关于作者

姓名 郭权浩
学校 电子科技大学研2020级
研究方向 计算机视觉
主页 Deep Hao的主页
github Deep Hao的github
如有错误,请及时留言纠正,非常蟹蟹!
后续会有更多论文复现系列推出,欢迎大家有问题留言交流学习,共同进步成长!
You might also like...
Torchserve server using a YoloV5 model running on docker with GPU and static batch inference to perform production ready inference.
Torchserve server using a YoloV5 model running on docker with GPU and static batch inference to perform production ready inference.

Yolov5 running on TorchServe (GPU compatible) ! This is a dockerfile to run TorchServe for Yolo v5 object detection model. (TorchServe (PyTorch librar

Drone detection using YOLOv5
Drone detection using YOLOv5

This drone detection system uses YOLOv5 which is a family of object detection architectures and we have trained the model on Drone Dataset. Overview I

Add gui for YoloV5 using PyQt5
Add gui for YoloV5 using PyQt5

HEAD 更新2021.08.16 **添加图片和视频保存功能: 1.图片和视频按照当前系统时间进行命名 2.各自检测结果存放入output文件夹 3.摄像头检测的默认设备序号更改为0,减少调试报错 温馨提示: 1.项目放置在全英文路径下,防止项目报错 2.默认使用cpu进行检测,自

A program to recognize fruits on pictures or videos using yolov5
A program to recognize fruits on pictures or videos using yolov5

Yolov5 Fruits Detector Requirements Either Linux or Windows. We recommend Linux for better performance. Python 3.6+ and PyTorch 1.7+. Installation To

Various operations like path tracking, counting, etc by using yolov5

Object-tracing-with-YOLOv5 Various operations like path tracking, counting, etc by using yolov5

FaceAnon - Anonymize people in images and videos using yolov5-crowdhuman
FaceAnon - Anonymize people in images and videos using yolov5-crowdhuman

Face Anonymizer Blur faces from image and video files in /input/ folder. Require

Yolov5-opencv-cpp-python - Example of using ultralytics YOLO V5 with OpenCV 4.5.4, C++ and Python
Yolov5-opencv-cpp-python - Example of using ultralytics YOLO V5 with OpenCV 4.5.4, C++ and Python

yolov5-opencv-cpp-python Example of performing inference with ultralytics YOLO V

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

Comments
  • train相关问题

    train相关问题

    作者您好,我在使用您的数据集训练YOLOv5n模型时,出现一个警告: Epoch gpu_mem box obj cls labels img_size 1/99 1.94G 0.09787 0.5162 0 679 640: 100%|███████████████████████████████████████████████████████████████████████| 57/57 [04:48<00:00, 5.05s/it] Class Images Labels P R [email protected] [email protected]:.95: 25%|██████████████▎ | 1/4 [00:17<00:53, 17.96s/it]/mnt/YOLOv5-Paddle-main/utils/loss.py:191: RuntimeWarning: divide by zero encountered in true_divide j = np.maximum(r, 1 / r).max(2) < self.hyp['anchor_t'] # compare Class Images Labels P R [email protected] [email protected]:.95: 100%|█████████████████████████████████████████████████████████| 4/4 [00:50<00:00, 12.56s/it] all 50 7742 0.571 0.664 0.579 0.188

    训练集为450,验证集为50,训练的目标只有一类“钢筋” (label: rebar) 想问一下会影响后续的部署使用吗?

    opened by qiujianchen 0
  • resume掉精度问题该怎么解决呢?

    resume掉精度问题该怎么解决呢?

    您好,我在使用您的代码时发现--resume时精度会下降,并且可能需要训练一些epoch才能恢复到之前的精度,请问该如何做才能做到resume时不掉精度呢(因为AIstudio的GPU每天只有8点算力卡,我所使用的数据集训练一个epoch需要一个小时,只能通过resume来完成整个训练过程) image

    图中的第一个39-45是直接resume的结果

    图中的第二个39-48是我认为之前训练时x['learning_rate']和x['momentum']存在,所以尝试在训练开始前给它们赋上warmup结束时的值,但发现效果并未达到预期 for j, x in enumerate(optimizer._param_groups): x['learning_rate'] = np.interp(nw, [0, nw], [hyp['warmup_bias_lr'] if j == 2 else 0.0, scheduler.base_lr * lf(epoch)]) if 'momentum' in x: x['momentum'] = np.interp(nw, [0, nw], [hyp['warmup_momentum'], hyp['momentum']])

    希望能得到您的帮助,谢谢!

    opened by diaoa1900 0
  • ai studio绘图问题

    ai studio绘图问题

    对比了yolov5的源码,绘图部分应该不是ai studio不支持的原因,而是在metrics.py的plot_pr_curve(px, py, ap, save_dir='pr_curve.png', names=())函数中,for i, y in enumerate(py.t())编写错误,修改为for i, y in enumerate(py.T)后可以正确绘制PR图

    opened by misaka-network10032 0
Owner
QuanHao Guo
Master at UESTC
QuanHao Guo
给yolov5加个gui界面,使用pyqt5,yolov5是5.0版本

博文地址 https://xugaoxiang.com/2021/06/30/yolov5-pyqt5 代码执行 项目中使用YOLOv5的v5.0版本,界面文件是project.ui pip install -r requirements.txt python main.py 图片检测 视频检测

Xu GaoXiang 215 Dec 30, 2022
Parallel Latent Tree-Induction for Faster Sequence Encoding

FastTrees This repository contains the experimental code supporting the FastTrees paper by Bill Pung. Software Requirements Python 3.6, NLTK and PyTor

Bill Pung 4 Mar 29, 2022
Unofficial pytorch implementation of paper "One-Shot Free-View Neural Talking-Head Synthesis for Video Conferencing"

One-Shot Free-View Neural Talking Head Synthesis Unofficial pytorch implementation of paper "One-Shot Free-View Neural Talking-Head Synthesis for Vide

ZLH 406 Dec 23, 2022
A Large Scale Benchmark for Individual Treatment Effect Prediction and Uplift Modeling

large-scale-ITE-UM-benchmark This repository contains code and data to reproduce the results of the paper "A Large Scale Benchmark for Individual Trea

10 Nov 19, 2022
Demonstrational Session git repo for H SAF User Workshop (28/1)

5th H SAF User Workshop The 5th H SAF User Workshop supported by EUMeTrain will be held in online in January 24-28 2022. This repository contains inst

H SAF 4 Aug 04, 2022
EMNLP'2021: Simple Entity-centric Questions Challenge Dense Retrievers

EntityQuestions This repository contains the EntityQuestions dataset as well as code to evaluate retrieval results from the the paper Simple Entity-ce

Princeton Natural Language Processing 119 Sep 28, 2022
Machine Learning University: Accelerated Computer Vision Class

Machine Learning University: Accelerated Computer Vision Class This repository contains slides, notebooks, and datasets for the Machine Learning Unive

AWS Samples 1.3k Dec 28, 2022
Ludwig is a toolbox that allows to train and evaluate deep learning models without the need to write code.

Translated in 🇰🇷 Korean/ Ludwig is a toolbox that allows users to train and test deep learning models without the need to write code. It is built on

Ludwig 8.7k Jan 05, 2023
Unified tracking framework with a single appearance model

Paper: Do different tracking tasks require different appearance model? [ArXiv] (comming soon) [Project Page] (comming soon) UniTrack is a simple and U

ZhongdaoWang 300 Dec 24, 2022
Discerning Decision-Making Process of Deep Neural Networks with Hierarchical Voting Transformation

Configurations Change HOME_PATH in CONFIG.py as the current path Data Prepare CENSINCOME Download data Put census-income.data and census-income.test i

2 Aug 14, 2022
SEOVER: Sentence-level Emotion Orientation Vector based Conversation Emotion Recognition Model

SEOVER-Master This code is the implementation of paper: SEOVER: Sentence-level Emotion Orientation Vector based Conversation Emotion Recognition Model

4 Feb 24, 2022
Official implementation of EdiTTS: Score-based Editing for Controllable Text-to-Speech

EdiTTS: Score-based Editing for Controllable Text-to-Speech Official implementation of EdiTTS: Score-based Editing for Controllable Text-to-Speech. Au

Neosapience 98 Dec 25, 2022
PyTorch code of "SLAPS: Self-Supervision Improves Structure Learning for Graph Neural Networks"

SLAPS-GNN This repo contains the implementation of the model proposed in SLAPS: Self-Supervision Improves Structure Learning for Graph Neural Networks

60 Dec 22, 2022
A simple consistency training framework for semi-supervised image semantic segmentation

PseudoSeg: Designing Pseudo Labels for Semantic Segmentation PseudoSeg is a simple consistency training framework for semi-supervised image semantic s

Google Interns 143 Dec 13, 2022
fastgradio is a python library to quickly build and share gradio interfaces of your trained fastai models.

fastgradio is a python library to quickly build and share gradio interfaces of your trained fastai models.

Ali Abdalla 34 Jan 05, 2023
Contra is a lightweight, production ready Tensorflow alternative for solving time series prediction challenges with AI

Contra AI Engine A lightweight, production ready Tensorflow alternative developed by Styvio styvio.com » How to Use · Report Bug · Request Feature Tab

styvio 14 May 25, 2022
PyTorch implementation code for the paper MixCo: Mix-up Contrastive Learning for Visual Representation

How to Reproduce our Results This repository contains PyTorch implementation code for the paper MixCo: Mix-up Contrastive Learning for Visual Represen

opcrisis 46 Dec 15, 2022
This is a Keras implementation of a CNN for estimating age, gender and mask from a camera.

face-detector-age-gender This is a Keras implementation of a CNN for estimating age, gender and mask from a camera. Before run face detector app, expr

Devdreamsolution 2 Dec 04, 2021
CAPITAL: Optimal Subgroup Identification via Constrained Policy Tree Search

CAPITAL: Optimal Subgroup Identification via Constrained Policy Tree Search This repository is the official implementation of CAPITAL: Optimal Subgrou

Hengrui Cai 0 Oct 19, 2021