All Projects → HaloTrouvaille → Yolo Multi Backbones Attention

HaloTrouvaille / Yolo Multi Backbones Attention

Model Compression—YOLOv3 with multi lightweight backbones(ShuffleNetV2 HuaWei GhostNet), attention, prune and quantization

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Yolo Multi Backbones Attention

Anpr
licence plate detection and recognition
Stars: ✭ 277 (-12.62%)
Mutual labels:  yolo
Attention is all you need
Transformer of "Attention Is All You Need" (Vaswani et al. 2017) by Chainer.
Stars: ✭ 303 (-4.42%)
Mutual labels:  attention-mechanism
Seq2seq chatbot
基于seq2seq模型的简单对话系统的tf实现,具有embedding、attention、beam_search等功能,数据集是Cornell Movie Dialogs
Stars: ✭ 308 (-2.84%)
Mutual labels:  attention-mechanism
Multi Scale Attention
Code for our paper "Multi-scale Guided Attention for Medical Image Segmentation"
Stars: ✭ 281 (-11.36%)
Mutual labels:  attention-mechanism
Yolo Pytorch
YOLO for object detection tasks
Stars: ✭ 301 (-5.05%)
Mutual labels:  yolo
Alphafold2
To eventually become an unofficial Pytorch implementation / replication of Alphafold2, as details of the architecture get released
Stars: ✭ 298 (-5.99%)
Mutual labels:  attention-mechanism
Object Detection Api Tensorflow
Object Detection API Tensorflow
Stars: ✭ 267 (-15.77%)
Mutual labels:  yolo
Deep Sort Yolov4
People detection and optional tracking with Tensorflow backend.
Stars: ✭ 306 (-3.47%)
Mutual labels:  yolo
Yolo V2 Pytorch
YOLO for object detection tasks
Stars: ✭ 302 (-4.73%)
Mutual labels:  yolo
Tensorflow end2end speech recognition
End-to-End speech recognition implementation base on TensorFlow (CTC, Attention, and MTL training)
Stars: ✭ 305 (-3.79%)
Mutual labels:  attention-mechanism
Vit Pytorch
Implementation of Vision Transformer, a simple way to achieve SOTA in vision classification with only a single transformer encoder, in Pytorch
Stars: ✭ 7,199 (+2170.98%)
Mutual labels:  attention-mechanism
Yolov3v4 Modelcompression Multidatasettraining Multibackbone
YOLO ModelCompression MultidatasetTraining
Stars: ✭ 287 (-9.46%)
Mutual labels:  yolo
Seq2seq Summarizer
Pointer-generator reinforced seq2seq summarization in PyTorch
Stars: ✭ 306 (-3.47%)
Mutual labels:  attention-mechanism
Timesformer Pytorch
Implementation of TimeSformer from Facebook AI, a pure attention-based solution for video classification
Stars: ✭ 225 (-29.02%)
Mutual labels:  attention-mechanism
Alturos.yolo
C# Yolo Darknet Wrapper (real-time object detection)
Stars: ✭ 308 (-2.84%)
Mutual labels:  yolo
Transformer
A Pytorch Implementation of "Attention is All You Need" and "Weighted Transformer Network for Machine Translation"
Stars: ✭ 271 (-14.51%)
Mutual labels:  attention-mechanism
Adaptiveattention
Implementation of "Knowing When to Look: Adaptive Attention via A Visual Sentinel for Image Captioning"
Stars: ✭ 303 (-4.42%)
Mutual labels:  attention-mechanism
Yolov3 Network Slimming
yolov3 network slimming剪枝的一种实现
Stars: ✭ 320 (+0.95%)
Mutual labels:  yolo
Social Distancing Analyser Covid 19
A social distancing analyzer AI tool to regulate social distancing protocol using video surveillance of CCTV cameras and drones. Social Distancing Analyser to prevent COVID19
Stars: ✭ 310 (-2.21%)
Mutual labels:  yolo
Tensorflow 2.x Yolov3
YOLOv3 implementation in TensorFlow 2.3.1
Stars: ✭ 300 (-5.36%)
Mutual labels:  yolo

Introduction

This Repository includes YOLOv3 with some lightweight backbones (ShuffleNetV2, GhostNet, VoVNet), some computer vision attention mechanism (SE Block, CBAM Block, ECA Block), pruning,quantization and distillation for GhostNet.

