The application discloses a tobacco safety
foreign matter identification method based on an
image segmentation algorithm, comprising the following steps: S1, collecting an original image of tobacco to be detected; S2, preprocessing the original image to generate a standardized image; S3, extracting multi-scale features by using a ConvNeXt model to generate a feature image set; S4, inputting the feature image set into an improved
Mask2Former model, outputting an instance segmentation
mask through a scale
perception query and a local texture attention mechanism; S5, calculating
foreign matter categories and coordinates according to the
mask; and S6, packing to generate a
visual identification result data packet. Through the fusion of the powerful
feature extraction capability of ConvNeXt and the
accurate segmentation mechanism of the improved
Mask2Former, the identification precision and robustness of small, low-contrast and texture-similar foreign matters are improved, the missing detection and
false alarm problems of traditional methods in a complex industrial background are solved, and a high-precision detection scheme is provided for tobacco storage safety.