A container lead seal identification and detection method and system based on an ACF-YOLOX algorithm, an electronic device, and a storage medium

By introducing the CA attention mechanism and feature fusion unit into container seal recognition using the ACF-YOLOX algorithm, the adaptability and accuracy issues of seal recognition in complex environments are solved, achieving efficient and accurate automated recognition, which is suitable for intelligent port logistics.

CN122116368APending Publication Date: 2026-05-29SHANDONG PORT LAND-SEA INT LOGISTICS GRP CO LTD +3

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHANDONG PORT LAND-SEA INT LOGISTICS GRP CO LTD
Filing Date
2026-01-22
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing technologies have poor adaptability to container seal identification in complex port environments, low efficiency of multi-scale feature fusion, and insufficient accuracy of seal positioning and identification, resulting in low identification efficiency, high false recognition rate, and difficulty in meeting stringent inspection standards.

Method used

The ACF-YOLOX algorithm is adopted. By introducing the CA attention mechanism into the CSPDarknet backbone network, and combining the AFM adaptive feature fusion unit and CFM cross-scale feature fusion unit in the improved feature fusion pyramid structure, the feature extraction and fusion capabilities are enhanced. Furthermore, by decoupling the head network to separate the classification and regression tasks, the localization accuracy and recognition efficiency are improved.

Benefits of technology

It significantly improves the stability and accuracy of lead seal identification in complex environments, reduces the false recognition rate, realizes end-to-end automated identification, has strong adaptability, reduces deployment costs, and meets the intelligent needs of port logistics.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122116368A_ABST
    Figure CN122116368A_ABST
Patent Text Reader

Abstract

The application discloses a kind of container lead seal identification detection method, system based on ACF-YOLOX algorithm, electronic equipment and storage medium, optimization feature extraction is carried out using the ACF-YOLOX algorithm embedded CA attention mechanism, and the positioning adaptability of lead seal is strengthened;Add target area effectiveness screening link, lock the effective recognition area of OCR based on the area intersection proportion threshold value;Optimize algorithm robustness and modular architecture, improve scene adaptive capacity and versatility;Build full-process software automatic identification process, get rid of special hardware dependence.Improve the positioning accuracy of lead seal and the efficiency of OCR identification, reduce the misidentification rate;Without a large number of customized parameter adjustment, widen the adaptation range and can be migrated to similar small target identification scene;Realize whole-link unmanned intervention to reduce deployment and labor cost, suitable for port, yard and other logistics scenarios, provide support for lead seal identification digital upgrade.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the fields of artificial intelligence and machine vision technology, and specifically relates to a container lead seal identification and detection method, system, electronic device and storage medium based on the ACF-YOLOX algorithm. Background Technology

[0002] In existing technologies, container seal recognition largely relies on general object detection schemes based on machine vision and deep learning. These schemes acquire multi-faceted RGB images of the container, assign them recognition task labels, and then use object detection algorithms to identify features such as the seal. The detection performance is optimized using the CIOU+DIOU_nms loss function, and a verification process ensures the recognition results, thus meeting the basic requirements for automated seal recognition in port operations. However, these existing technologies have significant shortcomings in terms of adaptability to complex port environments and accuracy control.

[0003] In practical applications, port operations face complex conditions such as variable lighting, container corrosion, and significant differences in seal dimensions. Existing feature extraction mechanisms lack targeted optimization, fail to focus on the small target characteristics of seals to enhance key feature capture, and employ relatively simple feature fusion methods. Affected by background noise interference and insufficient multi-scale feature integration, the positioning of seals and their numbers is prone to error. OCR recognition requires processing the entire image or low-matching areas, resulting in low recognition efficiency, high false recognition rates, and insufficient stability under stringent inspection standards to meet practical operational requirements.

[0004] It is evident that existing technologies often suffer from problems such as weak adaptability to complex environments, low efficiency in multi-scale feature fusion, and insufficient accuracy in lead seal positioning and recognition. These are the shortcomings of existing technologies.

[0005] In view of this, it is very necessary to provide a container lead seal identification and detection method, system, electronic device and storage medium based on the ACF-YOLOX algorithm to solve the above-mentioned defects in the prior art. Summary of the Invention

[0006] The purpose of this invention is to address the shortcomings of existing technologies, such as weak adaptability to complex environments, low efficiency of multi-scale feature fusion, and insufficient accuracy in lead seal positioning and identification. This invention provides a container lead seal identification and detection method, system, electronic device, and storage medium based on the ACF-YOLOX algorithm to solve the aforementioned technical problems.

[0007] To achieve the above objectives, the present invention provides the following technical solution: In a first aspect, the present invention provides a method for identifying and detecting lead seals on containers based on the ACF-YOLOX algorithm, specifically including the following steps: Step S0: Obtain the URL parameter through the lead seal identification interface, wherein the URL parameter corresponds to the network OSS file URL of the target file; Perform a validity check on the URL parameters. If the check result is invalid, terminate the entire detection process. If the check result is valid, extract the corresponding request parameters, download the target file based on the network OSS file address URL, and perform a file validity check on the target file. After the file validity check passes, output the lead-sealed file to be processed. Step S1: Construct the ACF-YOLOX algorithm, which includes a backbone network, a neck network, and a head network. The backbone network is CSPDarknet, and a CA attention mechanism is introduced in the key output layer of feature extraction. The neck network is an improved feature fusion pyramid structure, with the first half being FPN and the second half being PAN, and new AFM adaptive feature fusion units and CFM cross-scale feature fusion units are added. The head network is a decoupled head network that separates classification and regression tasks. The file type of the lead seal document to be processed is validated. If the validation result is invalid, the entire detection process is terminated. If the validation result is valid, the ACF-YOLOX algorithm is used to recognize the lead seal image corresponding to the lead seal document to be processed, obtain the location of the lead seal and the lead seal number, and return the corresponding recognition coordinates. Step S2: Calculate the area of ​​the lead seal recognition frame, the area of ​​the lead seal number recognition frame, and the intersection area of ​​the lead seal recognition frame and the lead seal number recognition frame based on the recognition coordinates. Make a judgment according to a preset threshold. The threshold is determined by the ratio of the intersection area of ​​the lead seal recognition frame and the lead seal number recognition frame to the area of ​​the lead seal recognition frame. Then, the target area for subsequent OCR recognition is selected and the effective recognition coordinates are output. Step S3: If no valid recognition coordinates are obtained, global OCR recognition is performed directly; if valid recognition coordinates are obtained, the seal image is cropped according to the valid recognition coordinates to obtain a cropped image set; the cropped image set is checked for out-of-bounds errors. If it is determined to be out of bounds, the recognized information is organized and output; if it is determined not to be out of bounds, the loop iteration optimization process is started. Within the preset loop variable i, the cropped image is rotated at the corresponding angle and OCR recognition is performed; if the current recognition result does not reach the preset optimal standard, the current recognition result is included in the total result set and the loop continues to traverse. After the traversal is completed, the seal number text with the highest confidence is output.

[0008] Furthermore, in step S0, performing a validity check on the URL parameter specifically includes: Verify that the URL format conforms to the OSS file address specification (such as including key components like the OSS service domain name, bucket path, and file identifier); verify that the URL has valid access permissions (to avoid files failing to download due to invalid permissions); and verify that the target file pointed to by the URL exists (excluding invalid links or deleted files).

[0009] Furthermore, the corresponding request parameters include the obtained network OSS file address URL (used to locate the target file) and the supporting parameters required for the interface call (such as identity verification parameters, file configuration parameters, etc., used to support the normal execution of the file download process).

[0010] Furthermore, the validity verification of the file specifically includes verifying the integrity of the downloaded file (ensuring that the file is not damaged or missing any key data) and verifying whether the file is a valid file that can be processed later (excluding empty files and abnormal files that cannot be parsed).

[0011] Furthermore, the ACF-YOLOX algorithm described in step S1 is specifically composed of a backbone network, a neck network, and a head network working together. Each network module performs its own function and works in deep collaboration to achieve end-to-end intelligent recognition of the seal image.

[0012] Furthermore, CSPDarknet is adopted as the basic backbone network. By utilizing the cross-stage local network structure of CSPDarknet, the efficiency of feature reuse is improved while reducing the amount of computation, thus providing a stable foundation for lead seal feature extraction. Furthermore, this invention embeds a Coordinate Attention (CA) mechanism into the Dark2, Dark3, and Dark4 output layers of CSPDarknet as an improvement to CSPDarknet; The CA attention mechanism enables the model to automatically learn the importance weights of different regions in an image, focus on the key features of the seal and its serial number, suppress background noise interference, and thus enhance the model's ability to extract features from seal targets at different scales, improving the accuracy and robustness of detection.

