Mask-based multi-scale visual transformer guided pharmaceutical package sealing defect recognition method and system and storage medium
Patent Information
- Application Number
- CN202610782763.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-02
- Publication Date
- 2026-10-16
AI Technical Summary
[0005]本申请的主要目的在于提供一种基于掩膜引导多尺度视觉Transformer的药包密封缺陷识别方法,旨在解决如何利用封口区域掩膜进行空间先验引导,并同时融合局部细节和全局温度分布信息进行缺陷识别的问题
[0036](1)将封口区域掩膜作为空间先验信息引入模型,使网络重点关注封口关键区域,减少背景冗余对分类结果的影响。
Smart Images

Figure CN122928703A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image recognition technology, and in particular to a method, system and storage medium for identifying sealing defects in pharmaceutical packages based on a mask-guided multi-scale visual Transformer. Background Technology
[0002] The sealing quality of pharmaceutical packaging directly affects the stability and safety of drugs. During the packaging process, issues such as powder inclusion, insufficient temperature, insufficient pressure, or simultaneous abnormalities in temperature and pressure can lead to poor sealing, moisture contamination, or loss of active ingredients. Traditional manual testing relies on experience, resulting in low efficiency, poor consistency, and strong subjectivity.
[0003] In existing infrared sealing inspection of pharmaceutical packages, a unique and difficult-to-distinguish combination of defects exists: powder inclusion defects (localized point-like thermal anomalies) and pressure reduction defects (decreased overall heat distribution uniformity) exhibit similar temperature statistical characteristics in infrared images, making them prone to misidentification by traditional methods or single-scale models. Furthermore, the combined defect of temperature and pressure reduction is highly confounded by single defects. This invention, for the first time, combines the spatial prior of the sealing area mask with global dependency modeling using a multi-scale VisionTransformer to achieve decoupled identification of the aforementioned three easily confused defect types.
[0004] Convolutional neural networks excel at extracting local features, but their ability to model global temperature distribution and long-range dependencies is limited. While ordinary Vision Transformers possess global modeling capabilities, their direct application to infrared sealing defect identification may overlook fine-grained local anomalies in critical sealing areas and is susceptible to background redundancy. Therefore, a defect identification method is needed that can utilize a sealing area mask for spatial prior guidance and simultaneously fuse local details and global temperature distribution information. Summary of the Invention
[0005] The main objective of this application is to provide a method for identifying sealing defects in pharmaceutical packages based on a mask-guided multi-scale visual Transformer. This method aims to solve the problem of how to use a mask of the sealing area for spatial prior guidance and simultaneously integrate local details and global temperature distribution information for defect identification.
[0006] To achieve the above objectives, this application provides a method for identifying sealing defects in pharmaceutical packages based on a mask-guided multi-scale visual Transformer, the method comprising:
[0007] S10, acquire the sealed area image and the sealing area mask corresponding to the infrared image of the medicine package to be identified, wherein the sealed area image is the sealing area image of interest obtained according to the segmentation model, the target detection model, manual annotation, threshold segmentation or rule cropping, and the sealing area mask is a binary mask or soft mask spatially aligned with the sealed area image.
[0008] S20, the sealed region image is divided into image block sequences of at least two scales to obtain a fine-scale image block sequence and a coarse-scale image block sequence;
[0009] S30, generate mask guidance weights based on the sealing region mask, and add the mask guidance weights to the image block embedding, attention calculation or feature fusion process;
[0010] S40, the fine-scale image block sequence and the coarse-scale image block sequence are respectively or jointly input into the Vision Transformer encoder to extract local fine-grained defect features and global temperature distribution features;
[0011] S50, the local fine-grained defect features and the global temperature distribution features are fused to obtain fused discrimination features. The fusion method includes at least one of splicing fusion, weighted summation fusion, average fusion, cross-attention fusion and gated fusion.
[0012] S60, the fused discrimination features are input into the classification module, and the identification result of the sealing defect of the medicine package is output. The defect category identification result includes at least two of the following: normal, powder inclusion, temperature reduction, pressure reduction, and simultaneous temperature and pressure reduction.
[0013] Optionally, in step S20, the patch size corresponding to the fine-scale image patch sequence is smaller than the patch size corresponding to the coarse-scale image patch sequence;
[0014] The fine-scale image patch sequence is used to extract features such as powder inclusion, particle occlusion, local thermal anomalies, or local boundary discontinuities.
[0015] The coarse-scale image block sequence is used to extract features such as temperature reduction, pressure reduction, combined temperature and pressure anomalies, or overall thermal distribution anomalies.
[0016] Optionally, in step S30, generating mask guiding weights based on the sealing area mask includes:
[0017] Adjust the mask of the sealing area to the spatial scale corresponding to the image block sequence;
[0018] Calculate the overlap ratio between each image patch and the mask of the sealing region;
[0019] Based on the overlap ratio, a nonlinear mapping function assigns higher weights to image blocks within or overlapping with the sealed area, and lower weights to image blocks outside the sealed area.
[0020] Optionally, the mask-guided weights may incorporate at least one of the following methods: weighted image block embedding, attention bias matrix, feature channel gating, and pre-classification feature weighting.
[0021] Optionally, in step S40, the Vision Transformer encoder includes a patch embedding layer, a position encoding layer, a multi-head self-attention layer, a feedforward neural network layer, a normalization layer, and a classification label, wherein the multi-head self-attention layer is used to establish long-distance dependencies between image patches of different sealing regions.
[0022] Optionally, the gating fusion includes the following steps:
[0023] Local fine-grained defect features and global temperature distribution features are input into a gated network to generate adaptive fusion weights;
[0024] The local fine-grained defect features and the global temperature distribution features are weighted and summed according to the adaptive fusion weights to obtain the fusion discrimination features.
[0025] Optionally, temperature intensity translation and temperature intensity scaling are performed in the target area corresponding to the sealing area mask, while the background area other than the target area remains unchanged, in order to simulate the fluctuation of actual sealing process parameters and avoid introducing irrelevant background noise.
[0026] Optionally, the classification module includes a fully connected layer and a Softmax layer. The classification module outputs the predicted probability of each sealing defect category and takes the category with the highest predicted probability as the final identification result.
[0027] Furthermore, to achieve the above objectives, this application also provides a drug package sealing defect identification system applied to the mask-guided multi-scale visual Transformer-based drug package sealing defect identification method described above, the drug package sealing defect identification system comprising:
[0028] The input module is used to acquire images of the sealed area and the mask of the sealing area;
[0029] A multi-scale segmentation module is used to divide the sealed region image into a sequence of image blocks of different scales;
[0030] The mask guidance module is used to generate mask guidance weights based on the mask of the sealing area;
[0031] The Transformer feature extraction module is used to extract local fine-grained defect features and global temperature distribution features based on the Vision Transformer encoder.
[0032] The feature fusion module is used to fuse features from different scales or different branches;
[0033] The classification output module is used to output the identification results of the sealing defects of the medicine package.
[0034] In addition, to achieve the above objectives, this application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the mask-guided multi-scale visual Transformer-based drug packaging sealing defect identification method as described in any of the preceding claims.
[0035] This application has at least the following beneficial effects:
[0036] (1) The mask of the sealing area is introduced into the model as spatial prior information, so that the network focuses on the key sealing area and reduces the impact of background redundancy on the classification results.
[0037] (2) By dividing the multi-scale patch, local fine-grained defects and overall temperature distribution abnormalities can be characterized simultaneously, which is suitable for the coexistence of multi-scale defects in the infrared image of the drug pack.
[0038] (3) Use the Vision Transformer self-attention mechanism to model the long-distance dependency between different sealing positions to improve the ability to identify overall anomalies such as pressure reduction and temperature reduction.
[0039] (4) By using gating fusion and other mechanisms to adaptively fuse local and global features, the ability to distinguish between similar defect types such as powder inclusion and pressure reduction can be improved.
[0040] (5) It can be combined with category weighting and mask region intensity perturbation to alleviate the generalization problem caused by sample imbalance and actual process fluctuations. Attached Figure Description
[0041] Figure 1 This is a flowchart illustrating the method for identifying sealing defects in pharmaceutical packages based on a mask-guided multi-scale visual Transformer, as described in an embodiment of this application.
[0042] Figure 2 This is a schematic diagram of mask-guided weight generation involved in an embodiment of this application;
[0043] Figure 3 This is a schematic diagram of multi-scale patch partitioning involved in an embodiment of this application;
[0044] Figure 4 This is a schematic diagram of the Vision Transformer encoder structure involved in the embodiments of this application;
[0045] Figure 5 This is a schematic diagram of gating fusion and classification output involved in the embodiments of this application.
[0046] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0047] To better understand the above technical solutions, exemplary embodiments of this disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of this disclosure to those skilled in the art.
[0048] First Embodiment
[0049] Reference Figures 1 to 5 This embodiment provides a method for identifying sealing defects in pharmaceutical packages based on a mask-guided multi-scale visual Transformer. The method includes the following steps:
[0050] S10, acquire the sealed area image and the sealing area mask corresponding to the infrared image of the medicine package to be identified, wherein the sealed area image is the sealing area image of interest obtained according to the segmentation model, the target detection model, manual annotation, threshold segmentation or rule cropping, and the sealing area mask is a binary mask or soft mask spatially aligned with the sealed area image.
[0051] In this embodiment, infrared images of the actual pharmaceutical packaging production line are acquired. Images of the sealing area and its mask are obtained through segmentation, cropping, or manual annotation. The sealing area image can be a pseudo-color infrared image or a thermal image converted from a pseudo-color image. The sealing area mask is a binary image or a soft mask with values ranging from 0 to 1.
[0052] To ensure consistency in model input, the image of the sealed area is scaled to a preset size, and the mask of the sealed area is simultaneously scaled to the same spatial size. If the aspect ratio of the image does not match the target size, proportional scaling and center filling can be used.
[0053] S20, the sealed region image is divided into image block sequences of at least two scales to obtain a fine-scale image block sequence and a coarse-scale image block sequence;
[0054] Further and optionally, the patch size corresponding to the fine-scale image patch sequence is smaller than the patch size corresponding to the coarse-scale image patch sequence;
[0055] The fine-scale image patch sequence is used to extract features such as powder inclusion, particle occlusion, local thermal anomalies, or local boundary discontinuities.
[0056] The coarse-scale image block sequence is used to extract features such as temperature reduction, pressure reduction, combined temperature and pressure anomalies, or overall thermal distribution anomalies.
[0057] S30, generate mask guidance weights based on the sealing region mask, and add the mask guidance weights to the image block embedding, attention calculation or feature fusion process;
[0058] Further and optionally, generating mask guiding weights based on the sealing region mask includes:
[0059] Adjust the mask of the sealing area to the spatial scale corresponding to the image block sequence;
[0060] Calculate the overlap ratio between each image patch and the mask of the sealing region;
[0061] Based on the overlap ratio, a nonlinear mapping function assigns higher weights to image blocks within or overlapping with the sealed area, and lower weights to image blocks outside the sealed area.
[0062] In this embodiment, the mask of the sealing region is downsampled or projected according to the Patch division scale, and the overlap ratio between each Patch and the mask region is calculated. Let the image patch sequence be... After projecting the mask M of the sealing area onto the block level, the overlap area ratio of each block is obtained. .
[0063] To enhance the distinction between highly overlapping and low-overlapping regions, this invention employs exponential weighted normalization to generate mask guiding weights:
[0064]
[0065] in This is a temperature coefficient used to amplify the weight differences of highly overlapping blocks; in this embodiment, it is taken as... ; To prevent small constants from being divided by zero.
[0066] If most of a patch is located within the sealed area ( If a patch is located in the background or edge-filled area, it is assigned a higher weight; if a patch is located in the background or edge-filled area, it is assigned a higher weight. If ), then assign a weight close to 0.
[0067] Mask-guided weights can be applied to at least one of the following steps:
[0068] Weighted image patch embedding: Multiply with the embedding vector of the i-th image patch;
[0069] Attention bias matrix: Adds a positive bias to the attention scores between patches within the closed region. Add a negative bias to the attention scores between background patches. (This embodiment takes) =2.0);
[0070] Weighting before feature fusion: Before the aggregation of classification features, according to... The features of each patch are weighted and pooled.
[0071] Further and optionally, the mask-guided weights incorporate at least one of the following: weighted image block embedding, attention bias matrix, feature channel gating, and pre-classification feature weighting.
[0072] S40, the fine-scale image block sequence and the coarse-scale image block sequence are respectively or jointly input into the Vision Transformer encoder to extract local fine-grained defect features and global temperature distribution features;
[0073] Further and optionally, the Vision Transformer encoder includes a patch embedding layer, a position encoding layer, a multi-head self-attention layer, a feedforward neural network layer, a normalization layer, and a classification label, wherein the multi-head self-attention layer is used to establish long-distance dependencies between image patches of different sealing regions.
[0074] In this embodiment, the sealed area image is divided into patches at at least two scales. For example, smaller patches are used to form a fine-scale sequence to preserve details such as powder particles, local hot spots, and discontinuities in the sealing boundary; larger patches are used to form a coarse-scale sequence to characterize overall temperature reduction, discontinuous heat diffusion caused by insufficient pressure, and combined temperature and pressure anomalies.
[0075] Each patch is linearly projected to obtain a patch embedding, and positional encoding is added. Patch sequences of different scales can be input into independent Transformer encoders, or they can be concatenated after scale marking and input into a shared Transformer encoder.
[0076] The Transformer encoder consists of a multi-head self-attention layer, a feedforward neural network layer, a normalization layer, and residual connections. The multi-head self-attention layer calculates the correlation between different patches based on the query, key, and value, enabling the model to learn the relationship between local anomalies in the sealing region and the overall heat distribution.
[0077] After the encoder outputs, classification label features, average pooling features, or mask-weighted pooling features are extracted as scale features. Fine-scale and coarse-scale features are then fused. Preferably, gated fusion is used: the two types of features are concatenated and input into a gated network consisting of a fully connected layer and a sigmoid activation function to obtain fusion weights; then, the two types of features are weighted and summed according to the fusion weights to obtain the fused discriminative features.
[0078] S50, the local fine-grained defect features and the global temperature distribution features are fused to obtain fused discrimination features. The fusion method includes at least one of splicing fusion, weighted summation fusion, average fusion, cross-attention fusion and gated fusion.
[0079] Further and optionally, the gating fusion includes the following steps:
[0080] Local fine-grained defect features and global temperature distribution features are input into a gated network to generate adaptive fusion weights;
[0081] The local fine-grained defect features and the global temperature distribution features are weighted and summed according to the adaptive fusion weights to obtain the fusion discrimination features.
[0082] S60, the fused discrimination features are input into the classification module, and the identification result of the sealing defect of the medicine package is output. The defect category identification result includes at least two of the following: normal, powder inclusion, temperature reduction, pressure reduction, and simultaneous temperature and pressure reduction.
[0083] Further and optionally, the temperature intensity translation and temperature intensity scaling are applied only to the target area corresponding to the sealing area mask, while the background area remains unchanged, in order to simulate the fluctuation of actual sealing process parameters and avoid introducing irrelevant background noise.
[0084] Further and optionally, the classification module includes a fully connected layer and a Softmax layer. The classification module outputs the predicted probability of each sealing defect category and takes the category with the highest predicted probability as the final identification result.
[0085] In this embodiment, the fused discriminative features are input into the classification head, which can consist of one or more fully connected layers. The predicted probabilities for each category are output via Softmax. Defect categories can include normal, powder inclusion, decreased temperature, decreased pressure, and simultaneous decrease in temperature and pressure.
[0086] During the training phase, cross-entropy loss, category-weighted cross-entropy loss, Focal Loss, or label-smoothed cross-entropy loss can be employed. For categories with a small number of samples or those prone to confusion, higher sampling probabilities or loss weights can be set. To address the issue that infrared temperature values are easily affected by fluctuations in actual sealing process parameters, this invention proposes a mask region perception data augmentation strategy: during the training phase, the input image... and its corresponding sealing area mask Temperature intensity transformation is performed only on pixels in the masked sealing area, while background pixels remain unchanged. Specifically, this includes:
[0087] (1) Random shift of temperature intensity:
[0088]
[0089] in In this embodiment, .
[0090] (2) Random scaling of temperature intensity:
[0091]
[0092] in In this embodiment, The two transformations described above can be used independently or in combination. The background region retains its original temperature value to ensure that the defect features learned by the model originate only from the sealing area, while avoiding the introduction of background noise interference unrelated to the sealing defects.
[0093] Verification of Examples
[0094] Based on the above embodiments, in this embodiment, the dataset was collected from an actual production line. On a test set of 375 images, including normal (75 images), powder contamination (75 images), temperature reduction (75 images), pressure reduction (75 images), and simultaneous temperature and pressure reduction (75 images), this method was compared with three baseline methods, and the results are shown in Table 1 below:
[0095] Table 1. Comparison Results
[0096]
[0097] The results show that the present invention provides the most significant improvement in easily confused categories.
[0098] Furthermore, this embodiment also proposes a drug package sealing defect identification system applied to the mask-guided multi-scale visual Transformer-based drug package sealing defect identification method described above. The drug package sealing defect identification system includes:
[0099] The input module is used to acquire images of the sealed area and the mask of the sealing area;
[0100] A multi-scale segmentation module is used to divide the sealed region image into a sequence of image blocks of different scales;
[0101] The mask guidance module is used to generate mask guidance weights based on the mask of the sealing area;
[0102] The Transformer feature extraction module is used to extract local fine-grained defect features and global temperature distribution features based on the Vision Transformer encoder.
[0103] The feature fusion module is used to fuse features from different scales or different branches;
[0104] The classification output module is used to output the identification results of the sealing defects of the medicine package.
[0105] Furthermore, those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program includes program instructions and can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in a computer system to implement the process steps of the embodiments of the above methods.
[0106] Therefore, this application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the various steps of the mask-guided multi-scale visual Transformer-based drug packaging sealing defect identification method as described in the above embodiments.
[0107] The computer-readable storage medium can be any computer-readable storage medium capable of storing program code, such as a USB flash drive, portable hard drive, read-only memory (ROM), magnetic disk, or optical disk.
[0108] It should be noted that, since the storage medium provided in the embodiments of this application is the storage medium used to implement the methods of the embodiments of this application, those skilled in the art can understand the specific structure and variations of the storage medium based on the methods described in the embodiments of this application, and therefore will not be repeated here. All storage media used in the methods of the embodiments of this application fall within the scope of protection of this application.
[0109] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0110] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0111] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0112] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0113] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0114] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A method for identifying sealing defects in pharmaceutical packaging based on a mask-guided multi-scale visual Transformer, characterized in that, The method includes the following steps: S10, acquire the sealed area image and the sealing area mask corresponding to the infrared image of the medicine package to be identified, wherein the sealed area image is the sealing area image of interest obtained according to the segmentation model, the target detection model, manual annotation, threshold segmentation or rule cropping, and the sealing area mask is a binary mask or soft mask spatially aligned with the sealed area image. S20, the sealed region image is divided into image block sequences of at least two scales to obtain a fine-scale image block sequence and a coarse-scale image block sequence; S30, generate mask guidance weights based on the sealing region mask, and add the mask guidance weights to the image block embedding, attention calculation or feature fusion process; S40, the fine-scale image block sequence and the coarse-scale image block sequence are respectively or jointly input into the VisionTransformer encoder to extract local fine-grained defect features and global temperature distribution features; S50, the local fine-grained defect features and the global temperature distribution features are fused to obtain fused discrimination features. The fusion method includes at least one of splicing fusion, weighted summation fusion, average fusion, cross-attention fusion and gated fusion. S60, the fused discrimination features are input into the classification module, and the identification result of the sealing defect of the medicine package is output. The defect category identification result includes at least two of the following: normal, powder inclusion, temperature reduction, pressure reduction, and simultaneous temperature and pressure reduction.
2. The method for identifying sealing defects in pharmaceutical packages based on a mask-guided multi-scale visual Transformer as described in claim 1, characterized in that, In step S20, the patch size corresponding to the fine-scale image patch sequence is smaller than the patch size corresponding to the coarse-scale image patch sequence; The fine-scale image patch sequence is used to extract features such as powder inclusion, particle occlusion, local thermal anomalies, or local boundary discontinuities. The coarse-scale image block sequence is used to extract features such as temperature reduction, pressure reduction, combined temperature and pressure anomalies, or overall thermal distribution anomalies.
3. The method for identifying sealing defects in pharmaceutical packages based on a mask-guided multi-scale visual Transformer as described in claim 1, characterized in that, In step S30, generating mask guiding weights based on the sealing area mask includes: Adjust the mask of the sealing area to the spatial scale corresponding to the image block sequence; Calculate the overlap ratio between each image patch and the mask of the sealing region; Based on the overlap ratio, a nonlinear mapping function assigns higher weights to image blocks within or overlapping with the sealed area, and lower weights to image blocks outside the sealed area.
4. The method for identifying sealing defects in pharmaceutical packages based on a mask-guided multi-scale visual Transformer as described in claim 1, characterized in that, The mask-guided weights incorporate at least one of the following methods: weighted image block embedding, attention bias matrix, feature channel gating, and pre-classification feature weighting.
5. The method for identifying sealing defects in pharmaceutical packages based on a mask-guided multi-scale visual Transformer as described in claim 1, characterized in that, In step S40, the Vision Transformer encoder includes a patch embedding layer, a position encoding layer, a multi-head self-attention layer, a feedforward neural network layer, a normalization layer, and a classification label. The multi-head self-attention layer is used to establish long-distance dependencies between image patches of different sealing regions.
6. The method for identifying sealing defects in pharmaceutical packages based on a mask-guided multi-scale visual Transformer as described in claim 1, characterized in that, The gating fusion includes the following steps: Local fine-grained defect features and global temperature distribution features are input into a gated network to generate adaptive fusion weights; The local fine-grained defect features and the global temperature distribution features are weighted and summed according to the adaptive fusion weights to obtain the fusion discrimination features.
7. The method for identifying sealing defects in pharmaceutical packages based on a mask-guided multi-scale visual Transformer as described in claim 1, characterized in that, Temperature intensity translation and scaling are performed in the target area corresponding to the sealing area mask, while the background area other than the target area remains unchanged to simulate the fluctuation of actual sealing process parameters and avoid introducing irrelevant background noise.
8. The method for identifying sealing defects in pharmaceutical packages based on a mask-guided multi-scale visual Transformer as described in claim 1, characterized in that, The classification module includes a fully connected layer and a Softmax layer. The classification module outputs the predicted probability of each sealing defect category and takes the category with the highest predicted probability as the final identification result.
9. A pill pack sealing defect identification system applied to the pill pack sealing defect identification method based on mask-guided multi-scale visual Transformer as described in any one of claims 1 to 8, characterized in that, The medicine package sealing defect identification system includes: The input module is used to acquire images of the sealed area and the mask of the sealing area; A multi-scale segmentation module is used to divide the sealed region image into a sequence of image blocks of different scales; The mask guidance module is used to generate mask guidance weights based on the mask of the sealing area; The Transformer feature extraction module is used to extract local fine-grained defect features and global temperature distribution features based on the Vision Transformer encoder. The feature fusion module is used to fuse features from different scales or different branches; The classification output module is used to output the identification results of the sealing defects of the medicine package.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method for identifying drug pack sealing defects based on a mask-guided multi-scale visual Transformer as described in any one of claims 1 to 8.