Machine vision feature retention and identification method and system for dense small targets

By introducing the ELA local attention layer and the feature enhancement fusion module of Transformer architecture in the YOLOv8 model, the feature retention and recognition capabilities of dense small object detection are improved, and the problem of feature loss and insufficient category distinction capabilities are solved, which significantly improves the detection accuracy .

CN119399440APending Publication Date: 2025-02-07SHANGHAI UNIVERSITY OF ELECTRIC POWER
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411517725.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-29
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

The prior art has problems of feature loss and insufficient category distinction ability in intensive small-object detection, especially in deep convolutional networks, small-objective features are easily lost and lack of correlation learning of related feature semantics.

Method used

The improved AMF-YOLOv8 model improves the extraction and positioning capabilities of dense target local features by introducing ELA local attention layer and feature enhancement fusion module based on Transformer architecture, and uses cross-level connections and normalized Wasserstein distances and IoU weights. The positioning loss function of the measurement improves the positioning accuracy of the small-scale target bounding box.

Benefits of technology

It effectively solves the problem that small target features are easily lost in deep convolutional networks, improves the learning ability of feature interactions between targets, alleviates the phenomenon of intensive small target miss detection, and improves the detection accuracy of various small targets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119399440A_ABST
    Figure CN119399440A_ABST
Patent Text Reader

Abstract

The invention relates to a machine vision feature retention and recognition method and system for dense small targets. The method comprises the steps that an obtained original image containing the dense small targets is input into an improved AMF-YOLOv8 model, and a dense small target result image is output; machine vision feature retention is realized through model improvement; the dense small target result image comprises a prediction frame, category information and confidence of each small target; according to the improved AMF-YOLOv8 model, YOLOv8n is used as a reference model, and the improved AMF-YOLOv8 model comprises a backbone network, a CS-PANet neck network and a Deect layer. The system is used for realizing the method. Compared with the prior art, the method optimizes the defects of YOLOv8, and enables the YOLOv8 to be more efficient and accurate in the recognition of dense small targets.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of target detection technology, and in particular to a method and system for preserving and recognizing machine vision features of dense small targets. Background Art

[0002] New artificial intelligence technology has become a powerful driver for the leapfrog development of all walks of life, and machine vision processing is a basic and key technology of artificial intelligence. With the unprecedented explosive growth of new power systems, smart transportation, ground-to-air economy, virtual reality and other industries, the contradiction between the lean perception of machine vision, especially the need for dense small target perception and the existing machine vision processing capabilities has become prominent, which has greatly restricted the in-depth functional expansion of operation, warning, fault and other indication information in general industrial control systems. The root cause lies in the scarcity of the number of pixel units and samples in the small target matrix, as well as the lack of various feature expression capabilities, which leads to complex backgrounds and off-standard information interfering with the correct identification of small targets in the form of noise submersion. Difficulty in feature identification and retention have become technical problems that need to be solved in this field.

[0003] At present, the target detection method based on deep learning is the mainstream method for dense target recognition and positioning. Among them, YOLOv8 is a single-stage target detection algorithm launched in recent years, which has the advantages of high detection accuracy and fast speed. However, the YOLOv8 series models all use similar network structures. Its backbone network extracts image target features through multiple convolutions, and outputs them after fusing network multi-scale features through top-down and bottom-up bidirectional paths. This working paradigm also encounters the problem of feature shortage when processing dense small target indication information, that is, as the convolutional neural network deepens, the semantic information becomes richer and the detailed features decrease. Especially in the bottom-up fusion path with a deeper neck, the feature information of various targets is lost to varying degrees, which can easily lead to missed detection of targets when transmitted to the output layer for detection. In addition, this type of structure also lacks the association learning of related feature semantics, which makes it poor in accurately distinguishing the category information of dense targets.

[0004] Therefore, optimizing the shortcomings of YOLOv8 to make it more advantageous in the recognition process of dense small targets is a problem that needs to be solved. Summary of the invention

[0005] The purpose of the present invention is to overcome the defects of the above-mentioned prior art and provide a method and system for machine vision feature retention and recognition of dense small targets.