[0013] Furthermore, the neck network is an improved feature fusion pyramid structure. The first half retains the FPN (Feature Pyramid Network) and the second half retains the PAN (Path Aggregation Network). Feature interaction is enhanced through the addition of new modules and optimized connection methods, specifically including: The original pyramid structure of the PAN is retained to ensure the basic transmission link between the bottom and high-level features. A new dynamic cross-connection layer and a lightweight hybrid attention mechanism are added to break the unidirectional limitation of feature transmission in the traditional FPN-PAN structure, strengthen the direct information interaction between the Dark layers of the backbone network and the head network, and improve the efficiency of feature transmission.

[0014] The AFM (Adaptive Complementary Fusion Module) and CFM (Cross Scale Feature Fusion Module) are introduced. These two modules work together with the original FPN-PAN structure to achieve adaptive focusing fusion of features within the backbone network and skip-layer complementary fusion of features across multiple scales in the cross-structure, respectively.

[0015] Furthermore, the AFM adaptive feature fusion unit is an attention-based adaptive feature fusion unit that captures key region information within the backbone network features through a self-attention mechanism, enhancing the feature local perception capability and contextual relevance; the AFM adaptive feature fusion unit is embedded in the feature interaction path between layers 1-3 of the FPN; The AFM adaptive feature fusion unit specifically includes two main branches: an upsampling fusion structure and a downsampling fusion structure. The feature input and processing logic of each branch are as follows: The downsampling fusion structure receives the basic convolutional layer feature map from FPN layer-1 of the upper FPN, and the upsampling fusion structure receives the basic convolutional layer feature map from FPN layer-2 of the upper FPN; wherein, the basic convolutional layer feature maps output by FPN layer-1 and FPN layer-2 are both derived from the intermediate features of the backbone network after the initial convolutional processing of the FPN layer. Furthermore, the downsampling fusion structure is implemented using the adaptive feature fusion layer-1 as the specific carrier. The adaptive feature fusion layer-1 collects the feature maps output by the backbone network Dark3 and Dark4 respectively. Pooling and dimensionality enhancement are performed on the Dark3 feature map in sequence, and convolutional feature enhancement is performed on the Dark4 feature map. Then, the two processed feature maps are merged along the channel dimension. After dimensionality enhancement and calibration in the channel dimension, the fused feature of the downsampling fusion structure is output. The downsampling fusion structure receives the base convolutional layer feature map from FPN layer-1 of the upper FPN. The corresponding original FPN layer feature is the base convolutional layer feature of FPN layer-1 before it is fused with the output feature of the AFM adaptive feature fusion unit. The fused output feature of the downsampling fusion structure is then fused with the original feature of FPN layer-1. The specific process is as follows: The adaptive feature fusion layer-1 receives the feature map with C=128 channels and size S=80×80 output by the backbone network Dark3, and the feature map with C=256 channels and size S=40×40 output by Dark4. The Dark3 feature map is first passed through a 3×3 max pooling layer with stride=2, halving the feature map size to 40×40 while maintaining 128 channels. Then, it passes through a 3×3 convolutional layer with stride=2, increasing the number of channels to 256 and further halving the size to 20×20. Finally, it passes through a 1×1 pointwise convolutional layer, keeping the size 20×20 unchanged while doubling the number of channels, resulting in a 20×20 feature map with 512 channels. The specific expression is as follows:

[0016] in, The image shows the final feature map result after the Dark3 backbone network output feature map is processed by the adaptive feature fusion layer-1. This indicates that the current layer is the adaptive feature fusion layer -1. Represents a convolutional layer. Represents the max pooling layer. This represents the original feature map output by the Dark3 backbone network. The step size.

[0017] The Dark4 feature map is processed through a 3×3 convolutional layer with stride=2 to increase the number of channels to 512 and halve the size to 20×20. Then, a 1×1 pointwise convolutional layer is used to calibrate the feature distribution, keeping the number of channels 512 and the size 20×20 unchanged, resulting in a feature map with 512 channels and a size of 20×20. The specific expression is as follows:

[0018] in, The image shows the final feature map result after the Dark4 backbone network output feature map is processed by the adaptive feature fusion layer-1. This indicates that the current layer is the adaptive feature fusion layer -1. Represents a convolutional layer. This represents the original feature map output by the Dark4 backbone network. The step size.

[0019] The feature maps processed from the two paths are then merged (Concat) along the dimension with 1 channel count (dim=1) to obtain a fused feature map with 1024 channels and a size of 20×20. This fused feature map is then increased in dimension by a 3×3 convolutional layer with a stride of 1, resulting in a feature map output with 512 channels and a size of 20×20. The specific expression is as follows:

[0020] in, This is the final output feature map of the adaptive feature fusion layer-1. The image shows the final feature map result after the Dark3 backbone network output feature map is processed by the adaptive feature fusion layer-1. The image shows the final feature map result after the Dark4 backbone network output feature map is processed by the adaptive feature fusion layer-1. Represents a convolutional layer. This is a feature map channel dimension merging operation; Furthermore, the upsampling fusion structure is implemented using the adaptive feature fusion layer-2. The adaptive feature fusion layer-2 collects the feature maps output by the backbone network Dark4 and Dark5 respectively. The Dark4 feature map is processed by pointwise convolutional channel adjustment and local feature extraction. The Dark5 feature map is processed by pointwise convolutional channel adjustment and tensor difference calculation to enhance feature difference processing. Then, the two processed feature maps are merged along the channel dimension. After channel dimension upscaling calibration, the fused feature of the upsampling fusion structure is output. The upsampling fusion structure receives the base convolutional layer feature map from FPN layer-2 of the upper FPN. The corresponding original FPN layer feature is the base convolutional layer feature of FPN layer-2 before it is fused with the output feature of the AFM adaptive feature fusion unit. The fused output feature of the upsampling fusion structure is then fused with this original feature of FPN layer-2. The specific process is as follows: The adaptive feature fusion layer-2 receives the feature map with C=256 channels and size S=40×40 output from the backbone network Dark4, and the feature map with C=512 channels and size S=20×20 output from Dark5. The Dark4 feature map is initialized and calibrated using a 1×1 pointwise convolutional layer with stride=1, maintaining 256 channels and a size of 40×40. Then, a 3×3 convolutional layer with stride=1 is used to extract local features, again maintaining 256 channels and a size of 40×40, resulting in a feature map with 256 channels and a size of 40×40. The specific expression is as follows:

[0021] in, The image shows the final feature map result after the Dark4 backbone network output feature map is processed by the adaptive feature fusion layer-2. This indicates that the current layer is the adaptive feature fusion layer -2. Represents a convolutional layer. This represents the original feature map output by the Dark4 backbone network. The step size.

[0022] The Dark5 feature map is reduced to 256 channels while maintaining the size of 20×20 using a 1×1 pointwise convolutional layer with stride=1, resulting in a feature map of size 20×20 with 256 channels. Then, the size is increased by a factor of 2 to 40×40 using a tensor interpolation function, while keeping the number of channels unchanged at 256, resulting in a feature map of size 40×40 with 256 channels. The specific expression is as follows:

[0023] in, The image shows the final feature map result after the Dark5 backbone network output feature map is processed by the adaptive feature fusion layer-2. This indicates that the current layer is the adaptive feature fusion layer -2. Represents a convolutional layer. This represents the original feature map output by the Dark5 backbone network. Step size, This is a function for calculating tensor differences.

[0024] The feature maps processed from the two branches are merged along the dimension with the number of channels dim=1 to obtain a fused feature map with 512 channels and a size of 40×40. This fused feature map is then upscaled and calibrated to a feature map with 256 channels and a size of 40×40 using a 3×3 convolutional layer with a stride of 1. The specific expression is as follows:

[0025] in, This is the final output feature map of the adaptive feature fusion layer-2. The image shows the final feature map result after the Dark4 backbone network output feature map is processed by the adaptive feature fusion layer-2. The image shows the final feature map result after the Dark5 backbone network output feature map is processed by the adaptive feature fusion layer-2. Represents a convolutional layer. This is an operation to merge the channel dimensions of the feature map.

[0026] Furthermore, the CFM cross-scale feature fusion unit is a cross-scale feature fusion unit based on convolutional neural networks, embedded in the cross-connection path between the PAN layer of the neck network and the Dark layer of the backbone network. Its core function is to achieve skip-layer concatenation and deep fusion of features at different scales between the backbone network (Dark layer) and the pyramid network (PAN layer), thereby enhancing the model's feature extraction capability for multi-scale sealed targets. Its related symbols are defined as follows: The backbone network features (from the Dark layer) are denoted as:

