Abstract:
Non-fiber impurities, such as cotton shells, cotton branches and broken leaves, are easily mixed into machine-harvested seed cotton during harvesting and processing. These impurities have complex morphologies, varying scales and blurred boundaries, which seriously affect impurity rate detection accuracy and subsequent quality evaluation during seed cotton procurement. To improve the instance segmentation accuracy and model deployment efficiency of seed cotton impurities under complex backgrounds, this study proposed a lightweight and efficient instance segmentation model named YOLO-LECNet based on the YOLOv8s-seg framework. The model was systematically improved in terms of feature extraction, cross-layer feature interaction and boundary optimization.First, an Efficient C2f (EC2f) structure was adopted to replace redundant convolutions with a Ghost dual-branch design, reducing the number of parameters by approximately 43.0% and the floating point operations (FLOPs) by 36.3%. This design reduced feature redundancy while maintaining the representation ability of impurity texture and semantic information. Second, a Local-Context Attention (LCA) module was introduced to enhance the interaction between local detail features and contextual semantic information. By strengthening impurity-related feature responses and suppressing cotton fiber background interference, the model improved the boundary perception ability for small-scale impurities, especially broken leaves with weak texture and low contrast. Third, a Channel-Enhanced IoU (CEIoU) loss function was used to improve the bounding box regression accuracy of irregular and deformed impurity targets, thereby enhancing the fitting ability of predicted regions to complex impurity boundaries.Based on the instance segmentation results, the impurity area information extracted from images was further combined with physical factors such as compressed sample thickness and seed cotton bulk density to establish an impurity rate prediction model, realizing quantitative estimation from visual segmentation results to impurity mass and impurity rate. The experimental results showed that YOLO-LECNet achieved better accuracy and lightweight performance than the baseline model. With 6.7 M parameters and an inference speed of 148.9 FPS, 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, compared with the baseline YOLOv8s-seg model.Ablation experiments further verified the contribution of each module to model performance. The combination of LCA, EC2f and CEIoU enabled YOLO-LECNet to achieve the best overall performance, indicating that feature response enhancement, lightweight feature extraction and boundary regression optimization had good synergistic effects. Compared with other mainstream instance segmentation models, YOLO-LECNet showed stronger ability in small-impurity segmentation, weak-boundary recognition and irregular-target localization while maintaining lower model complexity. The visualization results also showed that the proposed model reduced missed detections, boundary discontinuities and background mis-segmentation under complex cotton fiber backgrounds, and produced more complete masks for broken leaves, cotton shells and slender cotton branches.For impurity rate estimation, the multi-view image fusion strategy effectively reduced the uncertainty caused by occlusion and uneven impurity distribution in a single view. When four-view images were used for joint prediction, the prediction error tended to be stable, and the predicted impurity rate showed good consistency with the measured value. The coefficient of determination reached 0.822, while the mean absolute error and root mean square error were approximately 1.02% and 1.20%, respectively, indicating that the model could accurately reflect the real impurity level of seed cotton samples.In addition, the edge deployment experiment showed that YOLO-LECNet could be converted and 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, achieving a model size of 17 MB and an average inference time of 144.4 ms per image. These results demonstrate its potential for practical edge-side application. Overall, YOLO-LECNet achieved a good balance among impurity boundary recognition, small-target segmentation and model lightweight design. The proposed method provides an efficient and deployable engineering solution for seed cotton impurity detection and impurity rate evaluation.