[0006] The purpose of the present invention can be achieved by the following technical solutions:

[0007] According to a first aspect of the present invention, a method for preserving and identifying machine vision features of dense small targets is provided. The method inputs an acquired original image containing dense small targets into an improved AMF-YOLOv8 model to output a dense small target result image; and the machine vision feature preservation is achieved through model improvement; the dense small target result image includes a prediction box, category information and confidence of each small target;

[0008] The improved AMF-YOLOv8 model uses YOLOv8n as a benchmark model, including a backbone network, a CS-PANet neck network and a Detect layer; the bottom of the backbone network introduces an ELA local attention layer based on YOLOv8n; the CS-PANet neck network includes the neck network of YOLOv8n and a feature enhancement fusion module based on the Transformer architecture, and the two are connected in a cross-level manner; the Detect layer uses a positioning loss function of normalized Wasserstein distance and IoU weighted measurement to replace the loss function of YOLOv8n; the backbone network also includes multiple average pooling layers; the feature enhancement fusion module is arranged before the Detect layer.

[0009] As a preferred technical solution, the step of obtaining the dense small target result image includes:

[0010] Get the original image containing dense small objects and input it into the AMF-YOLOv8 model;

[0011] The backbone network receives the original image and performs feature extraction, and outputs position attention features;

[0012] The CS-PANet neck network receives the position attention features and performs feature fusion to obtain the output features;

[0013] The Detect layer receives the output features and outputs a dense small target result image.

[0014] As a preferred technical solution, the method for obtaining the position attention feature is:

[0015] Performing an average pooling operation on the original image in the horizontal direction and the vertical direction on each average pooling layer, and different average pooling layers output low-level features of different scales;

[0016] The ELA local attention layer receives the low-level features output by the final average pooling layer, uses one-dimensional convolution and group normalization to enhance the information, applies an activation function to process the enhanced information, generates position attention marks in the horizontal and vertical directions, and outputs position attention features.

[0017] As a preferred technical solution, the method for obtaining the output features is:

[0018] The position attention features are input into the CS-PANet neck network, which is received and processed by the YOLOv8n neck network and outputs multiple high-level features of different scales;

[0019] Select multiple preset scales, obtain the same number of low-level features and high-level features according to the preset scales, and input them into the feature enhancement fusion module for feature fusion and enhancement operations to obtain enhanced fusion features;

[0020] The high-level features of the preset scale, the low-level features of the preset scale and the enhanced fusion features are weighted and summed at the channel level, and the weighted summation result is projected to obtain the output feature.

[0021] As a preferred technical solution, obtaining the enhanced fusion features includes the following steps:

[0022] Performing a preliminary fusion operation on a plurality of low-level features of preset sizes and high-level features of preset sizes to obtain fused features;

[0023] The first feature is obtained by learning the long-distance feature interactions between dense small objects in the fusion feature using the extended window multi-head self-attention of the Transformer architecture;

[0024] Perform a channel shuffle operation on each channel of the first feature and the fused feature, and rearrange them in an alternating manner to obtain a mixed feature;

[0025] The mixed features are processed by grouped convolution and the second feature, namely the enhanced fusion feature, is output. Its expression is:

[0026]

[0027] Among them, F 2 Represents the second feature, represents a group convolution with a kernel of 7×7, CS represents a channel shuffle operation, and F 1 represents the first feature, F fusion Represents fusion features.

[0028] As a preferred technical solution, the method for obtaining the first feature is:

[0029] The fusion features are normalized, divided into multiple local windows of the same size, and filled and rearranged to (B·n 1 ·n 2 , C, h, w) of shape, where B identifies the batch size of the local window and n 1 Indicates the number of groups of feature maps in height, n2 represents the number of groups of feature maps in width, C represents the number of feature channels, h represents the height of the local window, and w represents the width of the local window;

[0030] Calculate the query, key, and value of the self-attention mechanism for each local window, and calculate the attention weight value, which is expressed as:

[0031]

[0032]