[0027] in, , , These represent the number of channels, height, and width of the feature map, respectively. The features of the pyramid network (from the PAN layer) are denoted as:

[0028] in, , , These represent the number of channels, height, and width of the feature map, respectively, and are assumed to be present during input. = , = (Size alignment); The unified parameter characteristics of the backbone network are denoted as:

[0029] in, The learnable parameters are for a 1×1 pointwise convolution. This indicates a change in the number of channels, and the change must be a multiple of 2, used to adapt to subsequent fusion requirements.

[0030] Furthermore, the fusion process of the CFM cross-scale feature fusion unit includes a fusion process that does not require channel changes and a fusion process that requires channel changes; Furthermore, if Number of channels and Number of channels If they are equal, it is determined that the fusion process does not require channel changes and can be directly performed. Perform feature fusion convolution processing, and then... Concat along the channel dimension to obtain the dimension. The concatenated features are then deeply fused through a convolutional layer (ConvFuse) containing an attention layer, resulting in an output dimension of... The fusion feature, specifically expressed as:

[0031] Furthermore, if Number of channels and Number of channels If they are not equal, it is determined that a fusion process requiring channel changes is needed. First, a 1×1 pointwise convolution is performed to... Convert to uniform parameter features Adjust the number of channels to Then and By concatenating along the channel dimension, we obtain a dimension of The concatenated features are then fused through a ConvFuse convolutional layer, resulting in an output dimension of [dimensionality missing]. The fusion features ensure effective complementarity of cross-scale features. The specific expression for this process is:

[0032] The introduction of dynamic cross-connection layers and lightweight hybrid attention mechanisms strengthens the feature interaction between the backbone network and the head network, reducing information loss during feature transmission. The AFM adaptive feature fusion unit achieves precise focusing and enhanced correlation of features at different levels within the backbone network through adaptive feature fusion, improving the local feature perception capability. The CFM cross-scale feature fusion unit broadens the feature receptive field through cross-structure and cross-scale feature skipping layer fusion, enabling the model to adapt to seals and seal number features of different sizes and environments. The collaborative work of the two fusion modules constructs a multi-dimensional and multi-level feature fusion system, providing the head network with more comprehensive and accurate feature inputs, effectively supporting the classification and localization tasks of seal targets, and significantly improving the overall detection performance.

[0033] Furthermore, the head network, also known as the decoupled head network, is the target detection terminal and result output core of the ACF-YOLOX algorithm. It receives the multi-scale fusion features output by the neck network, separates the classification and regression tasks, and processes category prediction and location prediction separately through independent branches. This reduces the mutual interference between the two tasks, thereby improving the convergence speed and detection accuracy of the model. The specific technical solution is as follows: The core structure of the head network revolves around two independent task branches. The classification branch focuses on the category prediction task, and its core function is to determine whether the detection area is the target (seal or seal number) and output the corresponding category confidence score, which provides a basis for the subsequent selection of effective target areas. The regression branch focuses on the location prediction task. Its core function is to calculate the bounding box coordinates of the valid targets determined by the classification branch and output accurate positioning information. These bounding box coordinates are the key data for the seal identification box (G) and the seal number identification box (P), which directly support the subsequent threshold judgment based on the coordinate area of ​​the seal identification box and the seal number identification box.

[0034] The input to the head network is the multi-scale fusion feature output from the neck network, specifically the feature map optimized by the AFM adaptive feature fusion unit and the CFM cross-scale feature fusion unit, ensuring the comprehensiveness and effectiveness of the feature input. Its output includes category prediction and location prediction results. The category prediction result is the confidence level of the detected region belonging to the seal or seal number, used to determine the target's validity and provide a basis for subsequent screening of valid identification regions. The location prediction result is the identification coordinate address of the seal and seal number, specifically the four-dimensional bounding box coordinates of the seal identification box (G) and the seal number identification box (P), with the upper left x-coordinate of G as the x-coordinate. Top left ordinate The horizontal coordinate of the lower right corner bottom right ordinate The x-coordinate of the upper left corner of P Top left ordinate The horizontal coordinate of the lower right corner bottom right ordinate .

[0035] Furthermore, step S2 specifically includes: Based on the position prediction results output by the head network, the area G of the lead seal recognition frame, the area P of the lead seal number recognition frame, and the intersection area Intersection(G,P) (i.e., G∩P) of the two are calculated. The area calculation value is the absolute value of the difference between the x-coordinate of the upper left corner and the x-coordinate of the lower right corner, multiplied by the absolute value of the difference between the y-coordinate of the upper left corner and the y-coordinate of the lower right corner. The specific formula is as follows:

[0036] in, This is a set of area calculation results. This represents the area of ​​the lead seal identification frame. This represents the area of ​​the lead seal identification frame.

[0037] Threshold determination is based on the ratio of the intersection area to the area of ​​the lead seal recognition frame, with a preset threshold of 0.9. The specific formula is as follows:

[0038] in, This is the ratio of the intersection area to the area of ​​the lead seal identification frame. This is the intersection of the area of ​​the lead seal identification frame and the area of ​​the lead seal number identification frame. This represents the area of ​​the lead seal identification frame.

[0039] When the ratio of the intersection area to the area of ​​the seal recognition frame is greater than or equal to 0.9, the seal recognition frame area is determined as the target area for subsequent OCR recognition, and the corresponding valid recognition coordinates are output; when the ratio of the intersection area to the area of ​​the seal recognition frame is less than 0.9, the match is deemed invalid, and the area is not included in the OCR recognition range.

[0040] Furthermore, step S3 specifically includes: If no valid recognition coordinates are obtained (i.e., no target area for the seal number that meets the threshold requirement is selected), the global OCR recognition process is started directly to extract the full text content from the seal image. If valid recognition coordinates are obtained, the original seal image is precisely cropped based on the recognition coordinates to focus on the target area corresponding to the seal number, effectively eliminating background interference such as container bodies and environmental debris in port scenes, and improving the targeting and efficiency of OCR recognition.

[0041] After cropping, a list of cropped images of the target area is obtained. First, an out-of-bounds judgment is performed on the list. If it is determined to be out of bounds, the post-processing stage of the recognition results is directly entered, where the acquired recognition information is sorted, summarized and output. If it is determined not to be out of bounds, the loop recognition and result optimization process is started.

[0042] After entering the loop recognition and result optimization process, first determine whether the loop variable i is less than 4. If i < 4, then perform the corresponding angle rotation operation on the current cropped image (where i = 0 keeps the cropped image from rotating, i = 1 performs a 90-degree clockwise rotation, i = 2 performs a 90-degree counterclockwise rotation, and i = 3 performs a 180-degree rotation). If i ≥ 4, then skip the rotation step. Then, perform OCR recognition on the cropped image after rotation (or without rotation), and simultaneously record the best recognition result (denoted as best_res) and the best confidence score (denoted as best_score) obtained in this recognition, and increment the loop variable i by 1. If the current recognition result does not reach the preset optimal standard, then add the recognized text content to the total result set, flip the page to extract the next cropped image in the cropped image list, and repeat the above rotation, recognition, and recording process until all cropped images have been traversed or the best recognition result is obtained.

[0043] Furthermore, the preset optimal standard is set according to the actual application scenario. For example, a confidence threshold of ≥0.95 is preset. When the confidence of the current OCR recognition reaches or exceeds the threshold, it is determined that the optimal recognition result has been obtained, and the current loop recognition process of the cropped image is terminated.

[0044] After all the loop recognition and optimization processes for cropped images are completed, all the recorded recognition results are integrated and processed, and the seal text with the highest confidence is selected as the final output.

