计算机工程与应用 ›› 2024, Vol. 60 ›› Issue (21): 315-323.DOI: 10.3778/j.issn.1002-8331.2306-0344

• 工程与应用 • 上一篇    下一篇

基于YOLOv7改进的夜间樱桃检测方法:YOLOv7-Cherry

盖荣丽,孔祥宙,秦山,魏凯   

  1. 1.大连大学 信息工程学院,辽宁 大连 116100
    2.大连市现代农业生产发展服务中心,辽宁 大连 116021
  • 出版日期:2024-11-01 发布日期:2024-10-25

Improved Cherry Detection Method at Night Based on YOLOv7: YOLOv7-Cherry

GAI Rongli, KONG Xiangzhou, QIN Shan, WEI Kai   

  1. 1.College of Information Engineering, Dalian University, Dalian, Liaoning 116100, China
    2.Dalian Modern Agricultural Production Development Service Center, Dalian, Liaoning 116021, China
  • Online:2024-11-01 Published:2024-10-25

摘要: 针对樱桃检测算法无法对夜晚环境下的樱桃进行成熟度识别的问题,提出一种改进的YOLOv7算法:YOLOv7-Cherry。使用一种将夜间樱桃图像和白天相同位置的樱桃图像相融合的图像预处理方法,保留夜间樱桃图像高空间分辨信息的同时加强其光谱分辨率。在YOLOv7-Cherry中,将CBAM注意力机制插入到骨干网络中,利用注意力机制强化神经网络的表征能力,强调重要特征,忽略次要特征,加强对樱桃目标特征的提取;为了加强目标检测算法对图像中小樱桃的识别,增加小目标检测层;改进了原始网络的初始检测框大小;为了减少遮挡对樱桃目标造成的损失,对检测框使用了Soft-NMS方法进行冗余去除。实验结果表明,YOLOv7-Cherry可以有效地识别出夜晚环境下的成熟樱桃和未成熟樱桃, 与YOLOv3、Faster-RCNN、YOLOv4、YOLOv5和原YOLOv7相比,YOLOv7-Cherry的mAP提高了26.88、25.05、22.51、17.11和7.66个百分点,其中,识别精度、召回率、mAP和F1为93.9%、94.7%、97.4%、94.3%。

关键词: 图像融合, YOLOv7, 目标检测, 小目标, 夜间樱桃识别

Abstract: To solve the problem that the cherry detection algorithm can not recognize the maturity of cherries in the night environment, an improved YOLOv7 algorithm: YOLOv7-Cherry is proposed. An image preprocessing method is used to combine the nighttime cherry image with the daytime cherry image in the same position to preserve the high spatial resolution information of the nighttime cherry image and enhance its spectral resolution. In YOLOv7-Cherry, the CBAM attention is firstly inserted into the backbone, and the attention mechanism is used to strengthen the representational ability of the neural network, emphasize important features, ignore secondary features, and enhance the extraction of cherry target features. Secondly,  the recognition of small cherries are enhanced in images by the target detection algorithm, the small target detection layer is added. Then the initial detection box size of the original network is improved. Finally, to reduce the loss of cherry targets caused by the occlusion, the Soft-NMS method is used for the redundancy removal of the detection box. The experimental results demonstrate that YOLOv7-Cherry can significantly detect mature and immature cherries in night conditions. Compared with the YOLOv3, Faster-RCNN, YOLOv4, YOLOv5 and original YOLOv7 models, mAP of YOLOv7-Cherry model increased by 26.88, 25.05, 22.51, 17.11 and 7.66 percentage points, among which the precision, recall, mAP and F1 are 93.9%, 94.7%, 97.4% and 94.3%.

Key words: image fusion, YOLOv7, object detection, small target, cherry recognition at night