[0033] Among them, X represents the characteristics of the local window, W Q represents the weight matrix of query Q, W K represents the weight matrix of key K, W V Represents the weight matrix of value V, head i represents the weight of the attention head of each local window of the ith type, dim_head represents the dimension of the attention head, K T represents the transpose of key K;

[0034] Obtaining process features based on the attention weight values, and re-arranging and merging the process features;

[0035] The features after rearrangement and merging are projected to output the first features.

[0036] As a preferred technical solution, the training of the AMF-YOLOv8 model includes the following steps:

[0037] Obtain a dense small object image dataset and perform image preprocessing;

[0038] Divide the preprocessed images into training sets and test sets according to a preset ratio;

[0039] Use the training set to train the AMF-YOLOv8 model, use the positioning loss function to update the model parameters and output the weight file after the training is completed;

[0040] Get the weight file as the model weight, input the test set into the AMF-YOLOv8 model trained with the training set for testing, and select the model with the best performance as the final AMF-YOLOv8.

[0041] As a preferred technical solution, the steps of constructing the positioning loss function include:

[0042] The loss function using the normalized Wasserstein distance metric is established, and its expression is:

[0043]

[0044] Among them, L NWD represents the loss function, and represents the modeled Gaussian distribution of image bounding box a and bounding box b, represents the Wasserstein distance, and q is a constant related to the data set input to the Detect layer;

[0045] The weighted sum of the loss function and the loss function of YOLOv8n is used as the positioning loss function, which is expressed as:

[0046]

[0047] in, represents the weight, L CIoU Represents the loss function of YOLOv8n.

[0048] As a preferred technical solution, the image preprocessing includes:

[0049] Annotating the dense small target image to obtain a label file, wherein the label file includes target color and meaning information;

[0050] Count all the colors in the label file and the proportion of small targets of each color;

[0051] Sort each color based on its proportion, and treat small targets with a proportion higher than a preset value as excess samples, and treat small targets with a proportion lower than a preset value as scarce samples;

[0052] Replace the corresponding colors of the excess samples with the colors of the scarce samples, and update the label files and dense small target images to obtain the data set to be processed;

[0053] The data set to be processed is subjected to color adjustment, rotation, cropping and random erasing operations to obtain a preprocessed data set. According to a second aspect of the present invention, a machine vision feature retention and recognition system for dense small targets is provided, which is used to implement the above-mentioned machine vision feature retention and recognition method for dense small targets.

[0054] Compared with the prior art, the present invention uses YOLOv8n as the benchmark model for model improvement. On the basis of retaining the advantages of YOLOv8n such as high detection accuracy and fast speed, the ELA local attention is introduced into the backbone network to encode the target feature position information, thereby improving the extraction and positioning capabilities of local features of dense targets; the CS-PANet neck network improved by cross-level connection and feature enhancement fusion module is adopted to solve the problem of small target feature loss after multiple convolutions, and strengthen the semantic association and feature expression between dense targets; the positioning loss function of the normalized Wasserstein distance and the IoU weighted measurement is applied to improve the positioning accuracy of the small-scale target bounding box; therefore, the present invention solves the problem of easy loss of small target features in deep convolutional networks, improves the learning ability of feature interaction between targets, alleviates the phenomenon of missed detection of dense small targets, and improves the detection accuracy of various small targets. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 It is a structural diagram of the AMF-YOLOv8 model of the present invention;

[0056] Figure 2 is a flow chart of the method of the present invention;

[0057] Figure 3 3a) is a comparison diagram of the detection results of the model of the present invention and the detection results of the benchmark model; (3b) is a result diagram of the model of the present invention. DETAILED DESCRIPTION

[0058] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0059] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantitative limitation, and may represent the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.

[0060] In order to solve the problems that, when the traditional YOLOv8 model detects small targets, the feature information of various small targets is lost to varying degrees, which easily leads to missed targets when transmitted to the output layer for detection. In addition, such a structure lacks the associative learning of relevant feature semantics, resulting in poor ability to accurately distinguish the category information of dense targets. This embodiment provides a method for preserving and recognizing machine vision features of dense small targets. The method outputs a result image of dense small targets from the acquired original image input containing dense small targets; and achieves machine vision feature preservation through model improvement.