[0045] Secondly, the present invention provides a container lead seal identification and detection system based on the ACF-YOLOX algorithm, including a file acquisition and parameter verification module, an ACF-YOLOX algorithm construction and position prediction module, a recognition box area calculation and effective coordinate filtering module, and a cropped image rotation optimization and text recognition module. The file acquisition and parameter verification module, in which: The URL parameter is obtained through the lead seal recognition interface. The URL parameter corresponds to the URL of the target file's network OSS file. The URL parameter is validated for validity. If the validation result is invalid, the entire detection process is terminated. If the validation result is valid, the corresponding request parameters are extracted, and the target file is downloaded based on the network OSS file address URL. The file validity of the target file is then validated. After the file validity validation is passed, the lead seal file to be processed is output. The ACF-YOLOX algorithm construction and location prediction module includes: The ACF-YOLOX algorithm is constructed with CSPDarknet as the backbone network and an attention mechanism introduced in the key output layer of feature extraction. The neck network is an improved feature fusion pyramid structure, with FPN in the front half and PAN in the back half, and AFM adaptive feature fusion unit and CFM cross-scale feature fusion unit are added. The head network is a decoupled head network that separates classification and regression tasks. The file type of the lead seal document to be processed is validated. If the validation result is invalid, the entire detection process is terminated. If the validation result is valid, the ACF-YOLOX algorithm is used to recognize the lead seal image corresponding to the lead seal document to be processed, obtain the location of the lead seal and the lead seal number, and return the corresponding recognition coordinates. The module for calculating the area of ​​the recognition box and filtering effective coordinates includes: Based on the recognition coordinates, calculate the area of ​​the lead seal recognition frame, the area of ​​the lead seal number recognition frame, and the intersection area of ​​the lead seal recognition frame and the lead seal number recognition frame. Make a judgment according to a preset threshold. The threshold is determined by the ratio of the intersection area of ​​the lead seal recognition frame and the lead seal number recognition frame to the area of ​​the lead seal recognition frame. Then, select the target area for subsequent OCR recognition and output the effective recognition coordinates. The image cropping rotation optimization and text recognition module includes: If no valid recognition coordinates are obtained, global OCR recognition is performed directly. If valid recognition coordinates are obtained, the seal image is cropped according to the valid recognition coordinates to obtain a cropped image set. The cropped image set is checked for out-of-bounds errors. If it is determined to be out of bounds, the recognized information is organized and output. If it is determined to be within bounds, a loop iterative optimization process is started. Within the preset loop variable i, the cropped image is rotated at the corresponding angle and OCR recognition is performed. If the current recognition result does not meet the preset optimal standard, the current recognition result is included in the total result set and the loop continues. After the loop is completed, the seal number text with the highest confidence is output.

[0046] Thirdly, the present invention provides an electronic device, including at least one processor; and a memory communicatively connected to the at least one processor; the memory stores computer program instructions executable by the at least one processor, the computer program instructions being executed by the at least one processor to enable the at least one processor to execute the container seal identification and detection method based on the ACF-YOLOX algorithm.

[0047] Fourthly, the present invention provides a computer-readable storage medium storing computer instructions that cause the computer to execute the container seal identification and detection method based on the ACF-YOLOX algorithm.

[0048] The beneficial effects of this invention are as follows: By embedding the CA attention mechanism into the ACF-YOLOX algorithm, it effectively suppresses background noise interference such as variable lighting and container corrosion in complex port environments, improving the algorithm's stable recognition capability under harsh conditions; relying on the feature fusion unit design of the ACF-YOLOX algorithm, it achieves deep collaboration of multi-scale seal features, significantly improving feature fusion efficiency; through the synergistic effect of the CA attention mechanism and the feature fusion unit, it strengthens the positioning adaptability of seals and seal numbers, improves positioning accuracy, and avoids positioning deviations; by adding a seal number target area validity screening step, it accurately locks the effective area for OCR recognition based on the area intersection ratio threshold and performs targeted cyclic rotation, significantly reducing the false recognition rate while improving recognition efficiency; adopting a modular algorithm architecture improves the technical versatility, allowing flexible migration to similar small target recognition scenarios without extensive customized parameter adjustments, thus broadening the adaptation range; and constructing an end-to-end automated recognition process, it achieves unmanned intervention throughout the entire process, eliminating the need for manual review, reducing deployment costs and manpower dependence, and meeting the operational needs of digital and intelligent port logistics.

[0049] Furthermore, the design principle of this invention is reliable, the structure is simple, and it has a very wide range of application prospects.

[0050] Therefore, it is evident that the present invention has outstanding substantive features and significant progress compared with the prior art, and the beneficial effects of its implementation are also obvious. Attached Figure Description

[0051] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0052] Figure 1 This invention provides an overall flowchart of a container lead seal identification and detection method based on the ACF-YOLOX algorithm.

[0053] Figure 2 This is the original YOLOX network structure diagram.

[0054] Figure 3 The present invention provides an ACF-YOLOX network structure diagram for a container lead seal identification and detection method based on the ACF-YOLOX algorithm.

[0055] Figure 4 This invention provides a structural diagram of the CA attention mechanism in a container lead seal identification and detection method based on the ACF-YOLOX algorithm.

[0056] Figure 5 This is a diagram of the feature fusion pyramid structure of the original YOLOX network.

[0057] Figure 6 The present invention provides an AFM adaptive feature fusion unit adaptive feature fusion layer structure diagram for a container lead seal identification and detection method based on the ACF-YOLOX algorithm.

[0058] Figure 7 This invention provides a CFM cross-scale feature fusion unit feature fusion pyramid structure diagram for a container lead seal identification and detection method based on the ACF-YOLOX algorithm.

[0059] Figure 8 This invention provides a schematic diagram of an electronic device structure. Detailed Implementation

[0060] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. The following embodiments are explanations of the present invention, but the present invention is not limited to the following implementation methods.

[0061] Example 1: This embodiment uses Ubuntu 22.04 as the operating system; the processor is an Intel(R) Core(TM) i7-14700 with 14 cores; the memory capacity is 32GB; and the graphics card is an NVIDIA RTX4070Ti Super with 16GB of video memory. Additionally, the miniforge virtual environment required for deep learning is installed, with Python version 3.10 and CUDA version 12.8.

[0062] The basic training settings for this embodiment are as follows: the input image size is 640×640; the model seed is set to 0; the training epochs are 100, with the first 5 epochs using a warm-up training method; the optimizer is selected as stochastic gradient descent (SGD); the learning rate is calculated as current learning rate × batch size / 64, using an initial learning rate of 0.01, and no pre-trained weights are used in any network during training. The object detection evaluation metric is:

[0063]

[0064]

[0065] in, Precision represents the accuracy of the model's prediction of positive samples of lead seals. Recall rate is the percentage of seals correctly identified by the calculation model out of all images of that type. (Mean Average Precision) represents the average precision across all categories. The average precision across all categories is the average of the precision and recall area calculated separately for each type of seal within the range. (True Positive) represents positive samples that are predicted as positive by the model, that is, the types and number of lead seals that are correctly detected; (False Positive) represents negative samples that are predicted as positive by the model, i.e., the number of false reports of defects in wood-based panels; (False Negative) represents the number of positive samples that the model predicts as negative, i.e., the number of positive samples that were missed in the lead seal.

[0066] To verify the effectiveness of the AFM adaptive feature fusion unit and CFM cross-scale feature fusion unit in the ACF-YOLOX algorithm, ablation experiments were conducted on a dedicated dataset of container lead seals using the YOLOX algorithm as the baseline model. The generalization ability and structural advantages of each module were verified, and the experimental results are shown in the table below: Table 1

[0067] This embodiment uses the YOLOX algorithm as the baseline model, which achieves an mAP@50 of 97.81% and an mAP@50:95 of 70.46% in the container seal recognition task. To verify the technical effectiveness of the ACF-YOLOX algorithm model constructed in this embodiment, three sets of comparison models were set up: Model 1 integrates only the AFM adaptive feature fusion unit; Model 2 integrates only the CFM cross-scale feature fusion unit; Model 3 is the ACF-YOLOX algorithm model provided in this embodiment, integrating both the AFM adaptive feature fusion unit and the CFM cross-scale feature fusion unit. Experimental data show that the mAP@50 and mAP@50:95 indicators of the three comparison models are improved to varying degrees compared with the baseline model, proving that the AFM adaptive feature fusion unit and the CFM cross-scale feature fusion unit make a positive contribution to optimizing the seal recognition performance of the model.

[0068] Specifically, after integrating the AFM adaptive feature fusion unit, Model 1 improved mAP@50 from 97.81% to 98.07% of the baseline model, and mAP@50:95 from 70.46% to 73.01%. This result demonstrates that the AFM adaptive feature fusion unit effectively optimizes target detection performance, achieving steady improvement on the relatively lenient mAP@50 metric, and showing a more significant improvement on the more stringent mAP@50:95 metric. This indicates that the attention-based adaptive feature fusion function enables the model to accurately capture target features under different IoU thresholds in the lead seal recognition task, effectively improving the model's precision in lead seal target localization.

[0069] When Model 2 integrates the CFM cross-scale feature fusion unit alone, the overall model architecture remains unchanged. Only three feature merging operations are performed in the feature output stage, resulting in an improvement in mAP@50 to 97.94% and mAP@50:95 to 71.93%. Compared with the baseline model, the CFM cross-scale feature fusion unit effectively improves the model's overall detection capability for lead-sealed targets by enhancing the feature fusion efficiency of the backbone network and the pyramid network.

