ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
49.5k stars 16.08k forks source link

Will there be a lighter yolov5? #4501

Closed ppogg closed 2 years ago

ppogg commented 3 years ago

❔Question

Additional context

Dear author, I am a student. I have been following your warehouse for a long time, from less than 1k of yolov5 to 15k now, yolov5 is indeed a pretty good algorithm. I think that yolov5 may allow light-weight development in the past. In fact, I am also doing related work. This is the model I modified. It can achieve 2-4 times acceleration on the chip of the Arm series architecture, but the map is definitely far inferior to yolov5m and yolov5l. This is also my graduation project. I would like to ask you how to maintain the speed of a model like me without losing too much map at the same time? I also look forward to your future release of lighter models, I will always follow you, and thank you for your suggestions! This is my project address: https://github.com/ppogg/YOLOv5-Lite

github-actions[bot] commented 3 years ago

👋 Hello @ppogg, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

Python>=3.6.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

$ git clone https://github.com/ultralytics/yolov5
$ cd yolov5
$ pip install -r requirements.txt

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

ppogg commented 3 years ago

Hi, sir. Yolov5 is really powerful, especially C3 block, which I think is a good idea. Actually, it also outstanding in lightweight modification, compared with depthwise or CSP block. In fact, I have been doing this aspect of the experiment, this is the new baseline.

ID Model Input_size Flops Params Size(M) Map@0.5 Map@.5:0.95
001 yolov5-lite 320×320 1.43G 1.62M 3.3 36.2 20.8
002 yolov3-tiny 416×416 6.96G 6.06M 23.0 33.1 16.6
003 yolov4-tiny 416×416 5.62G 8.86M 33.7 40.2 21.7
004 yolov5-lite 416×416 2.42G 1.62M 3.3 41.3 24.4
005 yolov5-lite 640×640 2.42G 1.62M 3.3 45.7 27.1
006 yolov5s 640×640 17.0G 7.3M 14.2 55.4 36.7

The backbone is shufflenet, neck is Yolov5 Pan (with c3 block), But I think it has reached the bottleneck. Do you have any suggestions?

Oh. In addition, I tested that concat in the following C3 block is replaced by add. The parameters can be reduced by 1 / 3, but the accuracy is declined 2 points. That's fun~

glenn-jocher commented 2 years ago

@ppogg thanks for the feedback! The most basic type of model reduction on the smaller side would depend on the priority:

Note that smaller size and faster speed are not necessarily highly correlated, instead speed is dominated by small object layers while size is dominated by large object layers.

ppogg commented 2 years ago

@ppogg thanks for the feedback! The most basic type of model reduction on the smaller side would depend on the priority:

  • smaller size: most easily attained by reduction/elimination of large output layers (i.e. P5-P6) or channel count/ops on large output layers, or depthwise convolutions on large output layers.
  • faster speed: most easily attained by reduction/elimination of small output layers (i.e. P1-P3) or channel count/ops on small output layers, or depthwise convolutions on small output layers.

Note that smaller size and faster speed are not necessarily highly correlated, instead speed is dominated by small object layers while size is dominated by large object layers.

Yes sir, I agree with your point of view deeply. In fact, I also discovered this point during the experiment. It is cool, and it is also two points that directly affect the speed and model size.

ppogg commented 2 years ago

The above two suggestions you gave are very useful! In fact, I have integrated the repvgg block, the model is only 10M, but the Flops of YOLOv5-Repvgg looks large (22G), the detection speed is only 10% faster on gpu, and the accuracy has dropped by 6 points. I will try you suggestions for pruning and compression~