[0061] The improved AMF-YOLOv8 model uses YOLOv8n as the benchmark model, including the backbone network, CS-PANet neck network and Detect layer. Its structure is as follows: Figure 1 As shown in the figure; the ELA local attention layer is introduced at the bottom of the backbone network based on YOLOv8n, and the network also includes multiple average pooling layers; the CS-PANet neck network includes the neck network of YOLOv8n and the feature enhancement fusion module based on the Transformer architecture, and the two are connected in a cross-level manner, and the enhancement module feature enhancement fusion module is Figure 1The part framed by the black dotted line is located before the Detect layer; the Detect layer uses the normalized Wasserstein distance and the IoU weighted measurement positioning loss function to replace the loss function of YOLOv8n.

[0062] In order to verify the feasibility of the method provided in this embodiment, and considering that accurately detecting the indicator light information in the operating panel image of IT equipment such as data center servers and switches is crucial for periodic monitoring of the operating status of data center equipment, it can not only handle equipment abnormalities in a timely manner but also avoid data loss and downtime events. However, a large number of dense indicator lights on the operating panel of data center equipment are prone to missed detection and false detection, resulting in low detection accuracy and difficulty in reflecting the operating status of the equipment. Therefore, the method is applied to the scenario of detecting dense indicator lights of servers. The method flow chart is as follows Figure 2 As shown, the specific steps include:

[0063] S1. Obtain the original image containing dense indicator lights and input it into the improved AMF-YOLOv8 model;

[0064] S2, the backbone network receives the original image and performs feature extraction, and outputs position attention features;

[0065] S21, performing average pooling operations on the original image containing dense indicator lights in the horizontal and vertical directions on each average pooling layer, capturing the long-range dependencies in the spatial dimension while retaining the precise position information of the indicator lights in the image, and different average pooling layers output low-level features of the indicator lights at different scales;

[0066] S22, ELA local attention layer receives the low-level features about the indicator light output by the final average pooling layer, uses one-dimensional convolution and group normalization to enhance the information, applies the activation function to process the enhanced information, generates the position attention mark in the horizontal and vertical directions, and outputs the position attention features of various indicator lights.

[0067] S3, CS-PANet neck network receives the position attention features of various indicator lights and performs feature fusion to obtain the output features of various indicator lights;

[0068] Considering that PANet lacks attention to shallow features in the bottom-up fusion path, it is very easy to lose important feature information on the device panel. The feature enhancement fusion module is built before the output detection layer with scales of 80×80, 40×40 and 20×20, and a cross-level connection method is used to fuse the feature maps of the corresponding scales of the backbone shallow network and the feature pyramid, which can effectively avoid the problem of feature information loss of device-related targets in the deep convolutional network. The specific steps are as follows:

[0069] S31. The position attention feature is input into the CS-PANet neck network, which is received and processed by the YOLOv8n neck network and outputs multiple high-level features of different scales.

[0070] S32, selecting low-level features and high-level features with scales of 80×80, 40×40 and 20×20, and inputting them into a feature enhancement fusion module for feature fusion and enhancement operations to obtain enhanced fusion features;

[0071] S321, performing a preliminary fusion operation on low-level features and high-level features with scales of 80×80, 40×40 and 20×20 to obtain fused features;

[0072] S322, using the Transformer architecture's extended window multi-head self-attention learning to obtain the first feature by performing long-distance feature interaction between dense small targets in the fusion feature, wherein the specific steps are A1 to A4:

[0073] A1. Normalize the fusion features, divide them into multiple local windows of the same size, and fill and rearrange them to (B·n 1 ·n 2 ,C,h,w) of shape, where B indicates the batch size of the local window, n 1 Indicates the number of groups of feature maps in height, n 2 represents the number of groups of feature maps in width, C represents the number of feature channels, h represents the height of the local window, and w represents the width of the local window;