[0070] The ACF-YOLOX algorithm model provided in this embodiment integrates both the AFM adaptive feature fusion unit and the CFM cross-scale feature fusion unit, achieving optimal performance with mAP@50 reaching 99.13% and mAP@50:95 reaching 74.18%. Compared to Model 1 and Model 2, which integrate only a single unit, the improvements in both metrics are more significant. This indicates a synergistic effect between the AFM adaptive feature fusion unit and the CFM cross-scale feature fusion unit. Their combined efforts fully leverage their respective advantages, further enhancing the overall performance of the model in object detection tasks. This results in a significant improvement not only in the accuracy of object detection but also in the fineness of object localization.

[0071] This embodiment provides a method for identifying and detecting lead seals on containers based on the ACF-YOLOX algorithm, such as... Figure 1 As shown, the specific steps include: Step S0: Obtain the URL parameter through the lead seal identification interface, wherein the URL parameter corresponds to the network OSS file URL of the target file; Perform a validity check on the URL parameters. If the check result is invalid, terminate the entire detection process. If the check result is valid, extract the corresponding request parameters, download the target file based on the network OSS file address URL, and perform a file validity check on the target file. After the file validity check passes, output the lead-sealed file to be processed. Step S1: Construct the ACF-YOLOX algorithm. The backbone network is CSPDarknet, and an attention mechanism is introduced into the key output layer of feature extraction as an improvement of CSPDarknet. The neck network is an improved feature fusion pyramid structure, with FPN in the front half and PAN in the back half, and AFM adaptive feature fusion unit and CFM cross-scale feature fusion unit are added. The head network is a decoupled head network that separates classification and regression tasks. The file type of the lead seal document to be processed is validated. If the validation result is invalid, the entire detection process is terminated. If the validation result is valid, the ACF-YOLOX algorithm is used to recognize the lead seal image corresponding to the lead seal document to be processed, obtain the location of the lead seal and the lead seal number, and return the corresponding recognition coordinates. Step S2: Calculate the area of ​​the lead seal recognition frame, the area of ​​the lead seal number recognition frame, and the intersection area of ​​the lead seal recognition frame and the lead seal number recognition frame based on the recognition coordinates. Make a judgment according to a preset threshold. The threshold is determined by the ratio of the intersection area of ​​the lead seal recognition frame and the lead seal number recognition frame to the area of ​​the lead seal recognition frame. Then, the target area for subsequent OCR recognition is selected and the effective recognition coordinates are output. Step S3: If no valid recognition coordinates are obtained, global OCR recognition is performed directly; if valid recognition coordinates are obtained, the seal image is cropped according to the valid recognition coordinates to obtain a cropped image set; the cropped image set is checked for out-of-bounds errors. If it is determined to be out of bounds, the recognized information is organized and output; if it is determined not to be out of bounds, the loop iteration optimization process is started. Within the preset loop variable i, the cropped image is rotated at the corresponding angle and OCR recognition is performed; if the current recognition result does not reach the preset optimal standard, the current recognition result is included in the total result set and the loop continues to traverse. After the traversal is completed, the seal number text with the highest confidence is output.

[0072] Furthermore, in step S0, performing a validity check on the URL parameter specifically includes: Verify that the URL format conforms to the OSS file address specification (such as including key components like the OSS service domain name, bucket path, and file identifier); verify that the URL has valid access permissions (to avoid files failing to download due to invalid permissions); and verify that the target file pointed to by the URL exists (excluding invalid links or deleted files).

[0073] Furthermore, the corresponding request parameters include the obtained network OSS file address URL (used to locate the target file) and the supporting parameters required for the interface call (such as identity verification parameters, file configuration parameters, etc., used to support the normal execution of the file download process).

[0074] Furthermore, the validity verification of the file specifically includes verifying the integrity of the downloaded file (ensuring that the file is not damaged or missing any key data) and verifying whether the file is a valid file that can be processed later (excluding empty files and abnormal files that cannot be parsed).

[0075] The original YOLOX algorithm network structure is as follows: Figure 2 As shown; The ACF-YOLOX algorithm described in step S1, as follows: Figure 3 As shown, it is specifically composed of a backbone network, a neck network, and a head network working together. Each network module performs its own function and works in deep collaboration to achieve end-to-end intelligent recognition of lead seal images.

[0076] Furthermore, CSPDarknet is adopted as the basic backbone network. By utilizing the cross-stage local network structure of CSPDarknet, the efficiency of feature reuse is improved while reducing the amount of computation, thus providing a stable foundation for lead seal feature extraction. Furthermore, this invention embeds a Coordinate Attention (CA) mechanism into the Dark2, Dark3, and Dark4 output layers of CSPDarknet as an improvement to CSPDarknet; like Figure 4 As shown, the CA attention mechanism enables the model to automatically learn the importance weights of different regions in the image, focus on the key features of the seal and its serial number, suppress background noise interference, and thus enhance the model's ability to extract features from seal targets at different scales, thereby improving the accuracy and robustness of detection.

[0077] The original YOLOX network feature fusion pyramid structure is as follows: Figure 5 As shown, the neck network is an improved feature fusion pyramid structure. The first half uses FPN (Feature Pyramid Network) and the second half uses PAN (Path Aggregation Network). Feature interaction is enhanced by adding new modules and optimizing connection methods, specifically including: The original pyramid structure of the PAN is retained to ensure the basic transmission link between the bottom and high-level features. A new dynamic cross-connection layer and a lightweight hybrid attention mechanism are added to break the unidirectional limitation of feature transmission in the traditional FPN-PAN structure, strengthen the direct information interaction between the Dark layers of the backbone network and the head network, and improve the efficiency of feature transmission.

[0078] The AFM (Adaptive Complementary Fusion Module) and CFM (Cross Scale Feature Fusion Module) are introduced. These two modules work together with the original FPN-PAN structure to achieve adaptive focusing fusion of features within the backbone network and skip-layer complementary fusion of features across multiple scales of the cross-structure, respectively.

[0079] Furthermore, the AFM adaptive feature fusion unit is an attention-based adaptive feature fusion unit that captures key region information within the backbone network features through self-attention, enhancing the feature's local perception capability and contextual relevance; for example... Figure 6 As shown; the AFM adaptive feature fusion unit is embedded in the feature interaction path between layers 1-3 of FPN; The AFM adaptive feature fusion unit specifically includes two main branches: an upsampling fusion structure and a downsampling fusion structure. The feature input and processing logic of each branch are as follows: The downsampling fusion structure receives the basic convolutional layer feature map from FPN layer-1 of the upper FPN, and the upsampling fusion structure receives the basic convolutional layer feature map from FPN layer-2 of the upper FPN; wherein, the basic convolutional layer feature maps output by FPN layer-1 and FPN layer-2 are both derived from the intermediate features of the backbone network after the initial convolutional processing of the FPN layer. Furthermore, the downsampling fusion structure is implemented using the adaptive feature fusion layer-1 as the specific carrier. The adaptive feature fusion layer-1 collects the feature maps output by the backbone network Dark3 and Dark4 respectively. Pooling and dimensionality enhancement are performed on the Dark3 feature map in sequence, and convolutional feature enhancement is performed on the Dark4 feature map. Then, the two processed feature maps are merged along the channel dimension. After dimensionality enhancement and calibration in the channel dimension, the fused feature of the downsampling fusion structure is output. The downsampling fusion structure receives the base convolutional layer feature map from FPN layer-1 of the upper FPN. The corresponding original FPN layer feature is the base convolutional layer feature of FPN layer-1 before it is fused with the output feature of the AFM adaptive feature fusion unit. The fused output feature of the downsampling fusion structure is then fused with the original feature of FPN layer-1. The specific process is as follows: The adaptive feature fusion layer-1 receives the feature map with C=128 channels and size S=80×80 output by the backbone network Dark3, and the feature map with C=256 channels and size S=40×40 output by Dark4. The Dark3 feature map is first passed through a 3×3 max pooling layer with stride=2, halving the feature map size to 40×40 while maintaining 128 channels. Then, it passes through a 3×3 convolutional layer with stride=2, increasing the number of channels to 256 and further halving the size to 20×20. Finally, it passes through a 1×1 pointwise convolutional layer, keeping the size 20×20 unchanged while doubling the number of channels, resulting in a 20×20 feature map with 512 channels. The specific expression is as follows:

