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
🛠 All-in-one web-based IDE specialized for machine learning and data science.

All-in-one web-based development environment for machine learning Getting Started • Features & Screenshots • Support • Report a Bug • FAQ • Known Issu

Machine Learning Tooling 2.9k Jan 09, 2023
Fast mesh denoising with data driven normal filtering using deep variational autoencoders

Fast mesh denoising with data driven normal filtering using deep variational autoencoders This is an implementation for the paper entitled "Fast mesh

9 Dec 02, 2022
Code release for the paper “Worldsheet Wrapping the World in a 3D Sheet for View Synthesis from a Single Image”, ICCV 2021.

Worldsheet: Wrapping the World in a 3D Sheet for View Synthesis from a Single Image This repository contains the code for the following paper: R. Hu,

Meta Research 37 Jan 04, 2023
Code for AutoNL on ImageNet (CVPR2020)

Neural Architecture Search for Lightweight Non-Local Networks This repository contains the code for CVPR 2020 paper Neural Architecture Search for Lig

Yingwei Li 104 Aug 31, 2022
DFM: A Performance Baseline for Deep Feature Matching

DFM: A Performance Baseline for Deep Feature Matching Python (Pytorch) and Matlab (MatConvNet) implementations of our paper DFM: A Performance Baselin

143 Jan 02, 2023
Geometric Vector Perceptron --- a rotation-equivariant GNN for learning from biomolecular structure

Geometric Vector Perceptron Code to accompany Learning from Protein Structure with Geometric Vector Perceptrons by B Jing, S Eismann, P Suriana, RJL T

Dror Lab 85 Dec 29, 2022
PyTorch implementation of the Quasi-Recurrent Neural Network - up to 16 times faster than NVIDIA's cuDNN LSTM

Quasi-Recurrent Neural Network (QRNN) for PyTorch Updated to support multi-GPU environments via DataParallel - see the the multigpu_dataparallel.py ex

Salesforce 1.3k Dec 28, 2022
Code for "Optimizing risk-based breast cancer screening policies with reinforcement learning"

Tempo: Optimizing risk-based breast cancer screening policies with reinforcement learning Introduction This repository was used to develop Tempo, as d

Adam Yala 12 Oct 11, 2022
Code and models for "Pano3D: A Holistic Benchmark and a Solid Baseline for 360 Depth Estimation", OmniCV Workshop @ CVPR21.

Pano3D A Holistic Benchmark and a Solid Baseline for 360o Depth Estimation Pano3D is a new benchmark for depth estimation from spherical panoramas. We

Visual Computing Lab, Information Technologies Institute, Centre for Reseach and Technology Hellas 50 Dec 29, 2022
Attentive Implicit Representation Networks (AIR-Nets)

Attentive Implicit Representation Networks (AIR-Nets) Preprint | Supplementary | Accepted at the International Conference on 3D Vision (3DV) teaser.mo

29 Dec 07, 2022
Code for the paper "Spatio-temporal Self-Supervised Representation Learning for 3D Point Clouds" (ICCV 2021)

Spatio-temporal Self-Supervised Representation Learning for 3D Point Clouds This is the official code implementation for the paper "Spatio-temporal Se

Hesper 63 Jan 05, 2023
Beginner-friendly repository for Hacktober Fest 2021. Start your contribution to open source through baby steps. 💜

Hacktober Fest 2021 🎉 Open source is changing the world – one contribution at a time! 🎉 This repository is made for beginners who are unfamiliar wit

Abhilash M Nair 32 Dec 11, 2022
MVFNet: Multi-View Fusion Network for Efficient Video Recognition (AAAI 2021)

MVFNet: Multi-View Fusion Network for Efficient Video Recognition (AAAI 2021) Overview We release the code of the MVFNet (Multi-View Fusion Network).

2 Jan 29, 2022
Pywonderland - A tour in the wonderland of math with python.

A Tour in the Wonderland of Math with Python A collection of python scripts for drawing beautiful figures and animating interesting algorithms in math

Zhao Liang 4.1k Jan 03, 2023
Establishing Strong Baselines for TripClick Health Retrieval; ECIR 2022

TripClick Baselines with Improved Training Data Welcome 🙌 to the hub-repo of our paper: Establishing Strong Baselines for TripClick Health Retrieval

Sebastian Hofstätter 3 Nov 03, 2022
Automatic caption evaluation metric based on typicality analysis.

SeMantic and linguistic UndeRstanding Fusion (SMURF) Automatic caption evaluation metric described in the paper "SMURF: SeMantic and linguistic UndeRs

Joshua Feinglass 6 Jan 09, 2022
Code for Learning to Segment The Tail (LST)

Learning to Segment the Tail [arXiv] In this repository, we release code for Learning to Segment The Tail (LST). The code is directly modified from th

47 Nov 07, 2022
A modular framework for vision & language multimodal research from Facebook AI Research (FAIR)

MMF is a modular framework for vision and language multimodal research from Facebook AI Research. MMF contains reference implementations of state-of-t

Facebook Research 5.1k Jan 04, 2023
Deep generative models of 3D grids for structure-based drug discovery

What is liGAN? liGAN is a research codebase for training and evaluating deep generative models for de novo drug design based on 3D atomic density grid

Matt Ragoza 152 Jan 03, 2023
Code for Parameter Prediction for Unseen Deep Architectures (NeurIPS 2021)

Parameter Prediction for Unseen Deep Architectures (NeurIPS 2021) authors: Boris Knyazev, Michal Drozdzal, Graham Taylor, Adriana Romero-Soriano Overv

Facebook Research 462 Jan 03, 2023