[0074] A2. Calculate the query, key, and value of the self-attention mechanism for each local window, and calculate the attention weight value, which is expressed as:

[0075]

[0076]

[0077] Among them, X represents the characteristics of the local window, W Q represents the weight matrix of query Q, W K represents the weight matrix of key K, W V Represents the weight matrix of value V, head i represents the weight of the attention head of each local window of the ith type, dim-head represents the dimension of the attention head, and K T represents the transpose of key K;

[0078] A3. Obtain process features based on attention weights, and rearrange and merge the process features;

[0079] A4, projecting the features after rearrangement and merging operations to output a first feature;

[0080] S323, performing a channel shuffling operation on each channel of the first feature and the fused feature, and rearranging them in an alternating manner to obtain a mixed feature;

[0081] S324, using grouped convolution to process the mixed features can improve the effect of information exchange between the two parts of the features, and output the second feature, namely the enhanced fusion feature, which is expressed as:

[0082]

[0083] Among them, F 2 Represents the second feature, represents a group convolution with a kernel of 7×7, CS represents a channel shuffle operation, and F 1 represents the first feature, F fusion Represents fusion features.

[0084] S33, weighted sum the enhanced fusion features, low-level features with scales of 80×80, 40×40 and 20×20, and high-level features at the channel level, and project the weighted summation result in a 1×1 convolutional layer to obtain the output features.

[0085] S4, the Detect layer receives the output features and outputs a result image of dense indicator lights, which includes: the prediction box, category information and confidence of each indicator light.

[0086] In order to verify that the improved AMF-YOLOv8 model used in this embodiment has better performance than the traditional YOLOv8 model, the original image used in this embodiment is simultaneously input into the YOLOv8 model, and the errors occurring in the detection process of both are counted and generated as follows: Figure 3 The bar chart shown in FIG. 3 shows the result obtained by using the YOLOv8 model for detection, and FIG. 3 shows the result obtained by using the AMF-YOLOv8 model for detection.

[0087] It can be seen that the improved AMF-YOLOv8 model has reduced missed detection and positioning errors by 2.1% and 2.39% respectively compared with the original YOLOv8 model, which greatly reduces missed detection and positioning errors. At the same time, other indicators have also improved accordingly. The classification has improved slightly because while a large number of missed indicator lights are identified, the confidence judgment for dense indicator lights has been reduced accordingly. In the detection of dense small targets such as indicator lights, the YOLOv8 baseline model will have a considerable degree of missed detection, while the use of the AMF-YOLOv8 model for indicator light detection can be comprehensive and accurate, reflecting the excellent effect of the AMF-YOLOv8 model on the retention and recognition of dense small target features.

[0088] Compared with the target detection model of the convolutional neural network series, the method provided in this embodiment can reduce the loss of local feature information of small targets in the deep convolutional network, enhance the quality of the feature map transmitted to the output detection layer, and can fully learn the long-distance feature interaction between targets, thereby improving the detection accuracy of dense small-scale targets. In the typical application of Example 1, a machine vision feature retention and recognition method for dense small targets is adopted, and the existing conventional target detection model YOLOv8n is optimized and improved, which effectively reduces the phenomenon of missed detection of indicator lights, has excellent detection performance, and effectively reduces the phenomenon of false detection, which has practical significance for the detection scenario of dense small-scale indicator lights.

[0089] For the above improved AMF-YOLOv8 model, the training process is as follows:

[0090] B1. Obtain a dense small object image dataset with a size of 640×640 and perform image preprocessing;

[0091] B11. Annotate the dense small target image to obtain a label file, which includes the target color and meaning information, and ensures that the image file name corresponds to the name of the saved annotation file, ensures that the bounding box is close to the target to avoid including redundant background, and ensures that objects of the same category use the same label and annotation method;

[0092] B12. Use OpenCV to parse the annotation file containing the location and category information of each annotation box, and use color thresholding to count the types of all colors in the label file and the proportion of small targets of each color;

[0093] B13. Sort each color based on its proportion, and take small targets with a proportion higher than a preset value as excess samples, and take small targets with a proportion lower than a preset value as scarce samples;