[0080] in, The image shows the final feature map result after the Dark3 backbone network output feature map is processed by the adaptive feature fusion layer-1. This indicates that the current layer is the adaptive feature fusion layer -1. Represents a convolutional layer. Represents the max pooling layer. This represents the original feature map output by the Dark3 backbone network. The step size.

[0081] The Dark4 feature map is processed through a 3×3 convolutional layer with stride=2 to increase the number of channels to 512 and halve the size to 20×20. Then, a 1×1 pointwise convolutional layer is used to calibrate the feature distribution, keeping the number of channels 512 and the size 20×20 unchanged, resulting in a feature map with 512 channels and a size of 20×20. The specific expression is as follows:

[0082] in, The image shows the final feature map result after the Dark4 backbone network output feature map is processed by the adaptive feature fusion layer-1. This indicates that the current layer is the adaptive feature fusion layer -1. Represents a convolutional layer. This represents the original feature map output by the Dark4 backbone network. The step size.

[0083] The feature maps processed from the two paths are then merged (Concat) along the dimension with 1 channel count (dim=1) to obtain a fused feature map with 1024 channels and a size of 20×20. This fused feature map is then increased in dimension by a 3×3 convolutional layer with a stride of 1, resulting in a feature map output with 512 channels and a size of 20×20. The specific expression is as follows:

[0084] in, This is the final output feature map of the adaptive feature fusion layer-1. The image shows the final feature map result after the Dark3 backbone network output feature map is processed by the adaptive feature fusion layer-1. The image shows the final feature map result after the Dark4 backbone network output feature map is processed by the adaptive feature fusion layer-1. Represents a convolutional layer. This is a feature map channel dimension merging operation; Furthermore, the upsampling fusion structure is implemented using the adaptive feature fusion layer-2. The adaptive feature fusion layer-2 collects the feature maps output by the backbone network Dark4 and Dark5 respectively. The Dark4 feature map is processed by pointwise convolutional channel adjustment and local feature extraction. The Dark5 feature map is processed by pointwise convolutional channel adjustment and tensor difference calculation to enhance feature difference processing. Then, the two processed feature maps are merged along the channel dimension. After channel dimension upscaling calibration, the fused feature of the upsampling fusion structure is output. The upsampling fusion structure receives the base convolutional layer feature map from FPN layer-2 of the upper FPN. The corresponding original FPN layer feature is the base convolutional layer feature of FPN layer-2 before it is fused with the output feature of the AFM adaptive feature fusion unit. The fused output feature of the upsampling fusion structure is then fused with this original feature of FPN layer-2. The specific process is as follows: The adaptive feature fusion layer-2 receives the feature map with C=256 channels and size S=40×40 output from the backbone network Dark4, and the feature map with C=512 channels and size S=20×20 output from Dark5. The Dark4 feature map is initialized and calibrated using a 1×1 pointwise convolutional layer with stride=1, maintaining 256 channels and a size of 40×40. Then, a 3×3 convolutional layer with stride=1 is used to extract local features, again maintaining 256 channels and a size of 40×40, resulting in a feature map with 256 channels and a size of 40×40. The specific expression is as follows:

[0085] in, The image shows the final feature map result after the Dark4 backbone network output feature map is processed by the adaptive feature fusion layer-2. This indicates that the current layer is the adaptive feature fusion layer -2. Represents a convolutional layer. This represents the original feature map output by the Dark4 backbone network. The step size.

[0086] The Dark5 feature map is reduced to 256 channels while maintaining the size of 20×20 using a 1×1 pointwise convolutional layer with stride=1, resulting in a feature map of size 20×20 with 256 channels. Then, the size is increased by a factor of 2 to 40×40 using a tensor interpolation function, while keeping the number of channels unchanged at 256, resulting in a feature map of size 40×40 with 256 channels. The specific expression is as follows:

[0087] in, The image shows the final feature map result after the Dark5 backbone network output feature map is processed by the adaptive feature fusion layer-2. This indicates that the current layer is the adaptive feature fusion layer -2. Represents a convolutional layer. This represents the original feature map output by the Dark5 backbone network. Step size, This is a function for calculating tensor differences.

[0088] The feature maps processed from the two branches are merged along the dimension with the number of channels dim=1 to obtain a fused feature map with 512 channels and a size of 40×40. This fused feature map is then upscaled and calibrated to a feature map with 256 channels and a size of 40×40 using a 3×3 convolutional layer with a stride of 1. The specific expression is as follows:

[0089] in, This is the final output feature map of the adaptive feature fusion layer-2. The image shows the final feature map result after the Dark4 backbone network output feature map is processed by the adaptive feature fusion layer-2. The image shows the final feature map result after the Dark5 backbone network output feature map is processed by the adaptive feature fusion layer-2. Represents a convolutional layer. This is an operation to merge the channel dimensions of the feature map.

[0090] Furthermore, the CFM cross-scale feature fusion unit is a cross-scale feature fusion unit based on a convolutional neural network, such as... Figure 7 As shown, the CFM cross-scale feature fusion unit is embedded in the cross-connection path between the PAN layer of the neck network and the Dark layer of the backbone network. Its core function is to achieve skip-layer splicing and deep fusion of features at different scales between the backbone network (Dark layer) and the pyramid network (PAN layer), thereby enhancing the model's ability to extract features from multi-scale sealed targets. Its related symbols are defined as follows: The backbone network features (from the Dark layer) are denoted as:

[0091] in, , , These represent the number of channels, height, and width of the feature map, respectively. The features of the pyramid network (from the PAN layer) are denoted as:

[0092] in, , , These represent the number of channels, height, and width of the feature map, respectively, and are assumed to be present during input. = , = (Size alignment); The unified parameter characteristics of the backbone network are denoted as:

[0093] in, The learnable parameters are for a 1×1 pointwise convolution. This indicates a change in the number of channels, and the change must be a multiple of 2, used to adapt to subsequent fusion requirements.

[0094] Furthermore, the fusion process of the CFM cross-scale feature fusion unit includes a fusion process that does not require channel changes and a fusion process that requires channel changes; Furthermore, the fusion process that requires no channel changes specifically involves: when the backbone network characteristics... Number of channels Features of pyramid networks Number of channels When meeting integration requirements, directly to Perform feature fusion convolution processing, and then... Concat along the channel dimension to obtain the dimension. The concatenated features are then deeply fused through a convolutional layer (ConvFuse) containing an attention layer, resulting in an output dimension of... The fusion feature, specifically expressed as:

[0095] Furthermore, the fusion process of channel changes needs to be specifically defined as follows: when Number of channels If the fusion requirements are not met, first use 1×1 pointwise convolution to... Convert to uniform parameter features Adjust the number of channels to Then and By concatenating along the channel dimension, we obtain a dimension of The concatenated features are then fused through a ConvFuse convolutional layer, resulting in an output dimension of [dimensionality missing]. The fusion features ensure effective complementarity of cross-scale features. The specific expression for this process is:

[0096] The introduction of dynamic cross-connection layers and lightweight hybrid attention mechanisms strengthens the feature interaction between the backbone network and the head network, reducing information loss during feature transmission. The AFM adaptive feature fusion unit achieves precise focusing and enhanced correlation of features at different levels within the backbone network through adaptive feature fusion, improving the local feature perception capability. The CFM cross-scale feature fusion unit broadens the feature receptive field through cross-structure and cross-scale feature skipping layer fusion, enabling the model to adapt to seals and seal number features of different sizes and environments. The collaborative work of the two fusion modules constructs a multi-dimensional and multi-level feature fusion system, providing the head network with more comprehensive and accurate feature inputs, effectively supporting the classification and localization tasks of seal targets, and significantly improving the overall detection performance.

[0097] Furthermore, the head network, also known as the decoupled head network, is the target detection terminal and result output core of the ACF-YOLOX algorithm. It receives the multi-scale fusion features output by the neck network, separates the classification and regression tasks, and processes category prediction and location prediction separately through independent branches. This reduces the mutual interference between the two tasks, thereby improving the convergence speed and detection accuracy of the model. The specific technical solution is as follows: The core structure of the head network revolves around two independent task branches. The classification branch focuses on the category prediction task, and its core function is to determine whether the detection area is the target (seal or seal number) and output the corresponding category confidence score, which provides a basis for the subsequent selection of effective target areas. The regression branch focuses on the location prediction task. Its core function is to calculate the bounding box coordinates of the valid targets determined by the classification branch and output accurate positioning information. These bounding box coordinates are the key data for the seal identification box (G) and the seal number identification box (P), which directly support the subsequent threshold judgment based on the coordinate area of ​​the seal identification box and the seal number identification box.

