Foreign matter, such as varia and mildew in the cutaway view of tobacco packages, can be detected using machine vision detection technology. However, mainstream object detection algorithms have poor detection ability for small targets when applied to foreign matter detection in the cutaway view of tobacco packages. To solve this problem, this study proposes Mask Block Attention (MBA) and introduces it into the feature extraction network to improve the global modeling ability of the object detection network, further enhancing its ability to detect foreign matter in the cutaway view of tobacco packages. Meanwhile, this study establishes a K-fold packet slicing defect dataset called K-PSDDS (K-fold packet slicing defect dataset) for foreign matter in the cutaway view of tobacco packages and conducts numerous experiments on K-PSDDS. The experimental results indicate that the AP50 and APbbox of DINO (DETR with an improved denoising anchor box for end-to-end target detection) + MBA reached 94.9% and 47.7%, respectively, showing an improvement of 0.3% and 0.9% over the baseline network DINO. Meanwhile, it achieves better performance and detection capabilities than fast region-based convolutional neural networks and other detection algorithms.