Yolov5: MobilenetV3-YoloV5 gots 5x speed up on CPU compare with yolov5s

Created on 22 Sep 2020  ·  21Comments  ·  Source: ultralytics/yolov5

Hi, I did some experiement on replace backbone with Mobilenetv3, here is the model comparasion:

image

image

CPU speed:

image

while original yolov5s:

image

Tested on forward onnx.

mAP drop a little bit but aceptable due to 5x speed up on CPU inference time.

Since yolov5 target on mobile devices, does it consider using a more lightweight backbone? Still v5s is the best for now, but maybe not the lightest one.

Stale enhancement

All 21 comments

@jinfagang could you please share your repository?

@bharatsubedi Oh, my repo is a little bit different like yolov5 does contruct model and a little mess.

Just tested mobilenetv3 vs yolov5s speed on TensorRT:

3ms VS 10ms

with 1280 input and GTX1080ti.

That's really fast, and also CPU speed 5x faster than yolov5s

How much the mAP drop?

on my dataset 95 -> 90, it's still very high, so acceptable.

Mobilenet is in a different class of detectors, which reduce accuracy in favor of speed and size. With YOLOv5 we want useable accuracy on edge devices, something typically lacking in previous architectures like yolov3-tiny, ssdlite, mobilenet, etc.

Mobilenet v3 (https://arxiv.org/pdf/1905.02244.pdf) produces 22.[email protected]:0.95 for COCO vs 37.0 for YOLOv5s currently.

@glenn-jocher In some tiny number classes dataset, mobilenetv3 seems OK, this is currently I got on my custom dataset. (Input resolution cares with small model)

image

在我的数据集95-> 90上,它仍然很高,可以接受。

i want to study your repository? can you share it?

great work! @jinfagang. Could you share repository!

Hi, I got a better result using Ghostnet as backbone:

image

It's almost same with v5s, but with double speed and half model size.

model size: 29M -> 10M, CPU speed is 3x faster.

Mobilenet is better for CPU device. And for specific custom dataset, mobilenet is good choice. However, the map of COCO is much lower than yolov5s.

Could you please share the (even if messy haha) repo @jinfagang ? Would appreciate it a lot. Thanks

I also experimented with ghostnet bottlenecks in place of standard or csp bottlenecks, but was not able to create performance increases, so we ultimately did not use them in YOLOv5. Ghostnet ops will reduce model size (and FLOPS), but will also add extra ops and layers, which in our experiments resulted in slightly slower inference and lower mAP.

Ghost operations are here BTW if anyone is interested in experimenting. You can use them by simply swapping a GhostBottleneck module for any of the BottleneckCSP modules in the model yaml file.

https://github.com/ultralytics/yolov5/blob/35fe98543c22e1b60f9b4f3d04c726b5aac166ef/models/experimental.py#L65-L90

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Hate to ask such a basic question, but @glenn-jocher would we only need to switch out BottleneckCSP? Or do we need to switch to GhostConv as well?

@bhaktatejas922 I don't know what you're asking. You can use GhostConv() in place of any normal Conv().

@jinfagang could you share it ,ths.

@bhaktatejas922 I don't know what you're asking. You can use GhostConv() in place of any normal Conv().

Ah just wasn't sure if using GhostBottleneck required us to use GhostConv as well. Sorry for the confusion

Ghost operations are here BTW if anyone is interested in experimenting. You can use them by simply swapping a GhostBottleneck module for any of the BottleneckCSP modules in the model yaml file.

https://github.com/ultralytics/yolov5/blob/35fe98543c22e1b60f9b4f3d04c726b5aac166ef/models/experimental.py#L65-L90

@glenn-jocher precision drops about 5% for my dataset by using GhostBottleneck, question is why you choose kernel size 5 for self.cv2 inGhostConv, seems different with the original setting?

@charlesyann precision is meaningless, as it varies by confidence threshold. mAP is absolute.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abhiksark picture abhiksark  ·  3Comments

krishnam3065 picture krishnam3065  ·  4Comments

Alex-afka picture Alex-afka  ·  3Comments

xinxin342 picture xinxin342  ·  3Comments

FSNStefan picture FSNStefan  ·  4Comments