Important Update

2020.6.1
(1) The best lightweight model——HuaWei GhostNet has been added as the YOLOv3 backbone! It is better than ShuffleNetV2. The result for visdrone dataset is as following.
(2) Add Dorefa quantization method for arbitrary bit quantization! The result for visdrone dataset is as following.
(3) And I delete the ShuffleNet and the attention mechanism.
2020.6.24
(1) Add pruning according to NetworkSlimming.
(2) Add distillation for higher mAP after pruning.
(3) Add Imagenet pretraining model for GhostNet.
2020.9.26
(1) Add VoVNet as the backbone. The result is excellent.

Model Params FPS mAP
GhostNet+YOLOv3 23.49M 62.5 35.1
Pruned Model+Distillation 5.81M 76.9 34.3
Pruned Model+INT8 5.81M 75.1 34
YOLOv5s 7.27M - 32.7
YOLOv5x 88.5M - 41.8
VoVNet 42.8M 28.9 42.7

Attention : Single GPU will be better
If you need previous attention model or have any question, you can add my WeChat: AutrefoisLethe

Environment

  • python 3.7
  • pytorch >= 1.1.0
  • opencv-python

Datasets

Usage

  1. Download the datasets, place them in the data directory
  2. Train the models by using following command (change the model structure by changing the cfg file)
  python3 train.py --data data/visdrone.data --batch-size 16 --cfg cfg/ghost-yolov3-visdrone.cfg --img-size 640
  1. Detect objects using the trained model (place the pictures or videos in the samples directory)
  python3 detect.py --cfg cfg/ghostnet-yolov3-visdrone.cfg --weights weights/best.pt --data data/visdrone.data
  1. Results:
    most
    car
    airplane

Pruning and Quantization

Pruning

First of all, execute sparse training.

python3 train.py --data data/visdrone.data --batch-size 4 --cfg cfg/ghost-yolov3-visdrone.cfg --img-size 640 --epochs 300  --device 3 -sr --s 0.0001

Then change cfg and weights in normal_prune.py then use following command

python normal_prune.py

After obtaining pruned.cfg and corresponding weights file, you can fine-tune the pruned model via following command

python3 train.py --data data/visdrone.data --batch-size 4 --cfg pruned.cfg --img-size 640 --epochs 300  --device 3 --weights weights/xxx.weighs

Quantization

If you want to quantize certain convolutional layer, you can just change the [convolutional] to [quan_convolutional] in cfg file. Then use following command

  python3 train.py --data data/visdrone.data --batch-size 16 --cfg cfg/ghostnet-yolov3-visdrone.cfg --img-size 640

Experiment Result for Changing YOLOv3 Backbone

ShuffleNetV2 + Two Scales Detection(YOLO Detector)

Using Oxfordhand datasets

Model Params Model Size mAP
ShuffleNetV2 1x 3.57M 13.89MB 51.2
ShuffleNetV2 1.5x 5.07M 19.55MB 56.4
YOLOv3-tiny 8.67M 33.1MB 60.3

Using Visdrone datasets(Incomplete training)

Model Params Model Size mAP
ShuffleNetV2 1x 3.59M 13.99MB 10.2
ShuffleNetV2 1.5x 5.09M 19.63MB 11
YOLOv3-tiny 8.69M 33.9MB 3.3

Experiment Result for Attention Mechanism

Based on YOLOv3-tiny

SE Block paper : https://arxiv.org/abs/1709.01507
CBAM Block paper : https://arxiv.org/abs/1807.06521
ECA Block paper : https://arxiv.org/abs/1910.03151
| Model | Params | mAP | | ----- | ----- | ----- | | YOLOv3-tiny | 8.67M | 60.3 | | YOLOv3-tiny + SE | 8.933M | 62.3 | | YOLOv3-tiny + CBAM | 8.81M | 62.7 | | YOLOv3-tiny + ECA | 8.67M | 62.6 |

TODO

  • [x] ShuffleNetV2 backbone
  • [x] HuaWei GhostNet backbone
  • [x] ImageNet pretraining
  • [x] COCO datasets training
  • [ ] Other detection strategies
  • [ ] Other pruning strategies
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].