[0094] B14. Replace the corresponding colors of the excess samples with the colors of the scarce samples, and update the label files and dense small target images to obtain the data set to be processed;

[0095] B15. Use the Imgaug library to perform color adjustment, rotation, cropping, and random erasing operations on the data set to be processed to obtain the preprocessed data set.

[0096] B2. Divide the preprocessed images into training set and test set in a ratio of 8:2;

[0097] B3. Use the training set to train the AMF-YOLOv8 model, set the initial learning rate to 0.01, use the positioning loss function to update the model parameters and output the weight file best.pt after training 200 times. The positioning loss function construction process is:

[0098] B31. Establish a loss function using the normalized Wasserstein distance metric, which is expressed as:

[0099]

[0100] Among them, L NWD represents the loss function, and represents the modeled Gaussian distribution of image bounding box a and bounding box b, represents the Wasserstein distance, and q is a constant related to the data set input to the Detect layer;

[0101] B32. The weighted sum of the loss function and the loss function of YOLOv8n is used as the positioning loss function, and its expression is:

[0102]

[0103] in, represents the weight, L CIoU Represents the loss function of YOLOv8n.

[0104] Moreover, the positioning loss function can take into account the positioning accuracy of normal-sized targets and small-scale targets (such as indicator lights), avoiding the problem of label flipping caused by low positioning accuracy of the prediction box, which in turn leads to the transformation of positive and negative samples, and can greatly improve the stability of model training.

[0105] B4. Obtain the weight file best.pt as the model weight, input the test set into the AMF-YOLOv8 model trained with the training set for testing, and select the model with the best performance as the final AMF-YOLOv8.

[0106] This embodiment also provides a machine vision feature retention and recognition system for dense small targets, which is used to implement the above method.

[0107] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the described module can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0108] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A machine vision feature retention and recognition method for dense small targets, characterized in that: The method inputs the acquired original image containing dense small targets into the improved AMF-YOLOv8 model to output a dense small target result image; and achieves machine vision feature retention through model improvement; the dense small target result image includes the prediction box, category information and confidence of each small target; The improved AMF-YOLOv8 model uses YOLOv8n as a benchmark model, including a backbone network, a CS-PANet neck network and a Detect layer; the bottom of the backbone network introduces an ELA local attention layer based on YOLOv8n; the CS-PANet neck network includes the neck network of YOLOv8n and a feature enhancement fusion module based on the Transformer architecture, and the two are connected in a cross-level manner; the Detect layer uses a positioning loss function of normalized Wasserstein distance and IoU weighted measurement to replace the loss function of YOLOv8n; the backbone network also includes multiple average pooling layers; the feature enhancement fusion module is arranged before the Detect layer.

2. The method for preserving and identifying machine vision features of dense small targets according to claim 1 is characterized in that: The steps of obtaining the dense small target result image include: Get the original image containing dense small objects and input it into the AMF-YOLOv8 model; The backbone network receives the original image and performs feature extraction, and outputs position attention features; The CS-PANet neck network receives the position attention features and performs feature fusion to obtain the output features; The Detect layer receives the output features and outputs a dense small target result image.

3. The method for preserving and identifying machine vision features of dense small targets according to claim 2, characterized in that: The method for obtaining the position attention feature is: Performing an average pooling operation on the original image in the horizontal direction and the vertical direction on each average pooling layer, and different average pooling layers output low-level features of different scales; The ELA local attention layer receives the low-level features output by the final average pooling layer, uses one-dimensional convolution and group normalization to enhance the information, applies an activation function to process the enhanced information, generates position attention marks in the horizontal and vertical directions, and outputs position attention features.

4. The method for preserving and identifying machine vision features of dense small targets according to claim 3 is characterized in that: The method for obtaining the output features is: The position attention features are input into the CS-PANet neck network, which is received and processed by the YOLOv8n neck network and outputs multiple high-level features of different scales; Select multiple preset scales, obtain the same number of low-level features and high-level features according to the preset scales, and input them into the feature enhancement fusion module for feature fusion and enhancement operations to obtain enhanced fusion features; The high-level features of the preset scale, the low-level features of the preset scale and the enhanced fusion features are weighted and summed at the channel level, and the weighted summation result is projected to obtain the output feature.

