Abstract:
Non-fiber impurities, such as cotton shells, cotton branches, and broken leaves, can easily be mixed into machine-harvested seed cotton during harvesting and processing. These impurities can seriously threaten the detection accuracy of the impurity rate and subsequent quality evaluation during seed cotton procurement, due to their complex morphologies, different sizes, and blurred boundaries. This study aims to improve the accuracy of instance segmentation and deployment for seed cotton impurities under complex backgrounds. A lightweight and efficient instance segmentation was also proposed, named YOLO-LECNet, using the YOLOv8s-seg framework. A series of improvements was used to systematically enhance feature extraction, cross-layer feature interaction, and boundary optimization. 1) An Efficient C2f (EC2f) structure with a Ghost dual-branch design was adopted to replace redundant convolutions, thereby reducing computational complexity and feature redundancy while maintaining effective feature representation.. Feature redundancy was reduced to maintain the representation of impurity texture and semantic information. 2) A Local-Context Attention (LCA) module was introduced to enhance the interaction between local features and contextual semantic information. Responses to the impurity feature were strengthened to suppress background interference from cotton fiber. Boundary perception was improved for small-scale impurities, especially broken leaves with weak texture and low contrast. 3) A Channel-Enhanced IoU (CEIoU) loss function was used to improve the accuracy of bounding box regression for irregular and deformed impurity targets, thereby enhancing the fitting of predicted regions to complex impurity boundaries. The impurity area was extracted from images after instance segmentation to further combine with physical factors, such as compressed sample thickness and seed cotton bulk density. A prediction model of impurity rate was established to realize quantitative estimation from visual segmentation to impurity mass and rate. The experimental results showed that YOLO-LECNet achieved better accuracy and lightweight performance compared with the baseline YOLOv8s-seg model. The precision, recall, Box mAP@0.5, and Mask mAP@0.5:0.95 were improved by 6.7, 5.9, 6.6, and 8.0 percentage points, respectively, particularly with 6.7 M parameters and an inference speed of 148.9 FPS. Ablation experiments verified the contribution rates of each module to performance. The LCA, EC2f, and CEIoU were combined for the best overall performance, indicating the high feature response, lightweight feature extraction, and boundary regression optimization. As such, YOLO-LECNet shared the stronger performance on small-impurity segmentation, weak-boundary recognition, and irregular-target localization, with lower model complexity, compared with other mainstream instance segmentation models. The visualization also showed that the missing detections, boundary discontinuities, and background mis-segmentation were reduced under complex backgrounds of cotton fiber. More complete masks were produced for broken leaves, cotton shells, and slender cotton branches. In impurity rate estimation, the multi-view image fusion effectively reduced the uncertainty caused by occlusion and uneven impurity distribution in a single view. Once four-view images were used for joint prediction, the prediction error tended to be stable. The impurity rate showed better consistency with the measured values. The coefficient of determination reached 0.822, while the mean absolute error and root mean square error were 1.02% and 1.20%, respectively. The real impurity level of seed cotton samples was represented accurately after measurement. In addition, the edge deployment experiment showed that YOLO-LECNet was converted and then deployed on the RK3588 platform. Compared with YOLOv8s-seg, the deployed YOLO-LECNet model reduced the model size by 8 MB and the average inference time by 17.9 ms, with a model size of 17 MB and an average inference time of 144.4 ms per image. There was great potential for edge-side application in practice. Overall, YOLO-LECNet can be expected to better balance impurity boundary recognition, small-target segmentation, and a lightweight model. The findings can provide an efficient and deployable engineering solution for seed cotton impurity detection and impurity rate evaluation.