[0098] The input to the head network is the multi-scale fusion feature output from the neck network, specifically the feature map optimized by the AFM adaptive feature fusion unit and the CFM cross-scale feature fusion unit, ensuring the comprehensiveness and effectiveness of the feature input. Its output includes category prediction and location prediction results. The category prediction result is the confidence level of the detected region belonging to the seal or seal number, used to determine the target's validity and provide a basis for subsequent screening of valid identification regions. The location prediction result is the identification coordinate address of the seal and seal number, specifically the four-dimensional bounding box coordinates of the seal identification box (G) and the seal number identification box (P), with the upper left x-coordinate of G as the x-coordinate. Top left ordinate The horizontal coordinate of the lower right corner bottom right ordinate The x-coordinate of the upper left corner of P Top left ordinate The horizontal coordinate of the lower right corner bottom right ordinate .

[0099] Furthermore, step S2 specifically includes: Based on the position prediction results output by the head network, the area G of the lead seal recognition frame, the area P of the lead seal number recognition frame, and the intersection area Intersection(G,P) (i.e., G∩P) of the two are calculated. The area calculation value is the absolute value of the difference between the x-coordinate of the upper left corner and the x-coordinate of the lower right corner, multiplied by the absolute value of the difference between the y-coordinate of the upper left corner and the y-coordinate of the lower right corner. The specific formula is as follows:

[0100] in, This is a set of area calculation results. This represents the area of ​​the lead seal identification frame. This represents the area of ​​the lead seal identification frame.

[0101] Threshold determination is based on the ratio of the intersection area to the area of ​​the lead seal recognition frame, with a default threshold of 0.9. The specific formula is as follows:

[0102] in, This is the ratio of the intersection area to the area of ​​the lead seal identification frame. This is the intersection of the area of ​​the lead seal identification frame and the area of ​​the lead seal number identification frame. This represents the area of ​​the lead seal identification frame.

[0103] When the ratio of the intersection area to the area of ​​the seal recognition frame is greater than or equal to 0.9, the seal recognition frame area is determined as the target area for subsequent OCR recognition, and the corresponding valid recognition coordinates are output; when the ratio of the intersection area to the area of ​​the seal recognition frame is less than 0.9, the match is deemed invalid, and the area is not included in the OCR recognition range.

[0104] Furthermore, step S3 specifically includes: If no valid recognition coordinates are obtained (i.e., no target area for the seal number that meets the threshold requirement is selected), the global OCR recognition process is started directly to extract the full text content from the seal image. If valid recognition coordinates are obtained, the original seal image is precisely cropped based on the recognition coordinates to focus on the target area corresponding to the seal number, effectively eliminating background interference such as container bodies and environmental debris in port scenes, and improving the targeting and efficiency of OCR recognition.

[0105] After cropping, a list of cropped images of the target area is obtained. First, an out-of-bounds judgment is performed on the list. If it is determined to be out of bounds, the post-processing stage of the recognition results is directly entered, where the acquired recognition information is sorted, summarized and output. If it is determined not to be out of bounds, the loop recognition and result optimization process is started.

[0106] After entering the loop recognition and result optimization process, first determine whether the loop variable i is less than 4. If i < 4, then perform the corresponding angle rotation operation on the current cropped image (where i = 0 keeps the cropped image from rotating, i = 1 performs a 90-degree clockwise rotation, i = 2 performs a 90-degree counterclockwise rotation, and i = 3 performs a 180-degree rotation). If i ≥ 4, then skip the rotation step. Then, perform OCR recognition on the cropped image after rotation (or without rotation), and simultaneously record the best recognition result (denoted as best_res) and the best confidence score (denoted as best_score) obtained in this recognition, and increment the loop variable i by 1. If the current recognition result does not reach the preset optimal standard, then add the recognized text content to the total result set, flip the page to extract the next cropped image in the cropped image list, and repeat the above rotation, recognition, and recording process until all cropped images have been traversed or the best recognition result is obtained.

[0107] Furthermore, the preset optimal standard is set according to the actual application scenario. For example, a confidence threshold of ≥0.95 is preset. When the confidence of the current OCR recognition reaches or exceeds the threshold, it is determined that the optimal recognition result has been obtained, and the current loop recognition process of the cropped image is terminated.

[0108] After all the loop recognition and optimization processes for cropped images are completed, all the recorded recognition results are integrated and processed, and the seal number text with the highest confidence is selected as the final output result, thus completing the entire process of step S3 and providing accurate seal number data support for subsequent business processing.

[0109] Example 2: This embodiment provides a container lead seal identification and detection system based on the ACF-YOLOX algorithm, including a file acquisition and parameter verification module, an ACF-YOLOX algorithm construction and position prediction module, a recognition box area calculation and effective coordinate filtering module, and a cropped image rotation optimization and text recognition module. The file acquisition and parameter verification module, in which: The URL parameter is obtained through the lead seal recognition interface. The URL parameter corresponds to the URL of the target file's network OSS file. The URL parameter is validated for validity. If the validation result is invalid, the entire detection process is terminated. If the validation result is valid, the corresponding request parameters are extracted, and the target file is downloaded based on the network OSS file address URL. The file validity of the target file is then validated. After the file validity validation is passed, the lead seal file to be processed is output. The ACF-YOLOX algorithm construction and location prediction module includes: The ACF-YOLOX algorithm is constructed, with the backbone network being CSPDarknet and an attention mechanism introduced into the key output layer of feature extraction as an improvement to CSPDarknet; the neck network is an improved feature fusion pyramid structure, with the first half being FPN and the second half being PAN, and new AFM adaptive feature fusion unit and CFM cross-scale feature fusion unit are added; the head network is a decoupled head network that separates classification and regression tasks. The file type of the lead seal document to be processed is validated. If the validation result is invalid, the entire detection process is terminated. If the validation result is valid, the ACF-YOLOX algorithm is used to recognize the lead seal image corresponding to the lead seal document to be processed, obtain the location of the lead seal and the lead seal number, and return the corresponding recognition coordinates. The module for calculating the area of ​​the recognition box and filtering the effective coordinates includes: Based on the recognition coordinates, calculate the area of ​​the lead seal recognition frame, the area of ​​the lead seal number recognition frame, and the intersection area of ​​the lead seal recognition frame and the lead seal number recognition frame. Make a judgment according to a preset threshold. The threshold is determined by the ratio of the intersection area of ​​the lead seal recognition frame and the lead seal number recognition frame to the area of ​​the lead seal recognition frame. Then, select the target area for subsequent OCR recognition and output the effective recognition coordinates. The image cropping rotation optimization and text recognition module includes: If no valid recognition coordinates are obtained, global OCR recognition is performed directly. If valid recognition coordinates are obtained, the seal image is cropped according to the valid recognition coordinates to obtain a cropped image set. The cropped image set is checked for out-of-bounds errors. If it is determined to be out of bounds, the recognized information is organized and output. If it is determined to be within bounds, a loop iterative optimization process is started. Within the preset loop variable i, the cropped image is rotated at the corresponding angle and OCR recognition is performed. If the current recognition result does not meet the preset optimal standard, the current recognition result is included in the total result set and the loop continues. After the loop is completed, the seal number text with the highest confidence is output.

[0110] Based on the above-described embodiment of a container seal identification and detection method and system based on the ACF-YOLOX algorithm, another embodiment of the present invention provides an electronic device, such as... Figure 8 As shown, it includes a processor board, a communication board, a memory board, and an LCD display module. Each component is electrically connected and interacts with data through a dedicated communication line. The overall structure is simple and adaptable to the functional requirements of container seal identification and detection.

[0111] The memory board stores computer program instructions that can be executed by the processor, corresponding to the container lead seal identification and detection method based on the ACF-YOLOX algorithm described in this invention. The processor board is communicatively connected to the memory board and is used to call and execute the program instructions stored in the memory board to complete core processing steps such as lead seal image recognition, effective coordinate calculation, and text recognition optimization. The communication board supports data communication between the electronic device and other devices or host computers, and is compatible with multiple communication protocols such as Ethernet and serial ports to realize data transmission and sharing. The LCD display module is used to intuitively present the lead seal identification results (such as the lead seal location coordinates and the text of the lead seal number with the highest confidence level), facilitating real-time viewing and verification by operators.

[0112] Through the coordinated operation of the aforementioned components, this electronic device can stably run the ACF-YOLOX algorithm, efficiently and accurately identify and detect container seals, meeting the usage requirements of practical application scenarios such as ports.