5. The method for preserving and identifying machine vision features of dense small targets according to claim 4, characterized in that: Acquiring the enhanced fusion feature comprises the following steps: Performing a preliminary fusion operation on a plurality of low-level features of preset sizes and high-level features of preset sizes to obtain fused features; The first feature is obtained by learning the long-distance feature interactions between dense small objects in the fusion feature using the extended window multi-head self-attention of the Transformer architecture; Perform a channel shuffle operation on each channel of the first feature and the fused feature, and rearrange them in an alternating manner to obtain a mixed feature; The mixed features are processed by grouped convolution and the second feature, namely the enhanced fusion feature, is output. Its expression is: Among them, F2 represents the second feature, represents a group convolution with a kernel of 7×7, CS represents a channel shuffle operation, F1 represents the first feature, and F fusion Represents fusion features.

6. The method for preserving and identifying machine vision features of dense small targets according to claim 5, characterized in that: The method for obtaining the first feature is: Normalize the fused features, divide them into multiple local windows of the same size, fill and rearrange them, and input the tensor into the shape of (B·n1·n2,C,h,w), where B indicates the batch size of the local window, n1 indicates the number of groups of the feature map in height, n2 indicates the number of groups of the feature map in width, C indicates the number of feature channels, h indicates the height of the local window, and w indicates the width of the local window; Calculate the query, key, and value of the self-attention mechanism for each local window, and calculate the attention weight value, which is expressed as: Among them, X represents the characteristics of the local window, W Q represents the weight matrix of query Q, W K represents the weight matrix of key K, W V Represents the weight matrix of value V, head i represents the weight of the attention head of each local window of the ith type, dim_head represents the dimension of the attention head, K T represents the transpose of key K; Obtaining process features based on the attention weight values, and re-arranging and merging the process features; The features after rearrangement and merging are projected to output the first features.

7. The method for preserving and identifying machine vision features of dense small targets according to claim 1, characterized in that: The training of the AMF-YOLOv8 model includes the following steps: Obtain a dense small object image dataset and perform image preprocessing; Divide the preprocessed images into training sets and test sets according to a preset ratio; Use the training set to train the AMF-YOLOv8 model, use the positioning loss function to update the model parameters and output the weight file after the training is completed; Get the weight file as the model weight, input the test set into the AMF-YOLOv8 model trained with the training set for testing, and select the model with the best performance as the final AMF-YOLOv8.

8. The method for preserving and identifying machine vision features of dense small targets according to claim 7, characterized in that: The steps of constructing the positioning loss function include: The loss function using the normalized Wasserstein distance metric is established, and its expression is: Among them, L NWD represents the loss function, and represents the modeled Gaussian distribution of image bounding box a and bounding box b, represents the Wasserstein distance, and q is a constant related to the data set input to the Detect layer; The weighted sum of the loss function and the loss function of YOLOv8n is used as the positioning loss function, which is expressed as: in, represents the weight, L CIoU Represents the loss function of YOLOv8n.

9. The method for preserving and identifying machine vision features of dense small targets according to claim 8, characterized in that: The image preprocessing includes: Annotating the dense small target image to obtain a label file, wherein the label file includes target color and meaning information; Count all the colors in the label file and the proportion of small targets of each color; Sort each color based on its proportion, and treat small targets with a proportion higher than a preset value as excess samples, and treat small targets with a proportion lower than a preset value as scarce samples; Replace the corresponding colors of the excess samples with the colors of the scarce samples, and update the label files and dense small target images to obtain the data set to be processed; The data set to be processed is subjected to color adjustment, rotation, cropping and random erasing operations to obtain the preprocessed data set.

10. A machine vision feature retention and recognition system for dense small targets, characterized in that: The system is used to implement a machine vision feature retention and recognition method for dense small targets as described in claims 1-9.