当前位置:网站首页>Yolov5 adds a small target detection layer
Yolov5 adds a small target detection layer
2022-06-28 06:20:00 【Caribbean kelp 66】
Small target detection has always been CV One of the difficulties in the field , that ,YOLOv5 How to add a small target detection layer ?

YOLOv5 Code changes ———— For small target detection
1.YOLOv5 Introduction to the algorithm
YOLOv5 Mainly by input terminal 、Backone、Neck as well as Prediction Four-part composition . among :
(1) Backbone: The convolution neural network of image features is formed by combining different fine-grained images .
(2) Neck: A network layer that mixes and combines image features , And transfer the image features to the prediction layer .
(3) Head: Prediction of image features , Generate bounding boxes and predict categories .
Detection framework :

2. original YOLOv5 Model
# YOLOv5 head
head:
[[-1, 1, Conv, [512, 1, 1]],
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
[[-1, 6], 1, Concat, [1]], # cat backbone P4
[-1, 3, C3, [512, False]], # 13
[-1, 1, Conv, [256, 1, 1]],
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
[[-1, 4], 1, Concat, [1]], # cat backbone P3
[-1, 3, C3, [256, False]], # 17 (P3/8-small)
[-1, 1, Conv, [256, 3, 2]],
[[-1, 14], 1, Concat, [1]], # cat head P4
[-1, 3, C3, [512, False]], # 20 (P4/16-medium)
[-1, 1, Conv, [512, 3, 2]],
[[-1, 10], 1, Concat, [1]], # cat head P5
[-1, 3, C3, [1024, False]], # 23 (P5/32-large)
[[17, 20, 23], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5)
]If you enter the image size =640X640,
# P3/8 The size of the corresponding detection feature map is 80X80, Used to detect that the size is in 8X8 The above goals .
# P4/16 The size of the corresponding detection feature map is 40X40, Used to detect that the size is in 16X16 The above goals .
# P5/32 The size of the corresponding detection feature map is 20X20, Used to detect that the size is in 32X32 The above goals .
3. Add a small target detection layer
# parameters
nc: 1 # number of classes
depth_multiple: 0.33 # model depth multiple
width_multiple: 0.50 # layer channel multiple
# anchors
anchors:
- [5,6, 8,14, 15,11] #4
- [10,13, 16,30, 33,23] # P3/8
- [30,61, 62,45, 59,119] # P4/16
- [116,90, 156,198, 373,326] # P5/32
# YOLOv5 backbone
backbone:
# [from, number, module, args]
[[-1, 1, Focus, [64, 3]], # 0-P1/2
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4
[-1, 3, BottleneckCSP, [128]], #160*160
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8
[-1, 9, BottleneckCSP, [256]], #80*80
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16
[-1, 9, BottleneckCSP, [512]], #40*40
[-1, 1, Conv, [1024, 3, 2]], # 7-P5/32
[-1, 1, SPP, [1024, [5, 9, 13]]],
[-1, 3, BottleneckCSP, [1024, False]], # 9 20*20
]
# YOLOv5 head
head:
[[-1, 1, Conv, [512, 1, 1]], #20*20
[-1, 1, nn.Upsample, [None, 2, 'nearest']], #40*40
[[-1, 6], 1, Concat, [1]], # cat backbone P4 40*40
[-1, 3, BottleneckCSP, [512, False]], # 13 40*40
[-1, 1, Conv, [512, 1, 1]], #40*40
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
[[-1, 4], 1, Concat, [1]], # cat backbone P3 80*80
[-1, 3, BottleneckCSP, [512, False]], # 17 (P3/8-small) 80*80
[-1, 1, Conv, [256, 1, 1]], #18 80*80
[-1, 1, nn.Upsample, [None, 2, 'nearest']], #19 160*160
[[-1, 2], 1, Concat, [1]], #20 cat backbone p2 160*160
[-1, 3, BottleneckCSP, [256, False]], #21 160*160
[-1, 1, Conv, [256, 3, 2]], #22 80*80
[[-1, 18], 1, Concat, [1]], #23 80*80
[-1, 3, BottleneckCSP, [256, False]], #24 80*80
[-1, 1, Conv, [256, 3, 2]], #25 40*40
[[-1, 14], 1, Concat, [1]], # 26 cat head P4 40*40
[-1, 3, BottleneckCSP, [512, False]], # 27 (P4/16-medium) 40*40
[-1, 1, Conv, [512, 3, 2]], #28 20*20
[[-1, 10], 1, Concat, [1]], #29 cat head P5 #20*20
[-1, 3, BottleneckCSP, [1024, False]], # 30 (P5/32-large) 20*20
[[21, 24, 27, 30], 1, Detect, [nc, anchors]], # Detect(p2, P3, P4, P5)
]
# New addition 160X160 Detection characteristic diagram of , Used to detect 4X4 The above goals .
After improvement , Although the amount of computation and the speed of detection have increased , However, the detection accuracy of small targets has been significantly improved .
边栏推荐
- JQ picture amplifier
- Binder interview: memory management unit
- Is it safe to open a stock account? How to open a stock account?
- 移动广告发展动向:撬动存量,精细营销
- Caused by: com. fasterxml. jackson. databind. Exc.invalidformatexception: exception resolution
- socke. IO long connection enables push, version control, and real-time active user statistics
- YYGH-BUG-03
- 5-minute NLP: summary of time chronology from bag of words to transformer
- Lombok @equalsandhashcode annotation how to make objects The equals () method compares only some attributes
- lombok @EqualsAndHashCode 注解如何让对象.equals()方法只比较部分属性
猜你喜欢

链表(二)——设计链表

【Paper Reading-3D Detection】Fully Convolutional One-Stage 3D Object Detection on LiDAR Range Images

Example of MVVM framework based on kotlin+jetpack

慢内容广告:品牌增长的长线主义

整型提升和大小端字节序
![[staff] arpeggio mark](/img/45/0ee0089b947b467344b247839893d7.jpg)
[staff] arpeggio mark

mac下安装多个版本php并且进行管理

Linux MySQL implements root user login without password

AutoCAD C # Polyline Small Sharp angle Detection

CAD二次开发+NetTopologySuite+PGIS 引用多版本DLL问题
随机推荐
What are the advantages of e-mail marketing? Why do sellers of shopline independent station attach so much importance to it?
YOLOv5增加小目标检测层
death_satan/hyperf-validate
4. use MySQL shell to install and deploy Mgr clusters | explain Mgr in simple terms
Example of MVVM framework based on kotlin+jetpack
手把手教你用Ucos
Integer promotion and size side byte order
MySQL(二)——基本操作
cocoapod中的第三方库怎么引用本地头文件
Introduction to browser tools: think sky browser, team work browser
OpenGL API learning (2008) client server client server
Linked list (III) - reverse linked list
Xcode13.3.1 error reported after pod install
@The reason why the Autowired annotation is empty
CAD secondary development +nettopologysuite+pgis reference multi version DLL
Working principle of es9023 audio decoding chip
Taobao seo training video course [22 lectures]
Idea generates entity classes from database tables
Using pytorch and tensorflow to calculate the confusion matrix of classification model
MySQL common functions