[0113] Based on the above-described embodiment of a container seal identification and detection method and system based on the ACF-YOLOX algorithm, another embodiment of the present invention provides a computer-readable storage medium storing computer instructions that cause the computer to execute the container seal identification and detection method based on the ACF-YOLOX algorithm.

[0114] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. The methods disclosed in the embodiments are described simply because they correspond to the systems disclosed in the embodiments; relevant details can be found in the method section.

[0115] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0116] In the embodiments provided by this invention, it should be understood that the disclosed systems, methods, and approaches can be implemented in other ways. For example, the system embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between systems or units may be electrical, mechanical, or other forms.

[0117] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0118] In addition, the functional modules in the various embodiments of the present invention can be integrated into one processing unit, or each module can exist physically separately, or two or more modules can be integrated into one unit.

[0119] Similarly, in the various embodiments of the present invention, each processing unit can be integrated into a functional module, or each processing unit can exist physically, or two or more processing units can be integrated into a functional module.

[0120] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0121] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0122] The above-disclosed embodiments are merely preferred embodiments of the present invention, but the present invention is not limited thereto. Any non-creative variations that can be conceived by those skilled in the art, as well as any improvements and modifications made without departing from the principles of the present invention, should fall within the protection scope of the present invention.

Claims

1. A method for identifying and detecting lead seals on containers based on the ACF-YOLOX algorithm, characterized in that, Includes the following steps: Step S1: Construct the ACF-YOLOX algorithm, which includes a backbone network, a neck network, and a head network. The backbone network is CSPDarknet, and an attention mechanism is introduced in the key output layer of feature extraction. The neck network is an improved feature fusion pyramid structure, with the first half being FPN and the second half being PAN. An AFM adaptive feature fusion unit and a CFM cross-scale feature fusion unit are added. The head network is a decoupled head network that separates the classification and regression tasks; The ACF-YOLOX algorithm is used to identify the seal images in the seal files to be processed, and the location prediction results are output. Step S2: Based on the location prediction results, calculate the area of ​​the lead seal recognition frame, the area of ​​the lead seal number recognition frame, and the intersection area of ​​the lead seal recognition frame and the lead seal number recognition frame. Based on the ratio of the intersection area of ​​the lead seal recognition frame and the lead seal number recognition frame to the area of ​​the lead seal recognition frame, perform threshold judgment and output the valid recognition coordinates. Step S3: Crop the image based on the valid recognition coordinates, and perform rotation operations on the cropped image at multiple angles within a preset loop variable. After each rotation, perform OCR text recognition, collect the recognition results, and output the seal number text with the highest confidence.

2. The method according to claim 1, characterized in that, In step S1, the attention mechanism is the CA attention mechanism; the key output layers for feature extraction in CSPDarknet are specifically Dark2 output layer, Dark3 output layer and Dark4 output layer, and each key output layer introduces the CA attention mechanism separately as an improvement part of CSPDarknet.

3. The method according to claim 2, characterized in that, In step S1, the AFM adaptive feature fusion unit of the ACF-YOLOX algorithm includes an upsampling fusion structure and a downsampling fusion structure; the AFM adaptive feature fusion unit is embedded in the feature interaction path between layers 1-3 of FPN; The downsampling fusion structure receives feature maps from the backbone network Dark3 and Dark4, reduces the feature map size through max pooling, merges them along the channel dimension after convolution and pointwise convolution, and outputs the result by convolution to increase the dimension. The upsampling fusion structure receives feature maps from the backbone network Dark4 and Dark5, performs pointwise convolution and convolution processing, enlarges the feature map size through a tensor difference calculation function, merges them along the channel dimension, and outputs the dimensionality-upgraded output through convolution. Furthermore, the output results of the upsampling fusion structure and the downsampling fusion structure are merged with the corresponding layer results of the FPN.

4. The method according to claim 3, characterized in that, In step S1, the CFM cross-scale feature fusion unit of the ACF-YOLOX algorithm is embedded in the cross-connection path between the PAN layer of the neck network and the Dark layer of the backbone network. The CFM cross-scale feature fusion unit receives the feature map output by the Dark layer of the backbone network. and the feature map output by the PAN layer ; CFM cross-scale feature fusion unit includes fusion processes that do not require channel changes and fusion processes that require channel changes; like Number of channels and Number of channels If they are equal, it is determined that the fusion process does not require channel changes. The splicing operation along the channel dimension is directly performed, and then the features are fused and output through a convolutional layer with an attention layer. like Number of channels and Number of channels If they are not equal, it is determined that a fusion process requiring channel changes is needed. First, a 1×1 pointwise convolution is performed on the pairs. Perform channel adaptation, converting it into the number of channels and... Consistent unified parameter characteristics Then and Perform a concatenation operation along the channel dimension, and finally fuse the features through a convolutional layer containing an attention layer and output the result.

5. The method according to claim 1, characterized in that, In step S2, the calculation of the area of ​​the lead seal identification frame, the area of ​​the lead seal number identification frame, and the intersection area of ​​the lead seal identification frame and the lead seal number identification frame based on the location prediction results is specifically as follows: Based on the location prediction results, calculate the area G of the seal identification frame, the area P of the seal number identification frame, and the intersection area Intersection(G,P). The area is calculated by multiplying the absolute value of the difference between the x-coordinate of the upper left corner and the x-coordinate of the lower right corner by the absolute value of the difference between the y-coordinate of the upper left corner and the y-coordinate of the lower right corner. The specific formula is as follows: in, This is a set of area calculation results. This represents the area of ​​the lead seal identification frame. This represents the area of ​​the lead seal identification frame; Let G be the x-coordinate of its upper left corner. Let G be the top left ordinate. Let G be the x-coordinate of its lower right corner. Let G be the ordinate of the lower right corner; Let P be the x-coordinate of its upper left corner. Let P be the ordinate of its upper left corner. Let P be the x-coordinate of its lower right corner. Let P be the ordinate of the lower right corner; The threshold determination is based on the ratio of the intersection area to the area of ​​the lead seal recognition frame, and the specific formula is as follows: in, For the threshold, This is the intersection of the area of ​​the lead seal identification frame and the area of ​​the lead seal number identification frame. This represents the area of ​​the lead seal identification frame.

6. The method according to claim 1, characterized in that, In step S3, the rotation operation of multiple angles is specifically as follows: when the loop variable i takes the values ​​0, 1, 2, and 3 in sequence, it corresponds to a clockwise rotation of 0 degrees and 90 degrees, a counterclockwise rotation of 90 degrees, and a rotation of 180 degrees, respectively.

7. The method according to claim 1, characterized in that, The method also includes a file acquisition and parameter verification step, in which: The URL parameter is obtained through the lead seal identification interface, and the URL parameter corresponds to the network OSS file URL of the target file. The URL parameters are validated for validity. If the validation result is invalid, the process ends directly. If the verification result is valid, the request parameters are extracted and the target file is downloaded, and the lead seal file to be processed is output.

8. A container lead seal identification and detection system based on the ACF-YOLOX algorithm, characterized in that, Specifically, it includes: The ACF-YOLOX algorithm construction and location prediction module: The ACF-YOLOX algorithm is constructed, with the backbone network being CSPDarknet and a CA attention mechanism introduced in the key output layer of feature extraction; the neck network is an improved feature fusion pyramid structure, with the first half being FPN and the second half being PAN, and new AFM adaptive feature fusion unit and CFM cross-scale feature fusion unit are added. The head network is a decoupled head network that separates the classification and regression tasks; the ACF-YOLOX algorithm is used to identify the seal images in the seal files to be processed to obtain the location prediction results; The module for calculating the area of ​​the recognition frame and filtering the effective coordinates calculates the area of ​​the seal recognition frame, the area of ​​the seal number recognition frame, and the intersection area of ​​the seal recognition frame and the seal number recognition frame based on the location prediction results. It then performs a threshold judgment based on the ratio of the intersection area to the area of ​​the seal recognition frame and outputs the effective recognition coordinates. Image cropping, rotation optimization, and text recognition module: Crops the image based on valid recognition coordinates, performs rotation operations on the cropped image at multiple angles within a preset loop variable i, and performs OCR text recognition after each rotation, collects the results, and outputs the seal text with the highest confidence.

9. An electronic device, characterized in that, It includes at least one processor; and a memory communicatively connected to said at least one processor; The memory stores computer program instructions that can be executed by at least one processor to enable the at least one processor to perform the container seal identification and detection method based on the ACF-YOLOX algorithm as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, A computer-readable storage medium stores computer instructions that cause the computer to perform the container seal identification and detection method based on the ACF-YOLOX algorithm as described in any one of claims 1 to 7.