Image detection method and electronic device, storage medium
By combining object detection models with hybrid feature extraction models and utilizing parameter tuning and attention mechanisms to weightedly fuse features, the problem of insufficient adaptability of image detection in complex environments is solved, achieving high-precision fine-grained feature recognition and improving the stability and adaptability of detection.
Patent Information
- Application Number
- CN202511847354.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-09
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2045-12-09
AI Technical Summary
Existing image detection technologies have poor adaptability in complex and ever-changing environments and cannot dynamically adjust detection parameters, resulting in high false detection and false negative rates and difficulty in identifying fine-grained features.
By combining an object detection model with a hybrid feature extraction model, and through parameter tuning and attention mechanism, multi-model features are weighted and fused to generate a fused feature vector, achieving adaptive high-precision detection.
It improves the accuracy and adaptability of image detection, enabling accurate identification of fine-grained features in complex environments, reducing false detections and missed detections, and is suitable for scenarios such as industrial monitoring and security protection.
Smart Images

Figure CN121280707B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing, and in particular to an image detection method, an electronic device and a storage medium. BACKGROUND
[0002] In the field of image detection, especially in the application of vision-based target detection and compliance inspection, the related technology mainly depends on fixed rule matching or predefined threshold to realize detection. For example, in the industrial monitoring, security protection or quality inspection scene, the target object or violation behavior is identified by setting the threshold of color, shape, texture and other characteristics. However, the image detection method in the related technology has limitations in dealing with complex and variable environments. The fixed rules lack adaptive ability and cannot dynamically adjust the detection parameters, resulting in high false detection and missed detection rates. The recognition ability for details or irregular behaviors is insufficient, for example, in personnel wearing detection, the sleeve is not tightened, the zipper is not closed, and other fine-grained features are difficult to accurately capture.
[0003] Therefore, how to adapt to the complex changes of the environment and efficiently fuse multi-dimensional features in the image detection process to improve the detection accuracy and practicality is a problem to be solved at present. SUMMARY
[0004] The present application provides an image detection method, an electronic device and a storage medium to at least solve the problem of how to adapt to the complex changes of the environment and efficiently fuse multi-dimensional features in the image detection process to improve the detection accuracy and practicality in the related technology.
[0005] The present application provides an image detection method, comprising:
[0006] locating and processing the to-be-detected image through a target detection model to determine a target object region in the to-be-detected image;
[0007] extracting features of the target object region through a hybrid model comprising a plurality of feature extraction models to obtain feature vectors output by each of the plurality of feature extraction models, wherein the hybrid model and the target detection model are obtained through parameter tuning, and the parameter tuning at least includes locating a target parameter region through a first algorithm for global exploration, and determining an optimal target parameter through a second algorithm for local fine search in the target parameter region;
[0008] weighting and fusing the plurality of feature vectors according to respective corresponding attention weights and confidences to generate a fused feature vector, wherein the attention weights are obtained by inputting the plurality of feature vectors into a preset attention network, and the confidences are obtained by a plurality of feature extraction models through a plurality of rounds of forward propagation before loss;
[0009] determining a detection result of the to-be-detected image according to the fused feature vector through the hybrid model.
[0010] The application also provides an image detection device, comprising:
[0011] a positioning unit configured to perform positioning processing on the to-be-detected image by using the target detection model to determine a target object region in the to-be-detected image;
[0012] an extraction unit configured to perform feature extraction on the target object region by using a hybrid model comprising a plurality of feature extraction models to obtain feature vectors respectively output by the plurality of feature extraction models, wherein the hybrid model and the target detection model are obtained by parameter tuning, and the parameter tuning at least comprises performing global exploration positioning on a target parameter region by using a first algorithm, and performing local fine search on the target parameter region by using a second algorithm to determine an optimal target parameter;
[0013] a fusion unit configured to perform weighted fusion on the plurality of feature vectors according to respective corresponding attention weights and confidences to generate a fusion feature vector, wherein the attention weights are obtained by inputting the plurality of feature vectors into a preset attention network, and the confidences are obtained by performing multi-round loss forward propagation on the plurality of feature extraction models respectively;
[0014] a determination unit configured to determine a detection result of the to-be-detected image by using the hybrid model according to the fusion feature vector.
[0015] The application also provides an electronic device, comprising: a memory configured to store a computer program; and a processor configured to execute the computer program to implement the steps of any of the above image detection methods.
[0016] The application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of any of the above image detection methods.
[0017] The application also provides a computer program product, comprising a computer program, and the computer program is executed by a processor to implement the steps of any of the above image detection methods.
[0018] This application discloses an image detection method, electronic device, and storage medium. Through a parameter-optimized hybrid model and adaptive feature fusion mechanism, it effectively solves the problems of poor adaptability and insufficient fine-grained feature recognition in complex environments. Specifically, by combining global exploration and local fine-grained search parameter tuning, the target detection model and the hybrid feature extraction model can break through the limitations of fixed rules and automatically adapt to the detection needs of different scenarios, significantly improving the recognition of complex factors and reducing false positives and false negatives. Through dynamic weighted fusion based on attention weights and model confidence, the complementary advantages of different feature extraction models are fully utilized, enabling the fused feature vector to adaptively strengthen the feature representation most relevant to the current detection task, especially for hard-to-capture fine-grained violation features, achieving accurate and stable recognition. This application can achieve high-precision, highly adaptive image detection without relying on predefined thresholds or fixed rules, significantly improving its practicality and reliability in complex application scenarios such as industrial monitoring and security protection. Attached Figure Description
[0019] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 A schematic flowchart of an image detection method provided in an embodiment of this application;
[0021] Figure 2 This is a schematic diagram of the application architecture of an image detection method provided in an embodiment of this application;
[0022] Figure 3 This application provides a schematic diagram of a parameter tuning process.
[0023] Figure 4 A schematic diagram of a feature fusion process provided in an embodiment of this application;
[0024] Figure 5 This is a schematic diagram of the structure of an image detection device provided in an embodiment of this application;
[0025] Figure 6 This is a schematic diagram of another image detection device provided in an embodiment of this application. Detailed Implementation
[0026] With reference to the drawings and embodiments of the present application, the technical solutions in the embodiments of the present application will be described clearly and completely. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0027] It should be noted that in the description of the present application, the terms "comprise", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or equipment comprising a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or equipment. The terms "first", "second" and the like in the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence.
[0028] An image detection method of the present application realizes accurate positioning and classification detection of target objects in an image by combining a target detection model and a hybrid feature extraction model. The core of the image detection method is to optimize the model performance through parameter tuning, and to use attention mechanism and confidence weighted fusion of multi-model features to improve the accuracy and robustness of detection.
[0029] The image detection method refers to a process of analyzing input images through computer vision and deep learning technology to identify and locate specific target objects in the images. This method is widely used in industrial quality inspection, security monitoring, medical imaging and other fields, and is particularly suitable for scenarios that require fine detection of specific regions in images, such as scenarios that require identification of specific objects from images and evaluation of their attributes, device status detection in industrial scenarios, personnel behavior recognition in security scenarios, and anti-static clothing compliance detection.
[0030] In order for those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the drawings and specific embodiments.
[0031] Figure 1 A flowchart of an image detection method provided by an embodiment of the present application is shown, and the method is described in detail in combination with the execution flow of the image detection method.
[0032] Step 101: positioning processing of the target detection model is performed on the image to be detected to determine the target object region in the image to be detected.
[0033] In the embodiments of the present application, the target detection model is a neural network model based on deep learning, such as a YOLOv8 model, which can extract image features based on convolutional layers, pooling layers, etc., analyze the pixel distribution, texture features, shape contours, etc. of the image at multiple levels, and output the bounding box coordinates and class probabilities of the target object by combining the pre-set target object features (such as the aspect ratio of the human body, the typical contour of the product, etc.). Common implementation methods include anchor-based detection frameworks, which complete target positioning through regression and classification tasks.
[0034] The to-be-detected image refers to image data that needs to be subjected to target recognition and attribute judgment, and its source can cover various image acquisition devices, including but not limited to high-definition intelligent cameras, industrial cameras, edge sensors, etc., and can be static images or single-frame images obtained by decomposing video stream data. The content of the to-be-detected image needs to be matched with the specific detection scene, for example, in the anti-static clothing compliance detection scene, the to-be-detected image is usually an image containing personnel taken in the scene of an electronic workshop, a research and development laboratory, etc.; in the industrial defect detection scene, the to-be-detected image is an image containing a to-be-detected product taken on a production line. It needs to be noted that all image acquisition operations are performed under the authorization of the user and in strict compliance with relevant laws and regulations on privacy and security, and at the same time, the image containing personnel taken in the scene of an electronic workshop, a research and development laboratory, etc. is collected for the purpose of maintaining safety.
[0035] The target object region refers to a local region in the image containing the to-be-detected target, which is usually represented in the form of a rectangular bounding box, and the coordinate information thereof is used to crop the region of interest for subsequent feature extraction. This step converts the entire image into a number of candidate regions through model inference, effectively reducing the detection range and improving the efficiency of subsequent processing.
[0036] Step 102, performing feature extraction on the target object region through a hybrid model comprising a plurality of feature extraction models to obtain feature vectors output by each of the plurality of feature extraction models, wherein the hybrid model and the target detection model are obtained through parameter tuning, and the parameter tuning at least includes positioning a target parameter region through a first algorithm for global exploration, and determining the target parameters of the model through a second algorithm for local fine search in the target parameter region.
[0037] In the embodiments of the present application, the mixed model refers to a model set composed of multiple feature extraction models with different feature extraction capabilities, such as a model set composed of ResNet50, MobileNetV2, ShuffleNet and the like. The purpose is to utilize the technical advantages of different feature extraction models to obtain multi-dimensional and multi-level feature information from the target object region, so as to make up for the limitations of a single feature extraction model in feature capturing. For example, some feature extraction models are good at mining deep texture features of images (such as damage marks of clothes, fine scratches of products), and some feature extraction models are good at capturing shallow contour features and color features (such as the style of clothes, the appearance color of products). Combining these models to form a mixed model can more comprehensively cover the feature dimensions of the target object.
[0038] The feature extraction model is the core component unit of the mixed model, which is an algorithm model capable of converting pixel information of an image region into a vector form with a representation meaning. Through a series of operations such as convolution, pooling and activation, the feature extraction model extracts key information that can reflect the attributes of the target object from the target object region. The feature extraction model will perform layer-by-layer processing on the input target object region image, gradually filter redundant information and strengthen key features, and finally output a vector data representing the characteristics of the target object region, i.e., a feature vector. Since the mixed model includes multiple feature extraction models, each feature extraction model will output a corresponding feature vector according to its feature extraction logic and emphasis, and thus multiple feature vectors will be obtained. These feature vectors reflect the attribute information of the target object region from different dimensions.
[0039] Parameter tuning refers to the process of adjusting model hyperparameters or structural parameters through optimization algorithms to minimize loss functions and improve model performance. The first algorithm is a meta-heuristic algorithm for global search, such as the Moth-Flame Optimization Algorithm (MFO), which simulates natural phenomena or group behavior to explore a wide range of parameters in the parameter space to identify potentially high-performance areas. Global exploration refers to the algorithm randomly or directionally sampling within the preset parameter range to avoid falling into local optimal solutions. The target parameter region refers to the subspace in the parameter space with better performance, and the parameter combination within it can make the model perform better on the validation set. The second algorithm is an optimization algorithm for local search, such as the Sailfish Optimizer (SFO), which performs fine iterations within the high-performance parameter region to find the optimal parameter combination. Local fine search refers to the algorithm adjusting parameters within a limited range with small steps to gradually approach the optimal solution. The target parameter refers to the final model parameter determined after tuning, including convolution kernel size, learning rate, channel number, etc., which directly affects the model's feature extraction ability and classification accuracy. This tuning process balances exploration and utilization by combining global and local search, ensuring that the model maintains high performance under complex data distribution.
[0040] In step 103, the plurality of feature vectors are weighted and fused according to their respective attention weights and confidence levels to generate a fused feature vector, wherein the attention weights are obtained by inputting the plurality of feature vectors into a preset attention network, and the confidence levels are obtained by multiple rounds of forward propagation of the plurality of feature extraction models.
[0041] In the embodiments of the present application, the attention weight refers to a scalar value calculated by the attention mechanism, which reflects the importance of each feature vector in the fusion process. The confidence level refers to the certainty measure of the feature extraction model for its output result, and the higher the value represents the greater the grasp of the classification result by the feature extraction model. Weighted fusion refers to the process of linearly combining multiple feature vectors according to weights, which realizes the integration of feature information through weighted summation. The fused feature vector refers to the joint feature representation obtained after fusion, which integrates the feature advantages of multiple models and improves the discriminative ability of features.
[0042] The preset attention network is a pre-trained neural network model with feature importance evaluation capability, which calculates feature importance through fully connected layers, activation functions, etc. Common implementations include channel attention-based architectures that generate weights through compression and excitation operations. This network concatenates multiple model feature vectors, compresses the spatial dimension through global average pooling, maps it to attention scores through fully connected layers, and finally normalizes the attention weights of each model by grouping.
[0043] The confidence is obtained through multiple rounds of dropout forward propagation of each feature extraction model. The multiple rounds of dropout forward propagation refers to randomly enabling a dropout layer multiple times in the forward inference process to simulate model uncertainty. Specifically, each feature extraction model performs multiple independent inferences on the same input sample to obtain multiple sets of output probability distributions; the confidence index is calculated by counting the average probability and standard deviation of the optimal class. The higher the confidence, the more stable the model output, and the higher the weight given in the fusion.
[0044] At step 104, the detection result of the to-be-detected image is determined by the hybrid model according to the fused feature vector.
[0045] In the embodiments of the present application, the detection result refers to the final judgment conclusion made by the hybrid model on the to-be-detected image based on the fused feature vector, which can include compliance judgment, class label, confidence score, etc. This step inputs the fused feature vector into the fully connected layer or classifier to generate the detection result through the Softmax function or regression head.
[0046] The present application effectively improves the detection accuracy and generalization ability through multi-model cooperation and adaptive fusion, especially suitable for complex scenes such as changes in illumination and target occlusion.
[0047] It should be noted that the specific form of the detection result needs to match the requirements of the detection scene, for example: in the anti-static clothing compliance detection scene, the detection result can be divided into compliance, zipper not pulled together, sleeve not tightened, clothing damage, etc. In the industrial product defect detection scene, the detection result can be divided into qualified, surface scratch, size deviation, component missing, etc. In the personnel behavior recognition scene, the detection result can be divided into normal behavior, illegal intrusion, abnormal behavior, etc.
[0048] The hybrid model usually has a classification module built-in, which will further analyze and calculate the input fused feature vector. Specifically, the classification module will map the fused feature vector to a pre-set class space, calculate the probability of the fused feature vector belonging to each class through the softmax activation function, and finally select the class with the highest probability as the detection result of the to-be-detected image. Since the fused feature vector has integrated the high-quality features of multiple feature extraction models and excluded the interference of low-reliability features through attention weights and confidence, the detection result output by the hybrid model based on this fused feature vector has high accuracy and reliability, effectively meeting the precision requirements of various image detection scenes, and having strong adaptability to complex scenes (such as changes in illumination, high personnel density, and multiple background disturbances).
[0049] The application optimizes the model performance through parameter tuning, and realizes feature fusion by using attention mechanism and confidence weighting, enhances the model's ability to capture target features, and improves the stability and adaptability of image detection. It can be widely used in industrial detection, intelligent monitoring and other fields, and provides an efficient and reliable solution for image analysis tasks.
[0050] In an implementation manner of the embodiment of the application, before the fusion feature vector is generated, the confidence degrees corresponding to the plurality of feature vectors are determined, so as to be weighted and fused according to the confidence degrees subsequently. Specifically, the following methods can be used, but are not limited to: based on the target object region, a plurality of features extraction models are independently subjected to multiple times of loss forward propagation, a plurality of sets of class probabilities corresponding to the plurality of feature extraction models are obtained, the class probability is the probability of a class to which the target object region belongs; the class probability with the highest occurrence frequency in the plurality of sets of class probabilities corresponding to the plurality of feature extraction models is determined as the target class probability corresponding to the plurality of feature extraction models; the average value and the standard deviation corresponding to the plurality of target class probabilities are calculated according to the occurrence frequencies corresponding to the plurality of target class probabilities, and the confidence degrees corresponding to the plurality of feature extraction models are obtained by normalization calculation based on the average value and the standard deviation.
[0051] In the embodiment of the application, each feature extraction model has its unique feature capturing logic (for example, some are good at deep texture feature extraction, and some are good at shallow outline feature extraction), so independent multiple times of loss forward propagation operation needs to be performed on each feature extraction model respectively, to ensure that the reliability evaluation of each model is not affected by other models. Multiple times of loss forward propagation means that, for a single feature extraction model, when processing the same target object region, multiple times of forward propagation process with a dropout mechanism are repeatedly performed: in each forward propagation process, the model randomly discards part of the network nodes (neurons), so that the model extracts features and predicts classes of the target object region in different network structure states; the multiple settings need to ensure that the different node dropout combinations of the model can be covered, to avoid that the result distribution is not representative due to too few propagation times; independence emphasizes that the different times of loss forward propagation of the same feature extraction model do not interfere with each other, the node dropout selection and the intermediate calculation process of each propagation are independently performed, to truly reflect the output stability of the model in different running states.
[0052] The category probability refers to a probability value of a feature extraction model predicting that a target object region belongs to a preset category after a loss forward propagation. The value range is usually [0, 1], and the value closer to 1 represents that the model considers that the target object region belongs to the category with a higher possibility; the value closer to 0 represents that the possibility is lower. The preset category needs to be determined according to a specific detection scene. For example, in the anti-static clothing compliance detection scene, the preset category can include compliance, zipper not pulled, sleeve not tightened, clothing damage, and the like; in the industrial product defect detection scene, the preset category can include qualified, surface scratch, size deviation, and the like. Since each feature extraction model performs multiple independent loss forward propagations, each feature extraction model will correspondingly output multiple groups of category probabilities. For example, a certain feature extraction model performs 10 loss forward propagations, and 10 groups of category probabilities are obtained, each of which reflects the judgment result of the model on the category of the target object region under a certain network state.
[0053] The target category probability is a screening result of multiple groups of category probabilities of a single feature extraction model, and the screening logic is based on the principle of the highest frequency. In multiple groups of category probabilities of a certain feature extraction model, the number of times (i.e., the frequency) of occurrence of each category probability is counted, and the category probability with the highest frequency of occurrence is selected as the target category probability of the model. The purpose of this screening process is to exclude the accidental deviation of a single prediction of the model. If a certain category probability frequently appears in multiple independent propagations, it means that the category probability is the mainstream result of the model's judgment on the category of the target object region, and can better represent the real prediction tendency of the model, rather than an abnormal result caused by improper node discarding. By determining the target category probability, multiple scattered prediction results can be focused on a representative core result, providing a clear and explicit analysis object for subsequent statistical calculation.
[0054] The average value refers to an average value of a target class probability of a feature extraction model in multiple sets of class probabilities combined with the frequency of occurrence. The average value can be calculated by, but is not limited to, the following method: multiplying the target class probability and the corresponding frequency of occurrence to obtain the total contribution value of the target class probability, and then dividing the total number of times of performing forward propagation before loss of the feature extraction model to finally obtain the average value. The average value can reflect the overall confidence level of the feature extraction model in predicting the target class probability. The higher the average value, the higher the degree of recognition of the model to the target class probability in multiple propagations, and the more explicit the overall prediction tendency. The standard deviation is a statistical indicator for measuring the fluctuation degree of multiple sets of class probabilities of the feature extraction model around the target class probability. The standard deviation can be calculated by, but is not limited to, the following method: first calculating the deviation of each set of class probabilities from the average value, then performing a weighted average (the weight is the frequency of occurrence of the corresponding class) on the squares of all deviations, and finally taking the square root of the weighted average result to obtain the standard deviation. The standard deviation can reflect the stability of the model output. The smaller the standard deviation, the smaller the fluctuation of multiple sets of class probabilities around the average value, the more consistent the prediction results of the model under different network states, and the stronger the output stability. On the contrary, it means that the model output fluctuates greatly and has poor stability.
[0055] Finally, the normalization calculation based on the average value and the standard deviation is a comprehensive quantification based on the complementary effect of the two on the reliability of the model. The average value reflects the confidence level of the model prediction, the standard deviation reflects the stability of the model prediction, and the combination of the two can comprehensively reflect the degree of grasping of the feature extraction model to its output feature vector. For example: if the average value of the target class probability of a certain feature extraction model is high and the standard deviation is low, it means that the model not only generally recognizes the target class probability, but also outputs stable results. The confidence obtained after summation will be higher, representing that the feature vector output by the model has strong reliability, and the model should be given a higher weight in subsequent feature fusion; if the average value of a certain feature extraction model is low or the standard deviation is high, the confidence obtained after summation will be lower, representing that the feature vector output by the model has weak reliability, and its weight should be reduced in subsequent fusion to avoid interference of low-reliability features on the fusion result.
[0056] Further, regarding the calculation of the confidence, the following methods can be used, but are not limited to: using Dropout integration and class probability statistics to ensure calculation efficiency and effectively measure the stability of the model output. Multiple rounds of Dropout forward propagation are used to collect the prediction probability distribution, i.e., a single model is independently forward propagated K times to obtain K sets of class probability vectors. The probability statistics indicators of the optimal class are calculated. First, for the K sets of probability vectors, the optimal prediction class of the model for the current sample is determined, i.e., the class with the highest frequency in K times of propagation. Two core statistical indicators, average probability and probability standard deviation, are calculated for the optimal class to measure the overall confidence level of the optimal class and the stability of the optimal class probability, respectively. The average probability and standard deviation are combined to calculate the final confidence of the single model for the current sample through a normalization formula. The closer to 1, the stronger the certainty.
[0057] Through confidence calculation, the reliability of each feature extraction model under a specific input sample can be dynamically evaluated, so that the weight proportion can be adjusted in the subsequent feature fusion stage. The robustness of the multi-model is enhanced, especially in the face of complex scenes such as light changes, target occlusions, or image noise, the contribution of unstable models can be adaptively reduced through confidence, and the overall detection accuracy is improved. In addition, this process does not require external data or manual intervention, and is completely based on model output for automatic evaluation, meeting the needs of efficiency and adaptability in industrial detection.
[0058] In an implementation manner of the embodiment of the present application, before the fusion feature vector is generated, the attention weights corresponding to the plurality of feature vectors are determined, so as to be weighted and fused according to the attention weights subsequently. Specifically, the following methods can be used, but are not limited to: after the plurality of feature vectors are processed in dimension alignment, the plurality of processed feature vectors are spliced along the feature channel direction to obtain a joint feature vector; the joint feature vector is input into a preset attention network, spatial dimension compression is performed through global average pooling to obtain a compressed feature vector, wherein the feature channel dimension of the compressed feature vector is the same as that of the joint feature vector; after the compressed feature vector is processed in dimension reduction through a first fully connected layer in the preset attention network, the first fully connected layer is activated through a first activation function to obtain a first feature vector, and after the first feature vector is processed in dimension restoration through a second fully connected layer in the preset attention network, the second fully connected layer is activated through a second activation function to obtain a channel score corresponding to each of the plurality of feature channels; and the attention weights corresponding to the plurality of feature extraction models are calculated according to the channel score.
[0059] In the embodiment of the present application, due to the differences in structure design and feature capture logic of different feature extraction models, the dimensions of the feature vectors output by the different feature extraction models may not be consistent, and therefore, the plurality of feature vectors need to be processed in dimension alignment.
[0060] The dimension alignment processing refers to an operation of mapping feature vectors output by different feature extraction models to a same preset dimension (such as D dimension) through a preset dimension unification strategy. The dimension of the feature vector can be converted from an original dimension to the D dimension through a fully connected layer, and in the conversion process, the weight parameters of the fully connected layer are adjusted through back propagation training to ensure that the feature vector can still retain the original key information reflecting the regional attribute of the target object after the dimension conversion. The dimension alignment processing is to eliminate the dimension difference of the feature vectors between different feature extraction models.
[0061] The feature channel direction refers to the extension direction of the feature vector in the feature dimension, which is different from the spatial dimension (such as width and height) of the image. The feature channel direction represents the category dimension of the feature, that is, each feature channel corresponds to a specific type of feature information (such as a texture feature channel, a color feature channel, a contour feature channel, etc.). The splicing along the feature channel direction refers to the superposition of the dimension-aligned multiple feature vectors in the channel dimension, for example, if the feature vectors of three feature extraction models are D dimension after alignment (that is, each model corresponds to D feature channels), then after splicing along the feature channel direction, the joint feature vector obtained has a dimension of 3D (that is, it contains 3D feature channels, of which the first D channels correspond to the features of the first feature extraction model, the middle D channels correspond to the features of the second feature extraction model, and the last D channels correspond to the features of the third feature extraction model).
[0062] The preset attention network function is to identify the feature channels that are more important for the current detection task from the joint feature vector and quantify the importance degree.
[0063] The global average pooling is an operation of simplifying the spatial dimension of the feature vector (or feature map), and the specific process includes but is not limited to: calculating the average value of all spatial elements under each feature channel corresponding to the spatial dimension data in the joint feature vector, and using the average value to represent the overall feature information of the feature channel. In order to eliminate the spatial dimension of the joint feature vector and retain the feature channel dimension information, a compressed feature vector is obtained. It should be particularly noted that the feature channel dimension of the compressed feature vector is the same as that of the joint feature vector, for example, if the joint feature vector is 3D feature channel, the compressed feature vector still maintains 3D feature channel, and only the spatial dimension is compressed.
[0064] The first fully connected layer is a network layer in the attention network for reducing the feature dimension, and the input is the compressed feature vector (dimension 3D), and the output dimension can be preset as D / 4 dimensions (the specific dimension can be adjusted according to the detection scene requirement). The purpose of the dimension reduction processing is that although the spatial dimension has been eliminated in the compressed feature vector, the channel number of the 3D dimension can still cause excessive calculation in the subsequent calculation. By reducing the dimension through the first fully connected layer, the number of network parameters and the calculation overhead can be significantly reduced on the premise of ensuring effective transmission of feature information. The first activation function is a function selected by the present application for introducing nonlinear features into the neural network, for example, a rectified linear unit (ReLU) activation function.
[0065] The second fully connected layer is opposite to the first fully connected layer, and the input is the first feature vector (dimension D / 4), and the output dimension needs to be restored to the same feature channel dimension (3D) as the joint feature vector. The purpose of the dimension restoration processing is to map the feature vector after the dimension reduction and the nonlinear activation back to the original feature channel dimension space, so as to ensure that the channel importance score output subsequently can correspond to each feature channel of the joint feature vector. The second activation function is a function selected by the present application, for example, a Sigmoid activation function.
[0066] Finally, the attention weights corresponding to the plurality of feature extraction models are calculated according to the channel scores.
[0067] The present application avoids the weight evaluation deviation caused by the abnormal value of the single channel score by comprehensively considering the importance of all feature channels of each feature extraction model, ensures that the attention weight of each feature extraction model can accurately reflect the overall importance of all feature channels thereof, provides accurate importance basis for the subsequent weighted fusion of the feature vector, and thus ensures that the fused feature vector can focus on the most critical feature information of the detection result, and further improves the precision and adaptability of the entire image detection method.
[0068] In an implementation manner of the embodiment of the present application, when the attention weights corresponding to the plurality of feature extraction models are calculated according to the channel scores, the following manner can be adopted but is not limited to: the plurality of channel scores are grouped according to the feature channels corresponding to the plurality of feature extraction models respectively to obtain the grouped channel scores corresponding to the plurality of feature extraction models respectively; and all channel scores in each grouped channel score are averaged to obtain the attention weights corresponding to the plurality of feature extraction models respectively.
[0069] In the embodiments of the present application, the grouping processing refers to the operation of dividing the channel scores into several groups according to the source of the feature extraction model, specifically, the channel dimension of the joint feature vector is equally divided according to the number of original feature extraction models, and each subgroup corresponds to all output channels of one feature extraction model, so as to ensure that the channel scores of each model are independently aggregated. The grouped channel score refers to the channel score set corresponding to each feature extraction model after grouping, which retains the importance information of all channels of the model and provides a basis for subsequent weight calculation.
[0070] Specifically, since the joint feature vector is spliced by the feature vectors of multiple feature extraction models along the feature channel direction, and each feature extraction model corresponds to a group of continuous feature channels in the joint feature vector, when calculating the attention weight, all channel scores need to be grouped according to the attribution of the feature extraction model, that is, the channel scores of the first D channels are grouped into the first group (corresponding to the first feature extraction model), the channel scores of the middle D channels are grouped into the second group (corresponding to the second feature extraction model), and the channel scores of the last D channels are grouped into the third group (corresponding to the third feature extraction model). Then, the sum of all channel scores in each group is calculated, and the average value is calculated, which is the attention weight of the corresponding feature extraction model. For example: the first group contains D channel scores, and the average value obtained by dividing the sum of the D channel scores by D is the attention weight of the first feature extraction model.
[0071] In order to facilitate understanding of the determination process of the attention weight in the present application, an example is provided for illustration: the feature vector splicing is a pre-operation of multi-model feature fusion, which integrates the feature vectors of different dimensions output by the feature extraction models ResNet50, MobileNetV2 and ShuffleNet into a joint feature vector with fixed dimension, providing input for subsequent attention network weight calculation.
[0072] First, the original feature vectors output by the three models after feature extraction are , , The dimensions are all D (the original features are mapped to D dimensions through a fully connected layer), and the channel dimension splicing is adopted, and the splicing process can be realized by but not limited to the following ways: , , .
[0073] The joint feature vector is compressed by global average pooling (GAP) The spatial dimension is compressed, the feature information of the channel dimension is reserved, an aggregated feature vector is obtained, only the spatial dimension is compressed, the number of channels remains unchanged, and it is ensured that the features of each model can still be identified individually; a module is constructed through two full connections and an activation function, the importance score of each channel is calculated, and then the sum is grouped according to the model dimension to obtain the attention weights of the three models.
[0074] Specifically, the first full connection (dimension reduction): 3D features are compressed to D / 4 dimensions (to reduce the amount of calculation and enhance the generalization ability), and the activation function uses ReLU; the second full connection (dimension increase): the D / 4-dimensional features are restored to 3D, and the activation function uses Sigmoid to adapt the weight; group sum: the channel scores of the 3D dimension are divided into 3 groups (D dimensions each) according to the model attribution, and the average of the sum of all channel scores in each group is taken to obtain the attention weights of the three models 、 、 which can be calculated by, but not limited to, the following formula:
[0075]
[0076]
[0077]
[0078] wherein, is the channel score output by the second full connection layer.
[0079] Through the above grouping processing and average calculation, the generation process of the attention weight can effectively integrate the local information of the feature channels of the multiple models to form a global model importance evaluation. Not only the robustness of feature fusion is enhanced, but also the contribution proportion of each model can be dynamically adjusted according to the content of the input image, which is especially suitable for detection scenes with diverse target object shapes or variable environments, and improves the perception ability of the model to key features and the overall detection accuracy.
[0080] In an implementable manner of the embodiment of the present application, when the multiple feature vectors are weighted and fused according to the respective attention weights and confidence to generate a fused feature vector, the following manner can be adopted, but is not limited to: the multiple feature vectors are respectively multiplied with the respective attention weights to obtain weighted feature vectors corresponding to the multiple feature vectors respectively; the respective preset initial weights of the multiple feature vectors are respectively multiplied with the respective attention weights and the confidence to obtain target weights corresponding to the multiple feature vectors respectively, wherein the preset initial weights are determined based on the average accuracy of the multiple feature extraction models in historical data processing; the multiple weighted feature vectors are weighted and fused according to the respective target weights to obtain the fused feature vector.
[0081] In the embodiments of the present application, the product processing refers to the operation of multiplying each element of the feature vector with the corresponding attention weight, which realizes the scaling of the feature value through scalar weighting, so that the features with high importance are enhanced and the features with low importance are suppressed. The weighted feature vector refers to the feature representation obtained after product processing, which retains the spatial structure and channel relationship of the original features, but the numerical amplitude is recalibrated according to the attention weight, highlighting the feature information of key model contribution.
[0082] The preset initial weight refers to the benchmark weight value preset based on the average accuracy of each feature extraction model on the historical data set, which reflects the overall performance level of the model in the long-term training and verification process; the higher the accuracy of the model, the larger the preset initial weight value is usually set.
[0083] The historical data processing refers to the batch inference and performance evaluation process of the model on the labeled data set in the training and verification stage, which calculates the prediction results through forward propagation and compares them with the true labels to calculate the classification accuracy of each model. The average accuracy refers to the arithmetic mean of the accuracy of the model on multiple historical data sets or cross-validation folds. The preset initial weight is proportionally distributed according to the average accuracy to ensure that the model with better performance obtains a higher basic weight at the beginning of fusion, providing a reasonable starting point for subsequent dynamic adjustment.
[0084] The weighted fusion processing here refers to the operation of linearly combining multiple weighted feature vectors according to the target weight, which integrates the advantage features of each model through weighted summation to form a unified feature representation. The fusion feature vector refers to the joint feature representation obtained after weighted fusion, which integrates the feature information of multiple models and optimizes the adjustment according to the long-term performance, current importance and output reliability of each model, having stronger discriminability and adaptability.
[0085] Specifically, regarding the calculation of the fusion feature vector, the following methods can also be used, but are not limited to: using feature extraction models ResNet50, MobileNetV2, and ShuffleNet to extract features from the image respectively to obtain their respective feature vectors , , Assign an initial weight to the feature vector of each model , , The initial weight is set according to the average accuracy of the model on the historical data set. Multiply the feature vector of each model with the corresponding attention weight to obtain the weighted feature vector , , According to the attention weight and the confidence, the initial weight is dynamically adjusted to obtain a final target weight:
[0086]
[0087]
[0088]
[0089] The weighted feature vector is fused according to the final target weight to obtain a fused feature vector:
[0090]
[0091] The fused feature vector is input into a classification layer to obtain a classification output of the to-be-detected image, that is, a detection result.
[0092] Through the weighted fusion process, the present application realizes fine integration of multi-model features, considers both long-term performance of the model and importance of the current sample features and output certainty, so that the fused feature vector can more accurately reflect the essential characteristics of the target object. The adaptability and classification accuracy in a complex scene are significantly improved, and a more reliable feature basis is provided for the image detection task.
[0093] In an implementable manner of the embodiment of the present application, before image detection, the target detection model and the hybrid model need to be parameter-optimized so as to subsequently complete the image detection task. Specifically, the following methods can be used, but are not limited to: based on the first algorithm and a plurality of first model parameter groups, the initial detection model is trained and verified by using training image data and verification image data, and a target parameter region is determined from the plurality of first model parameter groups, wherein the plurality of first model parameter groups are parameters sampled from a preset parameter search space in the training and verification process of the initial detection model, and the preset parameter search space is a parameter set containing a plurality of model parameters; a plurality of second model parameter groups are selected in the target parameter region, the initial detection model is trained and verified by using training image data and verification image data based on the second algorithm and the plurality of second model parameter groups, and a target parameter is determined from the plurality of second model parameter groups; and the initial detection model is parameter-optimized based on the target parameter to obtain the target detection model.
[0094] In the embodiments of this application, the first algorithm is a metaheuristic global optimization algorithm that simulates natural phenomena or group behavior to extensively explore the parameter space to identify potential high-performance parameter regions. For example, the moth-to-a-flame optimization algorithm covers a large number of parameter combinations through random walks and iterative updates. Multiple first model parameter sets refer to multiple sets of parameters randomly or directionally sampled from a preset parameter search space during the parameter tuning process. Each set of parameters includes model structure parameters and training hyperparameters, such as the number of convolutional layers, the number of channels, the anchor box size, and the learning rate. These parameter sets participate in model training and evaluation as candidate solutions.
[0095] Training image data refers to the labeled image set used for model training, containing bounding boxes and class labels of target objects. Model weights are optimized through backpropagation and gradient descent. Validation image data refers to a separate image set used for model validation. It is not involved in the training process and is used to evaluate the model's generalization performance on unseen data, preventing overfitting. The initial detection model refers to the original object detection network without parameter optimization, such as a pre-trained model based on the YOLOv8 architecture. It possesses basic detection capabilities but may not be suitable for specific scenario requirements. The target parameter region refers to the subspace with superior performance located in the parameter search space by the first algorithm. Parameter combinations within this region enable the model to exhibit high accuracy or low loss on the validation set. It is determined through cluster analysis or performance thresholding, providing a focus range for subsequent local searches.
[0096] The predefined parameter search space is a set of parameters containing multiple model parameters. It defines the boundary conditions for parameter tuning and covers the selectable range of model structure parameters and training hyperparameters. The predefined parameter search space includes dimensions such as the number of convolutional layers, the number of convolutional channels, anchor box size, initial learning rate, weight decay coefficient, loss function penalty coefficient, and batch size. Each parameter has a predefined upper and lower bound to ensure the search is conducted within a reasonable range. For example, the anchor box size is set according to the aspect ratio characteristics of the target object to avoid invalid parameter values; the learning rate is sampled on an exponential scale to cover the needs of different convergence speeds. The design of this search space is based on the characteristics of the object detection task and the constraints of the model architecture, ensuring the comprehensiveness and effectiveness of parameter tuning.
[0097] The plurality of second model parameter groups refers to parameter combinations further sampled from the target parameter region, which has a reduced sampling range and finer granularity, focusing on mining the optimal solution in the region. The second algorithm is a local fine search optimization algorithm that simulates precise pursuit behavior to perform small step iterations in a limited parameter space, for example: marlin optimization algorithm, which gradually approaches the optimal parameters through elite guidance and random disturbance. The target parameter refers to the optimal parameter combination determined after local search, which can make the model achieve the highest performance indicator on the validation set, such as maximum average precision or minimum loss value. This parameter is used as the final configuration of the model for actual detection tasks.
[0098] The parameter optimization process refers to the process of applying the target parameter to the structure adjustment and hyperparameter setting of the initial detection model, which improves the model performance by modifying the network layer configuration, updating the optimizer settings, etc. For example: adjusting the number of convolution channels to enhance feature extraction capability, or optimizing anchor box size to better match the shape distribution of target objects. This process ensures that the model adapts to the needs of specific detection scenarios, improving positioning accuracy and inference efficiency.
[0099] The present application realizes fine optimization of the target detection model through the above parameter tuning process, which utilizes the universality of global exploration and the accuracy of local search, enabling the model to quickly converge to a high-performance state. This significantly improves the model's adaptability and detection stability in complex environments, providing more reliable underlying support for image detection tasks.
[0100] In one implementation manner of the embodiment of the present application, when determining the target parameter region from the plurality of first model parameter groups, the following implementation manners can be used, but are not limited to: randomly sampling a plurality of first model parameter groups from the preset parameter search space based on a first search radius; training and verifying the initial detection model using training image data and verification image data for each first model parameter group, obtaining a plurality of performance indicators corresponding to each of the plurality of first model parameter groups, and converting the plurality of performance indicators into fitness values respectively; combining the centering manner of the first model parameter group with the lowest fitness value and the random sampling manner to sample a plurality of first iteration parameter groups from the preset parameter search space, training and verifying the initial detection model based on each first iteration parameter group; repeating the training and verification of the initial detection model until a first preset iteration number is reached, obtaining a plurality of target first model parameter groups, wherein the target first model parameter group is the parameter group with the lowest fitness value in each round of training and verification of the initial detection model; and performing clustering analysis on the plurality of target first model parameter groups to obtain the target parameter region.
[0101] In the embodiments of the present application, the first search radius refers to the random walk range when sampling parameters, which defines the fluctuation amplitude of each parameter value in the search space. The larger the radius, the wider the exploration range, which helps to discover scattered high-quality areas. For example, if the preset search range of a certain structural parameter (such as the number of convolution channels) is 32-256, and the first search radius is set to (256-32) x 0.2 = 44.8, then the initial sampling range of this parameter will be randomly sampled within 32-256 with a radius of 44.8. The purpose of setting the first search radius is to avoid the initial sampling range being too large, which leads to too scattered parameter combinations, or the range being too small, which leads to incomplete search.
[0102] The performance indicators refer to quantitative standards reflecting the detection capability of the model, including but not limited to mAP@0.5 (average precision mean when the intersection over union threshold is 0.5, which measures the matching accuracy of the model positioning bounding box and the real bounding box), recall rate (which measures the proportion of target objects successfully identified by the model from the verification image), loss value (which measures the error size of the model prediction result and the true label), etc. These indicators collectively reflect the influence of the first model parameter group on the performance of the initial detection model. The fitness value is the conversion of the performance indicators into scalar values that can be processed by the optimization algorithm. The lower the value, the better the model performance. For example, for mAP@0.5, the fitness value can be calculated as 1 - mAP@0.5 (if mAP@0.5 is 0.8, then the fitness value is 0.2); for the loss value, the loss value can be directly used as the fitness value (if the loss value is 0.3, then the fitness value is 0.3); if there are multiple performance indicators, they can be integrated into a single fitness value by weighted summation (e.g., fitness value = 0.6 x (1 - mAP@0.5) + 0.4 x loss value). Through the conversion of the fitness value, the originally scattered performance indicators are unified into quantifiable values that can be directly compared, providing a clear and unified judgment standard for subsequent selection of the optimal parameter group.
[0103] The first model parameter group with the lowest fitness value refers to the parameter combination with the best performance in the current iteration, which serves as an attractor to guide the subsequent sampling direction. Random sampling refers to completely random selection of parameter combinations in the parameter space, which ensures that the algorithm maintains global exploration ability and avoids premature convergence to local optima. The first iteration parameter group refers to the new generation of parameter set obtained by combining central attraction and random sampling, which not only develops locally around the current optimal parameter, but also maintains exploration vitality in the global range.
[0104] The first preset number of iterations refers to the maximum number of iterations set in the global exploration stage, for example, 30 rounds, which ensures that the algorithm has enough time to search sufficiently in the parameter space. The target first model parameter group refers to the high-quality parameter combination retained in each iteration, which represents the potential high-quality solution discovered by the algorithm in the exploration process.
[0105] The clustering analysis process refers to the process of merging similar target first model parameter groups into several clusters by unsupervised learning algorithm, for example: using K-Means algorithm to group according to the similarity of parameter values. The logic of clustering is: if the parameter dimension values (such as: convolution channel number, initial learning rate, anchor box size) of multiple target first model parameter groups are small, and the corresponding fitness value (performance) fluctuation is small (such as: fluctuation ≤5%), then these parameter groups belong to the same high-quality parameter cluster, representing a potential high-quality subspace in the preset parameter search space.
[0106] The specific clustering process includes but is not limited to: converting the parameter values of each target first model parameter group into vector form (such as: the number of convolution layers 10, the number of convolution channels 128, the initial learning rate 7e-4, converted into [10, 128, 7e-4]); then, calculate the Euclidean distance between each parameter vector (measure the similarity of parameter values) by K-Means algorithm, and group the parameter vectors with close distance into the same cluster; then, verify the performance of each target first model parameter group in each cluster, calculate the mean and standard deviation of the fitness values of all parameter groups in the cluster, if the standard deviation ≤5%, it means that the performance of the parameter groups in the cluster is stable, and it belongs to the high-quality parameter cluster; if the standard deviation >5%, then eliminate the cluster (avoid the influence of parameter groups with large performance fluctuation on the stability of the target parameter region).
[0107] The target parameter region refers to the parameter subspace obtained by clustering analysis, which contains multiple parameter combinations with excellent performance and similar parameter characteristics. The parameters in this region have high stability and strong generalization ability, providing a clear optimization direction for subsequent local fine search.
[0108] Further, regarding the determination of the target parameter region, the following methods can also be used, but are not limited to:
[0109] (1) Parameter encoding and search space initialization: Convert the parameters to be optimized of YOLOv8 into the encoding vector of flame individuals. All parameters to be optimized (structural parameters and training parameters) are uniformly encoded into a fixed-length vector. Each vector corresponds to a flame individual, and each dimension of the vector corresponds to the value or encoding value of a specific parameter. This ensures that the encoding can be directly mapped to the parameter combination that the model can call. At the same time, it adapts the global search logic of MFO: the number of convolution layers, the number of convolution channels, anchor box size, initial learning rate, weight decay coefficient, loss function penalty coefficient, batch size. The anchor box size is designed in multiple groups. The core is to adapt to the multi-scale feature detection logic of the model and the size difference of human targets. Through multiple anchor boxes of different sizes, the full-scale range from close-up small human bodies to long-range large human bodies is covered, ensuring that the model can accurately match human targets of different sizes and avoid detection omissions or precision decline due to single anchor box. The sum of the above parameter dimensions is a 14-dimensional vector = 1 (number of convolution layers) + 3 (number of channels) + 6 (anchor box) + 1 (initial learning rate) + 1 (weight decay) + 1 (loss function penalty coefficient) + 1 (batch size). Each flame individual is a 14-dimensional vector, and N flame individuals (such as N = 40) are randomly generated. The parameter values of each individual are randomly sampled within the preset search space.
[0110] (2) Global exploration of flame group and performance evaluation: For each flame individual (parameter group), quickly train the YOLOv8 model (only train the pre-trained model for 30 rounds, focus on loss convergence trend and preliminary fitness), calculate the performance indicators (1-mAP@0.5 as fitness value, the lower the fitness value, the better the performance) using the validation set. Update the intensity and position of the flame. In MFO, the intensity of the flame is determined by the fitness value (the smaller the fitness value, the better the performance, the higher the intensity). Stronger flames will attract weaker flames around them, while some random walks are retained to avoid local optimization. The flame individual position update formula (i.e. the sampling formula of the new parameter group) is as follows:
[0111]
[0112] where, is the jth parameter of the ith flame individual (parameter group) in the tth iteration, is the jth parameter with the lowest fitness value of the optimal flame (parameter group) in the tth generation, is the exploration factor (preset value, attenuated with iteration, balancing global exploration and local proximity). is a standard normal distribution random number.
[0113] The exploration factor adopts a linear attenuation method, where t represents the current iteration, , are the values of the self-defined setting, and T represents the total number of global exploration rounds. In consideration of the random walk mechanism, 10% of the flame individuals are retained in each generation, which do not follow the optimal flame, but randomly sample parameters in the search space again to ensure coverage of unexplored areas.
[0114] (3) Clustering and screening of potential high-quality areas: iteratively perform global exploration for T rounds (T=30 rounds, which is sufficient to cover the search space), and record the parameter vectors and fitness values of all flame individuals in each round. For the high-quality flame individuals with a fitness value lower than the threshold value 0.3 in all iterations, perform parameter space clustering by using the K-Means algorithm, randomly extract 3-5 groups of parameter combinations for each cluster (potential high-quality area), and perform medium-round training (100 rounds) to verify the performance stability (fitness value fluctuation ≤5%) of the parameters in the area. Remove the clusters with large performance fluctuations or poor average performance, and finally retain 2-3 high-stability and high-performance potential high-quality parameter areas as target parameter areas.
[0115] Through the determination of the target parameter area, the present application realizes systematic exploration of the parameter space and scientific identification of high-quality areas, which not only fully utilizes the exploration ability of the global optimization algorithm, but also ensures the representativeness and stability of the parameter area through clustering analysis, thereby providing a reliable guarantee for finally determining the optimal model parameters.
[0116] In an implementable manner of the embodiment of the present application, when multiple second model parameter groups are selected in the target parameter area, the following manner can be adopted, but is not limited to: in the target parameter area, multiple second model parameter groups are randomly sampled based on a first search step length, with multiple core parameter combinations in each parameter classification in the target parameter area as the center; wherein the target parameter area includes multiple parameter classifications, each parameter classification includes multiple target first model parameter groups, and the core parameter combination is a target first model parameter group with the minimum fitness value in the parameter classification.
[0117] In the embodiment of the present application, the parameter classification refers to a group divided by a clustering algorithm according to the parameter feature similarity of the target first model parameter group, for example: based on the numerical distribution of key parameters such as the number of convolution layers and the number of channels, each classification represents a group of parameters with common structure or training characteristics.
[0118] The core parameter combination refers to a parameter set with the best performance in each parameter classification, which is determined by selecting a plurality of parameter groups with the lowest fitness value. These combinations perform best on the validation set and are used as the center point of local sampling. The preset number refers to the number of selected core parameter combinations, for example: the top 5 optimal parameter groups in each classification, which balances the concentration and diversity of the search.
[0119] The first search step size refers to a step size control parameter when sampling parameters in the target parameter region, which defines the fluctuation range of the parameter values around the core parameter combination. The smaller the step size, the more refined the sampling, which helps to explore the high-precision in the high-quality region.
[0120] In the above manner, the second model parameter combination can be systematically selected in the target parameter region. The parameter classification structure obtained by clustering analysis is utilized, and the quality basis of sampling is ensured by the core parameter combination. The sampling precision is controlled by combining the search step size. The starting point quality and directionality of the local search are significantly improved, the parameter tuning process is more efficient and stable, and a solid guarantee is provided for finally determining the optimal model parameters.
[0121] In an implementation manner of the embodiment of the present application, when the target parameter is determined from the plurality of second model parameter combinations, the following manner can be adopted but is not limited to: training and verifying the initial detection model by using the image data for training and the image data for verification for each second model parameter combination, to obtain a plurality of fitness values corresponding to the plurality of second model parameter combinations respectively; determining a preset number of target first model parameter combinations or second model parameter combinations with the smallest fitness values as a plurality of updated core parameter combinations, and sampling a plurality of second iterative model parameter combinations in the target parameter region based on the updated core parameter combinations; training and verifying the initial detection model based on each second iterative parameter combination until a second preset iteration number is reached, to obtain a plurality of candidate model parameter combinations, wherein the candidate model parameter combination is the parameter combination with the lowest fitness value in each round of training and verification of the initial detection model; performing complete training and comprehensive performance evaluation on the plurality of candidate model parameter combinations to obtain evaluation index values, and taking the candidate model parameter combination with the highest evaluation index value as the target parameter.
[0122] In the embodiment of the present application, the updated core parameter combination refers to an elite parameter set dynamically updated according to the fitness value, which is composed of a preset number of parameter combinations with the best performance in the current iteration, and is used as the center point of the next round of sampling to guide the search direction to the better region. The preset number of target first model parameter combinations or second model parameter combinations with the smallest fitness values means that if the optimal fitness value of the second model parameter combination is lower than that of the target first model parameter combination, it indicates that the current local search has found better parameters, and the second model parameter combination is selected as the updated core. If the performances of the two are close, part of the target first model parameter combination is retained to avoid the loss of parameter diversity caused by excessive focus of local search. The preset number is usually set to 3-5, which can ensure the quality of the core parameter combination and avoid the dispersion caused by too many numbers.
[0123] The second iteration model parameter set refers to a new parameter set sampled in the target parameter region based on the updated core parameter combination, which is generated by small-step random disturbance, fine development around the elite parameters, and a certain randomness to explore potential better solutions. The second preset iteration number refers to the maximum iteration number set in the local fine search stage, for example: 40 rounds, which ensures that the algorithm has enough time to fully explore in the target parameter region and avoids premature termination of the search. The candidate model parameter set refers to the optimal parameter combination retained in each round of local iteration, which is obtained by fitness value screening, representing the high-performance solution found in the local search process. These parameter sets will participate in the final comprehensive evaluation.
[0124] Full training refers to a training process of a sufficient number of rounds for a model, which uses all training image data and adopts a complete optimization strategy (such as cosine annealing learning rate, multi-scale data augmentation), ensuring that the model parameters reach a converged state. Comprehensive performance evaluation refers to a process of testing a model through multiple dimensions, including average precision, recall rate, intersection over union, inference speed, and other indicators, measuring the practicality and robustness of the model from different angles. The evaluation index value refers to the quantitative result obtained in the comprehensive performance evaluation, which combines multiple indicators into a single value through weighting or fusion to facilitate comparison of the pros and cons of different parameter sets. The target parameter refers to the optimal parameter combination determined after full training and comprehensive performance evaluation, which can make the model achieve the highest performance level on the test set and be applied to actual detection tasks as the final model configuration.
[0125] Specifically, regarding the determination of the target parameter, the following implementation can be adopted, but is not limited to: the determination of the target parameter can be implemented by using the marlin fish optimization algorithm:
[0126] (1) Local search space limitation: The potential high-quality parameter region (target parameter region) selected by the MFO method is the local search range, which reduces the parameter search granularity; the local search space is only 10%-20% of the global search space, ensuring that the search focuses on the interior of the high-quality region.
[0127] (2) Initialization and elite guidance of marlin fish group: Each potential high-quality region corresponds to a marlin fish group (size M=20, the initialization of the parameters of the marlin fish individuals is centered on the regional core parameter combination, and is randomly sampled within the local search range (for example: the anchor box size is sampled within ±15% of the core value, and the learning rate is sampled within ±10% of the core value), the top 5 optimal flame individuals (core parameter combination) in the region in the MFO are retained as the elite individuals of the marlin fish group, avoiding repeated exploration, and the optimal one in the core parameter combination or the elite individual of the region is set as the initial prey position (i.e. the current local optimal parameter).
[0128] (3) The sailfish individual approaches the prey location, and the parameter update uses small step iteration to ensure that it does not jump out of the local high-quality area. The position update formula (i.e., the selection of the second iteration parameter group) is:
[0129]
[0130] wherein, is the jth parameter of the ith sailfish in the tth generation, is the jth parameter of the current prey location, is the iteration step, which is self-defined and initially set to 0.3 and then gradually reduced to 0.05, is a random number between 0 and 1. For discrete parameters, the neighborhood sampling is updated, with an 80% probability of retaining the current value and a 20% probability of switching to a neighborhood discrete value (e.g., 64 to 128). For each sailfish individual (parameter combination), a complete 300-round training (using cosine annealing learning rate, complete IoU loss (CIoU loss)) is performed, and the 1-mAP@0.5, precision, recall, and other indicators are calculated using the validation set to update the fitness value. If the fitness value of a certain sailfish individual is lower than that of the current prey location (i.e., the performance is better), the parameter combination of the sailfish is set as the new prey location. To prevent the over-concentration of the sailfish swarm in a certain local point, a random disturbance mechanism is introduced, and every 5 iterations, 30% of the sailfish individuals are subjected to small-scale random disturbance, for example, the learning rate is randomly fluctuated within ±3% of the current value. If the fitness value of the prey location does not improve (fluctuation ≤0.5%) for 10 consecutive iterations, 50% of the sailfish individuals are reinitialized (re-sampled within the local search range), triggering a new local exploration.
[0131] (4) After 40 rounds of local fine search in each potential high-quality area, the sailfish individual with the lowest fitness value (optimal performance) in the area is selected as the optimal parameter combination of the area. For all optimal parameter combinations of the areas, a final 300-round complete training and test set evaluation is performed, and the one with the optimal comprehensive performance (mean Average Precision (mAP), inference speed, loss convergence) is selected as the final tuning parameter of the YOLOv8 model, i.e., the target parameter. This ensures global coverage of the entire parameter space (avoiding missing high-quality areas) and high-precision mining of high-quality areas (improving the precision of parameter optimization), ultimately achieving performance improvement of the detection model.
[0132] The application realizes systematic local search and elite screening in the target parameter region through the determination process of the target parameter, utilizes the guiding role of the historical high-quality parameter group, and ensures the comprehensiveness and reliability of parameter optimization through iterative updating and comprehensive evaluation. The accuracy and efficiency of model parameter tuning are significantly improved, and the target detection model can quickly adapt to complex scene requirements, providing stronger underlying support for image detection tasks.
[0133] In an implementable manner of an embodiment of the application, in each round of training and verification of the initial detection model, when the iterative parameter groups are sampled from the preset parameter search space, the search radius is dynamically adjusted to improve the pertinence and effectiveness of parameter sampling in the global exploration stage. Specifically, the following methods can be used, but are not limited to: obtaining the scene type of the training image data, wherein the scene type is used to indicate the scene in which the training image data is collected; in response to the fitness values corresponding to the plurality of first model parameter groups meeting the preset fitness conditions corresponding to the scene type, the first search radius is dynamically expanded to sample a plurality of first iterative parameter groups based on the expanded search radius, wherein different scene types correspond to different preset fitness conditions, and the preset fitness conditions at least include the fitness value fluctuation degree and the average precision value.
[0134] In an embodiment of the application, the scene type is a label classified according to the characteristics of the image acquisition environment, such as an electronic workshop, a research and development laboratory, a strong light area, a weak light area, a high-density pipeline, or a low-density office, etc. It reflects the environmental attributes such as lighting conditions, personnel density, and background complexity of the data source, which directly affect the visual performance of the target object and the difficulty of model detection. Through the identification of the scene type, the distribution characteristics of the training data can be understood, and context information can be provided for parameter tuning.
[0135] The scene type is a classification label used to accurately describe the scene characteristics of the training image data, and its division basis needs to be set in combination with the scene differences of specific detection tasks. Common division dimensions include but are not limited to:
[0136] Lighting condition dimension: such as strong light scene (such as electronic workshop welding area, outdoor open work area), weak light scene (such as research and development laboratory dark room, workshop night work area), normal lighting scene (such as ordinary assembly workshop, office detection area);
[0137] Target density dimension: such as high-density scene (such as pipeline personnel-intensive workstations, warehouse area multi-person work scene), low-density scene (such as laboratory single-person operation area, equipment inspection single-person scene);
[0138] Background complexity dimension: such as high-complexity background scene (such as equipment-intensive area in the workshop, multi-material storage area), low-complexity background scene (such as clean laboratory, open detection area).
[0139] The preset fitness condition is a quantitative standard pre-set for different scene types for judging whether the performance of the current first model parameter group meets the scene requirement. The core role is to judge whether the sampling range defined by the current first search radius can cover the high-quality parameter region in the scene through the analysis of the fitness value. If the preset fitness condition is met, it means that the current sampling range cannot fully exploit the high-quality parameters adapted to the scene, and the search radius needs to be expanded. If it is not met, it means that the current range can already provide better parameters, and there is no need to adjust or reduce the search radius. The preset fitness condition includes at least two core indicators of the fitness value fluctuation degree and the average accuracy value, and different scene types correspond to different condition thresholds, because there are inherent differences in the performance of model parameters in different scenes, and a unified standard cannot be used to measure them.
[0140] The fitness value fluctuation degree refers to the dispersion degree between the fitness values of multiple first model parameter groups, which is usually measured by standard deviation or coefficient of variation. If the fluctuation degree is too large (such as: standard deviation > 0.1), it means that the performance of the parameter combinations in the current sampling range is significantly different, and there are some parameter groups with poor performance and some parameter groups with good performance, and the parameter groups with good performance may not cover all the high-quality parameter dimensions in the scene, so the search radius needs to be expanded to capture more potential high-quality parameters. For example, in the strong light scene, due to the complexity of image features, the parameter performance fluctuation is usually larger, so the fitness value fluctuation degree threshold corresponding to the strong light scene will be higher than that of the normal light scene (such as: strong light scene threshold set to 0.12, normal light set to 0.08), and it is more likely to trigger the operation of expanding the search radius.
[0141] The average accuracy value refers to the average value of the fitness corresponding to multiple first model parameter groups, which directly reflects the overall positioning accuracy of the parameter groups in the current sampling range. If the average accuracy value is lower than the preset threshold corresponding to the scene type, it means that the parameter combinations in the current sampling range cannot make the model reach the basic accuracy requirement in the scene, which may be because the search radius is too small and does not cover the key parameter dimensions that can improve the accuracy (such as: the number of convolution channels adapted to the strong light scene, the anchor frame size adapted to the dense scene), so the search radius needs to be expanded to find better parameters. For example, in the weak light scene, the image target features are not obvious, and the model positioning accuracy is more difficult to improve, so the average accuracy value threshold corresponding to the weak light scene will be lower than that of the normal light scene (such as: weak light scene threshold set to 0.7, normal light set to 0.75), and when the average accuracy value < 0.7, it triggers the expansion of the search radius.
[0142] The preset fitness condition can also be supplemented with other auxiliary indicators (such as: average recall rate, average loss value) according to the scene requirements, but all indicators need to be set differently for scene types to ensure the scene adaptability of the judgment standard. For example: in a high-density scene, the target overlap degree is high, and the recall rate (the integrity of capturing the target) is more important, so the preset fitness condition of the high-density scene will additionally include the average recall rate threshold (such as: set to 0.72), when the average recall rate < 0.72, even if the fitness value fluctuates and the average precision value meets the standard, the search radius needs to be expanded.
[0143] The expansion range of the first search radius needs to be set in combination with the scene type and the degree of deviation of the current fitness value from the condition, for example: the current first search radius is 20% of the parameter range, and after expansion, it is adjusted to 24%~30%; if the fitness value deviates from the condition seriously (such as: the average precision value is much lower than the threshold), the expansion range can be appropriately increased. The first search radius after expansion needs to be strictly controlled within the preset parameter search space range to avoid exceeding the overall parameter range and causing invalid sampling.
[0144] Specifically, regarding the dynamic adjustment of the search radius, the following methods can be used but are not limited to: taking scene grouping and performance indicators as dual trigger basis, first clustering the antistatic clothing detection dataset according to scenes (such as: strong light workshop, weak light laboratory, high-density pipeline, and low-density office 4 types of scenes), and then judging whether to adjust through the following results: when the fitness value fluctuation of multiple groups of flame individuals (parameter combinations) is >10%, the radius is increased; when the average precision mean of all flame individuals is less than 0.6 (not reaching the preset qualified line 0.7), the radius is increased; when the mAP of more than 80% of the flame individuals is concentrated in 0.75~0.85, the radius is reduced; the difference between the optimal flame mAP of different scenes is >0.15, then the radius of the low-performance scene needs to be increased accordingly. For each parameter to be optimized, the basic radius = (upper limit of parameter search range - lower limit) x 0.2, for example: the convolution kernel size search range [3, 5, 7], the basic radius = (7-3) x 0.2 = 0.8;
[0145] The dynamic adjustment formula is: , wherein, is the basic search radius, i.e. the first search radius, is the radius adjustment coefficient, is the current MFO global exploration round, Custom settings, for example: when the performance fluctuates greatly or the performance fitness value is low, the adjustment coefficient is 1.3-1.5, when the fitness value is optimal, the adjustment coefficient is 0.5-0.7, and when the cross-scene difference is large, the adjustment parameter is 1.2-1.4. The upper limit of the search radius is (parameter search range upper limit-lower limit) x 0.3, and the lower limit is (parameter search range upper limit-lower limit) x 0.1, mainly to avoid the decrease of efficiency caused by too large search range and retain the basic exploration ability, avoid early stagnation; the search radius adjustment and the decay of exploration factor synchronization (decay of exploration factor synchronization, the radius is reduced, avoiding dispersion in the later exploration).
[0146] Through the dynamic adjustment of the search radius, the application can optimize the parameter search strategy according to the scene type and real-time performance feedback, making the global exploration process more adaptive and scene-aware. It significantly improves the flexibility and efficiency of parameter tuning, especially in complex and variable industrial environments, it can quickly adapt to the detection needs of different scenes, providing reliable protection for the stable improvement of model performance.
[0147] In one implementation manner of the embodiment of the application, in each round of training and verification of the initial detection model, the search step is dynamically adjusted when sampling the iteration parameter group from the target parameter region, to improve the pertinence of local search and the adaptability of the final target parameter to high-frequency scenes. Specifically, the following methods can be used, but are not limited to: obtaining the target classification corresponding to each image in the training image data after training and verifying the initial detection model using the training image data and the verification image data for each second model parameter group, and the occurrence frequency of the image of the target classification in the training image data; in response to the occurrence frequency meeting the preset frequency condition, dynamically reducing the first search step, to sample multiple second iteration model parameter groups based on the reduced search step.
[0148] In the embodiment of the application, the target classification refers to the class label predicted by the model for each image in the training image data, for example: in the anti-static clothing detection scene, the categories can include compliance, zipper not pulled together, sleeve not tightened, clothing damage, etc., which reflects the semantic understanding and classification result of the model for the input sample. The occurrence frequency refers to the frequency of the target classification in the training image data, that is, the proportion of a specific category in the data set, which is calculated by counting the number of images of each category. The higher the frequency, the more common or important the category is in the training data.
[0149] The preset frequency condition refers to a threshold or rule preset about the occurrence frequency, which is used to determine whether to trigger the adjustment of the search step. For example, when the occurrence frequency of a certain target category exceeds a certain proportion (such as 25%), the condition is met, indicating that this category occupies a dominant position in the data set or belongs to a high-frequency key category, and more refined parameter optimization is needed to improve its detection accuracy. The first search step refers to the step size control parameter when sampling parameters in the target parameter region, which defines the fluctuation range of parameter values around the core parameter combination. The larger the step size, the coarser the sampling and the wider the exploration range. The smaller the step size, the more refined the sampling and the higher the exploration accuracy. Dynamically reducing the first search step refers to reducing the step size by a certain proportion according to the triggering of the preset frequency condition. For example, multiplying the original step size by a reduction factor less than 1, so that subsequent sampling is performed in a smaller neighborhood, enhancing the fine-tuning ability of parameters related to high-frequency categories.
[0150] The setting of the preset frequency condition needs to be combined with the actual needs of the detection scene and the distribution characteristics of the target category. For example, in the compliance detection scene of anti-static clothing, if historical data shows that the proportion of high-frequency violation types is usually ≥25%, the preset frequency condition can be set as the occurrence frequency of the target category ≥25%. In the industrial product detection scene, if the occurrence frequency of qualified products is usually ≥60%, and the proportion of high-frequency defects in defective products is ≥15%, the preset frequency condition can be set differently for different target categories (such as qualified product frequency ≥60%, high-frequency defect frequency ≥15%). The essence of the preset frequency condition is to distinguish between target categories that need to be optimized and non-key target categories. High-frequency target categories that meet the condition are the most common and most need to be protected in the detection scene. Detection accuracy needs to be improved through more refined parameter search; low-frequency target categories that do not meet the condition have less impact on overall detection effect and do not need to be adjusted in step size.
[0151] Specifically, regarding the dynamic adjustment of the search step, the following methods can be used but are not limited to: Through training data, the frequency of violation types is counted (such as sleeve not tightened 35%, not wearing anti-static clothing 28%, not wearing a hat 20%), and the proportion ≥25% is defined as a high-frequency violation type. When the recall rate of high-frequency violation types is less than 0.75, the step size is reduced; when the average intersection over union of high-frequency violation types is less than 0.6, the step size is reduced; when the recall rate of high-frequency violation types is ≥0.85 and the intersection over union is ≥0.75, the step size is increased; for each parameter to be optimized, the basic step size = basic search radius x 0.5, and the dynamic optimization formula is:
[0152]
[0153] Wherein, is the basic search step size, is the violation performance coefficient, To iterate the attenuation coefficient.
[0154] With SFO rounds of attenuation, the attenuation formula is: ,
[0155] Wherein, is the current iteration number of local search.
[0156] Custom settings, for example: when the high-frequency violation recall rate is low, the violation performance coefficient is 0.4, when the high-frequency violation performance meets the standard, take 1.0-1.2. For high-frequency violation types, step adjustment only acts on parameters related to this violation feature (such as not tightening the sleeve depends on fine-grained features, focusing on adjusting the step of small convolution kernel size, shallow convolution channel number; not wearing anti-static clothing depends on global features, focusing on adjusting the step of pooling strategy, deep channel number).
[0157] Through the dynamic adjustment of search step, the application can adaptively adjust the fineness of local search according to the distribution characteristics of categories in the training data, so that the parameter tuning is more focused on high-frequency or key categories, and the feature learning ability and detection stability of the model for these categories are improved. Suitable for scenarios where the category distribution is uneven or a specific category has high priority, the efficiency and effectiveness of parameter search are optimized through dynamic step control, which further guarantees the reliable performance of the model in complex environments.
[0158] It should be further pointed out that the parameter tuning process of the hybrid model is the same as that of the target detection model, only the parameters are different, that is, based on the first algorithm and the plurality of first hybrid model parameter groups, the initial hybrid model is trained and verified by the training image data and the verification image data, and the target hybrid parameter region is determined from the plurality of first hybrid model parameter groups, wherein the plurality of hybrid model parameter groups are parameters sampled from the second preset parameter search space in the training and verification process of the initial hybrid model, and the second preset parameter search space is a parameter set containing a plurality of model parameters; a plurality of second hybrid model parameter groups are selected in the target hybrid parameter region, based on the second algorithm and the plurality of second hybrid model parameter groups, the initial hybrid model is trained and verified by the training image data and the verification image data, and the target hybrid parameter is determined from the plurality of second hybrid model parameter groups; the initial hybrid model is parameter optimized based on the target hybrid parameter, and the hybrid model is obtained.
[0159] Specifically, the determination of the target hybrid parameter region and the target hybrid parameter can refer to the determination of the target parameter region and the target parameter described above, so it will not be repeated here.
[0160] Further, regarding the parameter adjustment of the hybrid model, the following methods can also be used, but are not limited to: feature extraction parameter adjustment of the hybrid model. The core is to optimize the structure parameters and training parameters of each sub-model to ensure that the features of different sub-models are complementary (ResNet50 extracts global features, MobileNetV2 extracts lightweight features, and ShuffleNet extracts channel attention features), and adapt to the scene differences and violation types of the anti-static clothing detection. Encode the parameters into a 16-dimensional vector of the flame individual (ResNet50 parameters 2-dimensional + MobileNetV2 parameters 2-dimensional + ShuffleNet parameters 2-dimensional + fusion weight 3-dimensional + training parameters 7-dimensional), randomly generate 30 flame individuals (parameters are sampled within the search range), and the parameter adjustment process is similar to the YOLOv8 parameter adjustment process. Global exploration stage: for each flame individual, quickly train the hybrid model (30 rounds of pre-training), and calculate the comprehensive mAP (weighted according to the scene data volume) using the validation set of each scene; according to the search radius adjustment rule described above, increase the search radius for low-performance scenes (for example, increase the search radius of the MobileNetV2 convolution kernel size and the ShuffleNet grouping number in the weak light scene); cluster and select 3 potential high-quality parameter regions (for example, the combination region of ResNet50 channel number [512, 1024], MobileNetV2 expansion coefficient [1.2, 1.4], and ShuffleNet group number [16, 32]);
[0161] Local fine search stage: for high-frequency violation types (such as sleeve not tightened), reduce the search step of related parameters (such as MobileNetV2 3x3 convolution kernel size, ShuffleNet 16-group grouping convolution step); initialize 20 marlin individuals (including elite individuals containing MFO optimal parameters) for each potential high-quality region, and train the model completely (300 rounds, cosine annealing learning rate); iteratively update the marlin position (fine-tune the feature fusion weight, convolution channel number, etc. with small step); evaluate the recall rate of high-frequency violation types every 10 rounds, if there is no improvement for 5 consecutive rounds, trigger random disturbance: increase or decrease the fusion weight by 0.05 for fine-tuning. For the optimal parameter combination of each region, evaluate the overall performance (mAP, high-frequency violation recall rate, inference speed) of the test set; select the parameter combination with comprehensive mAP≥0.8, high-frequency violation recall rate≥0.85, and inference speed≥30 frames as the final adjustment result.
[0162] In an implementation manner of the embodiment of the present application, after the mixed model and the target detection model are obtained through parameter tuning, the parameter-tuned model needs to be subjected to lightweight processing and layer pruning to ensure that the model can adapt to edge devices with limited hardware resources, and the optimized model is deployed to realize local real-time detection. Specifically, the following methods can be used, but are not limited to: after the mixed model and the target detection model are obtained through parameter tuning, the mixed model and the target detection model are subjected to lightweight processing and layer pruning; the mixed model and the target detection model subjected to lightweight processing and layer pruning are deployed; in response to the detection result continuously failing to meet the preset reliability condition for the to-be-detected image, the detection result is transmitted to the cloud, and the detection strategy is adjusted based on the feedback data of the cloud.
[0163] In the embodiment of the present application, lightweight processing refers to reducing the computational complexity and storage requirements of the model through a series of technical means, so that it is more suitable for running on devices with limited resources. Lightweight techniques include but are not limited to model quantization, weight pruning, and knowledge distillation. Model quantization refers to converting floating-point parameters in the model to low-precision representations, thereby reducing memory occupancy and accelerating the inference process while maintaining model accuracy as much as possible. Layer pruning refers to removing redundant or less contributing layers or channels in the neural network. By analyzing the importance of the layers or output activation values, the parts that have little impact on the overall performance are deleted, thereby simplifying the model structure and improving the inference speed. The common goal of lightweight processing and layer pruning is to reduce the demand of the model on computing resources and storage space while maintaining the detection performance of the model, so that it can efficiently run in limited environments such as edge devices, while ensuring the real-time performance and response efficiency of the detection process.
[0164] Deployment refers to the process of integrating the optimized model into the target hardware platform and putting it into actual use. Deployment includes model conversion, environment configuration, interface development, and performance tuning. After the lightweight model is deployed, real-time image detection can be realized on the local device, reducing the dependence on network connection and reducing response delay, thereby meeting the strict requirements on timeliness in industrial detection. The deployment process also needs to consider the device computing power and storage limitations, and through adaptability testing, it ensures stable operation of the model and provides a basic framework for subsequent dynamic optimization.
[0165] The detection result refers to the classification or positioning information output by the model after analyzing the input image, which reflects the state or category of the target object, for example: in the detection of anti-static clothing, the result may include compliance, violation or other fine categories. The preset reliability condition refers to the standard for evaluating the reliability of the detection result, which is based on the consistency, confidence or scene adaptability of the model output, for example: when the confidence of consecutive multiple frames of detection results is lower than the threshold or appears abnormal fluctuation, it is considered that the reliability condition is not met; in the same scene, consecutive multiple frames of detection results do not conform to the true situation, and consecutive N frames of missed detection, wrong classification, repeated labeling error are considered as not meeting the reliability condition; the confidence determines the certainty of the model output, when the confidence is continuously substandard, it means that the model is not adapted to the current scene (the confidence in consecutive N frames is less than the threshold 0.6 or the standard deviation of consecutive frame confidence is greater than 0.2, which is considered as not meeting the reliability condition); after the picture environment parameter (obtained by the edge device camera) mutates, the detection accuracy of consecutive 3 frames decreases by more than 30%, which is considered as not meeting the reliability condition.
[0166] The cloud refers to a remote server or a cloud computing platform with powerful computing and storage capabilities, which can handle complex tasks and large amounts of data. The feedback data refers to the optimization suggestions or correction information generated by the cloud after analyzing the uploaded detection results, for example: by retraining the model or adjusting the parameters to improve the detection performance. Adjusting the detection strategy refers to dynamically modifying the local detection model or process according to the feedback from the cloud, for example: updating the model parameters, changing the preprocessing method or adjusting the confidence threshold to improve the accuracy and stability of subsequent detection.
[0167] The present application combines the efficient operation of the model on the edge device with the dynamic optimization supported by the cloud, which not only guarantees the real-time performance of the detection, but also continuously improves the system performance through the cloud feedback mechanism. It is suitable for industrial scenes with variable environment or evolving needs, ensuring the reliability and adaptability of the detection system in long-term operation, and optimizing resource utilization through lightweight processing and layer pruning, providing a feasible basis for large-scale deployment.
[0168] In one implementation manner of the embodiment of the present application, when collecting image data, the following methods can also be used, but are not limited to: collecting real-time image data, and pre-processing the real-time image data after being disassembled into single-frame images to obtain the to-be-detected image, wherein the pre-processing at least includes image denoising, size standardization and pixel value normalization.
[0169] In the embodiments of the present application, real-time image data refers to a dynamic video stream continuously captured by an Internet of Things device (such as a high-definition intelligent camera or an edge sensor), which is updated at a millisecond level and can reflect the real-time state of the detection scene, for example: a continuous picture of an antistatic suit worn in an electronic workshop or a research and development laboratory. This data relies on the low-latency transmission capability of the edge computing server to ensure the timeliness and continuity of image acquisition, providing the original input source for the detection process. The real-time image data is decomposed into single frames, which means that the video stream is decomposed into independent static image frames through frame extraction technology. This converts the continuous pictures in time series into discrete image units, facilitating subsequent frame-by-frame analysis and processing. This step ensures that the detection system can perform fine detection on each instantaneous state and avoid information loss in dynamic scenes.
[0170] Image denoising refers to reducing noise and artifacts in images through filtering algorithms to improve picture clarity and quality. Common methods include Gaussian filtering and median filtering, which calculate the average or median value of the pixel neighborhood through convolution kernels, effectively suppressing random noise and environmental interference while preserving image edges and key details, ensuring that subsequent models can focus on effective features rather than noise signals. Size normalization refers to the process of uniformly adjusting images to a preset resolution, for example: scaling all input images to 640x640 pixels. This is achieved through interpolation algorithms (such as bilinear interpolation) to maintain image proportions or perform padding processing, ensuring that all input samples have the same spatial dimensions, adapting to the fixed input requirements of deep learning models, and avoiding fluctuations in model performance or calculation errors caused by size differences. Pixel value normalization refers to the operation of linearly scaling image pixel values from the original range (such as 0-255) to the [0,1] interval. This is achieved by dividing by the maximum pixel value to unify data distribution, reducing pixel value fluctuations caused by different lighting conditions or device differences, making input data more consistent with deep learning model training and inference specifications, and improving model convergence speed and generalization ability.
[0171] The present application converts raw real-time image data into high-quality, standardized images to be detected through image preprocessing, effectively eliminating environmental factors and device differences that interfere with the detection process. This improves the reliability and consistency of input data, providing an optimized input basis for subsequent target detection models and hybrid models, enhancing the robustness and detection accuracy of the system in complex industrial scenarios. In addition, the preprocessing operation is computationally efficient, adapting to the resource constraints of edge devices, ensuring the real-time and sustainability of the detection process.
[0172] Further, regarding the image detection method of the present application, an example application scenario of the image detection method is also provided for illustration: the image detection method of the present application can be specifically applied to the compliance detection scene of anti-static clothing. The following will be described in detail in combination with an embodiment. In this embodiment, by combining the Internet of Things device with the adaptive deep learning framework, real-time and accurate detection of the wearing state of anti-static clothing in an electronic workshop or a research and development laboratory is realized, thereby improving the reliability of static protection and production efficiency.
[0173] As Figure 2 shown, Figure 2 the application architecture schematic diagram of the image detection method provided in the embodiment of the present application, which comprises:
[0174] Step 1: Obtain real-time video stream data from the Internet of Things device (such as a high-definition intelligent camera, an edge sensor) deployed in an electronic workshop, a research and development laboratory and the like, and rely on the low-delay transmission capability (guaranteeing millisecond-level data response) of the edge computing server to disassemble the video stream into single-frame images and perform preprocessing operations.
[0175] Step 2: Optimize and deploy the YOLOv8 human body detection model based on the marlin-flame optimization algorithm, and use the marlin-flame hybrid optimization algorithm to perform targeted optimization on the core parameters of the target detection model YOLOv8.
[0176] Step 3: Parameter collaborative optimization of the hybrid deep learning model, continuing the marlin-flame optimization algorithm, and performing collaborative optimization on the parameters of the hybrid deep learning model composed of ResNet50, MobileNetV2 and ShuffleNet, and adapting to the characteristics of the anti-static clothing detection scene.
[0177] Step 4: Model fusion and compliance detection based on dynamic weights and attention mechanisms, input the human body region image marked by YOLOv8 into the hybrid deep learning model, and realize anti-static clothing compliance detection through an adaptive fusion strategy.
[0178] Step 5: Edge device model deployment and real-time detection.
[0179] Further, the Internet of Things system in step 1 can process a large amount of data and transmit data with extremely low delay, ensuring the real-time of detection. The video stream from these cameras is decomposed into individual frames and then passed as input to the detection system. Image noise and artifacts are removed by Gaussian filtering, median filtering and other algorithms to improve picture clarity; the image is uniformly adjusted to a preset size of 640x640 pixels to adapt to the subsequent model input requirements, and the pixel value is normalized to the [0,1] interval to reduce the interference of data distribution differences on deep learning model training and inference. This step can greatly improve the performance of deep learning models that rely on these inputs for algorithm operation; use the annotation tool to label the preprocessed images, mark the human body bounding box and the label of anti-static clothing compliance and violation, and provide a labeled dataset for subsequent model training.
[0180] Regarding steps 2 and 3, the application provides a parameter tuning process diagram as shown in Figure 3 Further, in step 2, the pixels in the input image are detected to find the person and place a bounding box when the person is found. The quality of the target detection result will affect the accuracy of the subsequent classification, so the present scheme proposes a hybrid parameter optimization method, the Sailfish-Flame Optimization Algorithm. This parameter optimization algorithm is a new algorithm for optimizing global metaheuristic, which combines the best features of Flame Optimization (MFO) and Sailfish Optimization Method (SFO). This parameter optimization logic balances global search and local convergence ability through two stages of flame optimization global exploration to find potential high-quality parameter regions and sailfish optimization local fine search to mine better parameters in the existing high-quality area, which can effectively optimize the parameters of the deep learning model (anchor box size, convolution layer number, channel number, etc.) and improve the judgment accuracy of the model for target detection. Use the labeled human detection dataset, set the number of iterations to 300 rounds, the loss function is CIoU Loss function, and the learning rate strategy uses cosine annealing learning rate. Train the YOLOv8 model after parameter tuning. Evaluate the human detection performance of the trained YOLOv8 model using the test set. If the performance is not up to standard, adjust the parameters and training strategy of the Sailfish-Flame Optimization Algorithm and perform iterative training.
[0181] The potential high-quality parameter region refers to a subspace in the parameter search space of the YOLOv8 model that contains parameter combinations that can make the model have high detection accuracy and low loss. The parameter combinations in this region can make the model's performance (such as loss function and model evaluation indicators) on the training set / validation set significantly better than random parameters, and the performance of the parameters in the region fluctuates less, and the model parameters are robust. That is, the high-quality parameter region is a small part of the parameter space that can make the model perform better than the global random parameters. Compared with the global random parameters, any parameter in this region can make the model perform better, and the performance of the parameters in the region fluctuates less (there is no situation that some parameters in the same region are excellent and some are poor). For the YOLOv8 human body detection task, the high-quality region is suitable for the characteristics of the human body target, such as: the anchor box size will be concentrated near the aspect ratio of the human body (about 1:2), and the convolution channel number will be concentrated in the dimension interval that can effectively extract the human body contour and posture features, rather than covering all parameter ranges indiscriminately. The parameter search space mainly includes structure parameters and training parameters: the number of convolution layers, the number of convolution channels (32-64-128-256), anchor box size, initial learning rate, weight decay coefficient, penalty coefficient of loss function, batch size (the number of samples that the model reads and processes at a time during each iteration of training). The potential high-quality parameter region is not a single point parameter, but a continuous / discrete subspace with better performance in the search space (for example: the combination of convolution channel number in the [64, 128, 256] interval and initial learning rate in the [5e-4, 1e-3] interval).
[0182] Further, in the anti-static clothing detection scene in step 3, the light, personnel density and other environmental differences of different workshops and laboratories are large. In the global exploration stage, the search range of the flame optimization can be dynamically adjusted according to the historical data of different scenes; in the local optimization stage, the local search step of the sailfish optimization is optimized for frequently occurring violations (such as not tightening the cuffs), to improve the detection ability of specific violations; the number of convolution layers, the number of channels, the size of the convolution kernel, the pooling strategy and parameters, and the learning rate of the feature extraction model are adjusted. Using the labeled anti-static clothing compliance and violation data set, the same training strategy is used to train the mixed deep learning model after parameter tuning.
[0183] The search radius of the flame optimization is essentially the local range size of the parameter search space. The larger the search radius, the wider the random walk range of the parameters of a single flame individual (the stronger the global exploration ability). The smaller the search radius, the more focused the search on the current high-quality area (the stronger the local convergence ability). The adjustment basis is the performance feedback of historical data in different scenarios, and the core goal is to adapt to the environmental differences (light, personnel density) of the anti-static clothing detection. The search step of the marlin optimization is the step size of the parameter iterative update in the potential high-quality parameter area. The larger the step, the faster the local exploration speed. The smaller the step, the more accurate the parameter fine-tuning. The optimization goal is to improve the detection ability of high-frequency violation types (such as sleeve not tightened).
[0184] Regarding step 4, the application embodiment provides a flowchart of feature fusion, as shown in Figure 4 Further, in step 4, based on the trained single models, model fusion strategy is used for fusion. A model fusion strategy based on dynamic weight and attention mechanism is introduced, and multiple models are used for feature extraction. ResNet50 extracts deep features such as anti-static clothing texture and damage, MobileNetV2 quickly extracts basic features such as clothing style and color, and ShuffleNet strengthens the feature interaction of key parts such as sleeves and zippers. Attention and confidence calculation is performed, the three model feature vectors are spliced and input into the attention network to generate the attention weight of each model (reflecting the importance of the feature under the current sample); at the same time, the output confidence of each model is calculated through Dropout multiple forward propagation (measuring the classification degree of grasp).
[0185] In the model fusion based on dynamic weight and attention mechanism, the core goal of confidence calculation is to quantify the classification grasp degree of a single model on the current input sample (the human anti-static clothing region image after YOLOv8 cropping). The higher the confidence, the stronger the certainty of the model on its output category, and the higher the weight should be given in subsequent fusion; otherwise, the certainty is weak, and the weight needs to be reduced.
[0186] In step 5, according to the computing power of the edge device, a suitable model quantization and cropping method is selected to make the trained model run efficiently on the edge device while ensuring detection accuracy and efficiency. Edge device exception handling: when the edge device detection has abnormal results (such as continuous multiple frame detection errors), the data is returned to the cloud for review, and the detection strategy of the edge device is adjusted according to the cloud feedback.
[0187] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be realized by means of software and necessary general hardware platform, of course, it can also be realized by hardware, but in many cases the former is a better embodiment.
[0188] The embodiment of the present application also provides an image detection device, Figure 5 A structural schematic diagram of an image detection device provided by the present application is shown in the figure, Figure 5 As shown in the figure, it comprises:
[0189] A positioning unit 51 is configured to perform positioning processing on the to-be-detected image by a target detection model, and determine a target object region in the to-be-detected image;
[0190] An extraction unit 52 is configured to perform feature extraction on the target object region by a hybrid model comprising a plurality of feature extraction models, and obtain feature vectors respectively output by the plurality of feature extraction models, wherein the hybrid model and the target detection model are obtained by parameter tuning, and the parameter tuning at least comprises positioning a target parameter region by a first algorithm for global exploration, and determining an optimal target parameter by a second algorithm for local fine search in the target parameter region;
[0191] A fusion unit 53 is configured to weight and fuse the plurality of feature vectors according to respective corresponding attention weights and confidences, and generate a fusion feature vector, wherein the attention weights are obtained by inputting the plurality of feature vectors into a preset attention network, and the confidences are obtained by a plurality of rounds of loss forward propagation performed by the plurality of feature extraction models respectively;
[0192] A determination unit 54 is configured to determine a detection result of the to-be-detected image according to the fusion feature vector by the hybrid model.
[0193] In an embodiment of the present application, the fusion unit 53 is further configured to:
[0194] Perform a plurality of rounds of loss forward propagation on the plurality of feature extraction models independently based on the target object region, and obtain a plurality of groups of class probabilities respectively corresponding to the plurality of feature extraction models, wherein the class probability is a probability of a class to which the target object region belongs;
[0195] Determine a target class probability respectively corresponding to each of the plurality of feature extraction models as a class probability with the highest occurrence frequency in the plurality of groups of class probabilities respectively corresponding to the plurality of feature extraction models;
[0196] Calculate an average value and a standard deviation respectively corresponding to the plurality of target class probabilities according to respective occurrence frequencies of the plurality of target class probabilities, and perform normalization calculation based on the average value and the standard deviation to obtain a confidence respectively corresponding to each of the plurality of feature extraction models.
[0197] In an embodiment of the present application, the fusion unit 53 is further configured to:
[0198] Perform dimension alignment processing on the plurality of feature vectors, and then splice the plurality of processed feature vectors along a feature channel direction to obtain a joint feature vector;
[0199] The joint feature vector is input into a preset attention network, spatial dimension compression is performed through global average pooling, and a compressed feature vector is obtained, wherein a feature channel dimension of the compressed feature vector is the same as that of the joint feature vector;
[0200] After the compressed feature vector is processed by the first full connection layer in the preset attention network, the first feature vector is obtained through activation processing by the first activation function, and after the first feature vector is processed by the second full connection layer in the preset attention network, the channel score corresponding to each feature channel of the plurality of feature channels is obtained through activation processing by the second activation function.
[0201] The attention weight corresponding to each feature extraction model is calculated according to the channel score.
[0202] In an embodiment of the present application, the fusion unit 53 is further configured to:
[0203] The plurality of channel scores are grouped according to the feature channel corresponding to each feature extraction model, and the grouped channel score corresponding to each feature extraction model is obtained.
[0204] The attention weight corresponding to each feature extraction model is obtained by averaging all channel scores in each grouped channel score.
[0205] In an embodiment of the present application, the fusion unit 53 is specifically configured to:
[0206] The plurality of feature vectors are respectively multiplied by the attention weight corresponding to each feature vector, and the weighted feature vector corresponding to each feature vector is obtained.
[0207] The target weight corresponding to each feature vector is obtained by multiplying the preset initial weight corresponding to each feature vector, the attention weight and the confidence, wherein the preset initial weight is determined based on the average accuracy of each feature extraction model in historical data processing.
[0208] The weighted fusion processing is performed on the plurality of weighted feature vectors according to the target weight corresponding to each weighted feature vector, and the fusion feature vector is obtained.
[0209] In an embodiment of the present application, as shown in Figure 6 The image detection device further comprises an optimization unit 55, and the optimization unit 55 is configured to:
[0210] The initial detection model is trained and verified based on the first algorithm and the plurality of first model parameter groups by using the training image data and the verification image data, and a target parameter region is determined from the plurality of first model parameter groups, wherein the plurality of first model parameter groups are parameters sampled from a preset parameter search space during the training and verification of the initial detection model, and the preset parameter search space is a parameter set containing a plurality of model parameters;
[0211] A plurality of second model parameter groups are selected in the target parameter region, and the initial detection model is trained and verified based on the second algorithm and the plurality of second model parameter groups by using the training image data and the verification image data, and a target parameter is determined from the plurality of second model parameter groups;
[0212] The initial detection model is parameter-optimized based on the target parameter to obtain a target detection model.
[0213] In an embodiment of the present application, the optimization unit 55 is specifically configured to:
[0214] A plurality of first model parameter groups are randomly sampled from a preset parameter search space based on a first search radius;
[0215] The initial detection model is trained and verified by using the training image data and the verification image data for each first model parameter group, a plurality of performance indicators corresponding to the plurality of first model parameter groups are obtained, and the plurality of performance indicators are respectively converted into fitness values;
[0216] A plurality of first iteration parameter groups are resampled from the preset parameter search space by combining a centering manner and a random sampling manner, and the initial detection model is trained and verified based on each first iteration parameter group;
[0217] The training and verification of the initial detection model are repeated until a first preset iteration number is reached, and a plurality of target first model parameter groups are obtained, wherein the target first model parameter groups are parameter groups with a fitness value lower than a preset fitness threshold in each round of training and verification of the initial detection model;
[0218] The plurality of target first model parameter groups are subjected to clustering analysis to obtain a target parameter region.
[0219] In an embodiment of the present application, the optimization unit 55 is specifically configured to:
[0220] A plurality of second model parameter groups are randomly sampled based on a first search step length, with a plurality of core parameter combinations of each parameter classification in the target parameter region as the center;
[0221] The target parameter region includes a plurality of parameter categories, each parameter category includes a plurality of target first model parameter groups, and the core parameter combination is a target first model parameter group with a minimum preset number of fitness values in the parameter category.
[0222] In an embodiment of the present application, the optimization unit 55 is specifically configured to:
[0223] For each second model parameter group, the initial detection model is trained and verified by using the training image data and the verification image data, and a plurality of second model parameter groups each correspond to a fitness value;
[0224] The target first model parameter group or the second model parameter group with a minimum preset number of fitness values is determined as a plurality of updated core parameter combinations, and a plurality of second iteration model parameter groups are sampled in the target parameter region based on the updated core parameter combinations;
[0225] The initial detection model is trained and verified based on each second iteration parameter group until a second preset iteration number is reached, and a plurality of candidate model parameter groups are obtained, wherein the candidate model parameter group is a parameter group with the lowest fitness value in each round of training and verification of the initial detection model;
[0226] The plurality of candidate model parameter groups are respectively subjected to complete training and comprehensive performance evaluation, an evaluation index value is obtained, and the candidate model parameter group with the highest evaluation index value is taken as the target parameter.
[0227] In an embodiment of the present application, the optimization unit 55 is specifically configured to:
[0228] The scene type of the training image data is obtained, wherein the scene type is used to indicate the scene in which the training image data is collected;
[0229] In response to the fitness values corresponding to the plurality of first model parameter groups meeting preset fitness conditions corresponding to the scene types, the first search radius is dynamically expanded, and a plurality of first iteration parameter groups are sampled based on the expanded search radius, wherein different scene types correspond to different preset fitness conditions, and the preset fitness conditions at least include the fitness value fluctuation degree and the average precision value.
[0230] In an embodiment of the present application, the optimization unit 55 is specifically configured to:
[0231] The target category corresponding to each image in the training image data and the occurrence frequency of the image of the target category in the training image data are obtained after the initial detection model is trained and verified by using the training image data and the verification image data for each second model parameter group;
[0232] In response to the occurrence frequency meeting the preset frequency condition, the first search step is dynamically reduced, and a plurality of second iteration model parameter groups are sampled based on the reduced search step.
[0233] In an embodiment of the present application, as shown in Figure 6 The image detection device further includes a deployment unit 56, configured to:
[0234] After the hybrid model and the target detection model are obtained through parameter tuning, the hybrid model and the target detection model are subjected to lightweight processing and layer pruning.
[0235] The hybrid model and the target detection model subjected to the lightweight processing and layer pruning are deployed.
[0236] In response to the detection result continuously failing to meet the preset reliability condition for the to-be-detected image, the detection result is transmitted to the cloud, and the detection strategy is adjusted based on feedback data of the cloud.
[0237] In an embodiment of the present application, as shown in Figure 6 The image detection device further includes a collection unit 57, configured to:
[0238] The real-time image data is collected, preprocessed after being disassembled into single-frame images, and to-be-detected images are obtained, wherein the preprocessing at least includes image denoising, size standardization, and pixel value normalization.
[0239] The features of the embodiments of the image detection device can be referred to the related descriptions of the embodiments of the image detection method, which will not be repeated here.
[0240] Embodiments of the present application further provide an electronic device, including a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any of the above image detection method embodiments.
[0241] Embodiments of the present application further provide a computer readable storage medium, which stores a computer program, wherein the computer program is configured to execute the steps in any of the above image detection method embodiments when running.
[0242] In an exemplary embodiment, the above computer readable storage medium can include, but is not limited to, a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store computer programs.
[0243] The embodiment of the present application further provides a computer program product, the computer program product comprising a computer program, the computer program being executed by a processor to implement the steps in any of the image detection method embodiments.
[0244] The embodiment of the present application further provides another computer program product, comprising a non-volatile computer readable storage medium, the non-volatile computer readable storage medium storing a computer program, the computer program being executed by a processor to implement the steps in any of the image detection method embodiments.
[0245] Those skilled in the art can further understand that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be realized in electronic hardware, computer software or a combination of both. In order to clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been described in the above description in general terms. Whether the functions are performed 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 implementation should not be considered beyond the scope of the present application.
[0246] The above provides a detailed description of the image detection method, electronic device and storage medium provided by the present application. The principles and implementation modes of the present application are described by applying specific examples. The above description of the examples is only to help understand the method of the present application and its core idea. It should be pointed out that for those skilled in the art, without departing from the principles of the present application, some improvements and modifications can be made to the present application, and these improvements and modifications also fall within the protection scope of the claims of the present application.
Claims
1. An image detection method, characterized in that, include: The target object region in the image to be detected is determined by locating the image using a target detection model. Feature extraction is performed on the target object region using a hybrid model comprising multiple feature extraction models, resulting in feature vectors output by each of the multiple feature extraction models. The hybrid model and the target detection model are obtained through parameter tuning, which includes at least the following: global exploration to locate the target parameter region using a first algorithm, and local fine-grained search within the target parameter region using a second algorithm to determine the model's target parameters. Multiple loss-of-premise forward propagations are performed independently on each of the multiple feature extraction models for the target object region to obtain a confidence level reflecting the certainty of each feature extraction model's classification result for the current target object region. Multiple feature vectors are weighted and fused according to their respective attention weights and confidence scores to generate a fused feature vector. The attention weights are obtained by inputting the multiple feature vectors into a preset attention network, and the confidence scores are obtained by performing multiple rounds of lossy forward propagation on each of the multiple feature extraction models. The detection result of the image to be detected is determined by the fusion model based on the fused feature vector; Before weighting and fusing the multiple feature vectors according to their respective attention weights and confidence levels to generate a fused feature vector, the method further includes: Based on the target object region, the multiple feature extraction models are independently subjected to multiple loss forward propagation to obtain multiple sets of category probabilities corresponding to each of the multiple feature extraction models. The category probability is the probability of the category to which the target object region belongs. The probability of the class with the highest frequency among the multiple sets of class probabilities corresponding to each of the multiple feature extraction models is determined as the target class probability corresponding to each of the multiple feature extraction models. Based on the occurrence frequency corresponding to each of the multiple target category probabilities, the average value and standard deviation of each of the multiple target category probabilities are calculated. Normalization is then performed based on the average value and the standard deviation to obtain the confidence level corresponding to each of the multiple feature extraction models.
2. The image detection method according to claim 1, characterized in that, Before weighting and fusing the multiple feature vectors according to their respective attention weights and confidence scores to generate a fused feature vector, the method further includes: After performing dimension alignment on the multiple feature vectors, the processed multiple feature vectors are concatenated along the feature channel direction to obtain a joint feature vector. The joint feature vector is input into the preset attention network, and the spatial dimension is compressed by global average pooling to obtain a compressed feature vector, wherein the feature channel dimension of the compressed feature vector is the same as that of the joint feature vector. The compressed feature vector is dimensionality reduced by passing it through the first fully connected layer in the preset attention network, and then activated by the first activation function to obtain the first feature vector. The first feature vector is then dimensionality restored by passing it through the second fully connected layer in the preset attention network, and then activated by the second activation function to obtain the channel scores corresponding to each of the multiple feature channels. The attention weights corresponding to each of the multiple feature extraction models are calculated based on the channel scores.
3. The image detection method according to claim 2, characterized in that, The step of calculating the attention weights corresponding to the multiple feature extraction models based on the channel scores includes: The scores of the multiple channels are grouped according to the feature channels corresponding to each of the multiple feature extraction models to obtain the grouped channel scores corresponding to each of the multiple feature extraction models. The attention weights corresponding to each of the multiple feature extraction models are obtained by averaging the scores of all channels within each group channel score.
4. The image detection method according to claim 1, characterized in that, The step of weighting and fusing multiple feature vectors according to their respective attention weights and confidence levels to generate a fused feature vector includes: The multiple feature vectors are multiplied by their respective attention weights to obtain the weighted feature vectors corresponding to the multiple feature vectors. The preset initial weights corresponding to each of the multiple feature vectors are multiplied by the corresponding attention weights and the confidence scores to obtain the target weights corresponding to each of the multiple feature vectors. The preset initial weights are determined based on the average accuracy of each of the multiple feature extraction models in historical data processing. The multiple weighted feature vectors are weighted and fused according to their respective target weights to obtain the fused feature vector.
5. The image detection method according to claim 1, characterized in that, Before locating the target object region in the image to be detected using a target detection model, the method further includes: Based on the first algorithm and multiple first model parameter sets, the initial detection model is trained and validated using training image data and validation image data. The target parameter region is determined from the multiple first model parameter sets. The multiple first model parameter sets are parameters sampled from a preset parameter search space during the training and validation process of the initial detection model. The preset parameter search space is a parameter set containing multiple model parameters. Multiple second model parameter groups are selected in the target parameter region. Based on the second algorithm and the multiple second model parameter groups, the initial detection model is trained and validated using the training image data and the validation image data to determine the target parameters from the multiple second model parameter groups. The initial detection model is optimized based on the target parameters to obtain the target detection model.
6. The image detection method according to claim 5, characterized in that, The step of determining the target parameter region from the plurality of first model parameter groups, based on the first algorithm and multiple first model parameter groups, involves training and validating the initial detection model using training image data and validation image data, and then determining the target parameter region from the plurality of first model parameter groups. Randomly sample the multiple first model parameter groups from the preset parameter search space based on a first search radius; For each first model parameter group, the initial detection model is trained and validated using training image data and validation image data to obtain the performance index corresponding to each of the multiple first model parameter groups, and the multiple performance indexes are converted into fitness values respectively. By combining a method centered on the first model parameter group with the lowest fitness value with a random sampling method, multiple first iteration parameter groups are sampled again from the preset parameter search space, and the initial detection model is trained and validated based on each first iteration parameter group; The initial detection model is repeatedly trained and validated until the first preset number of iterations is reached, resulting in multiple target first model parameter sets. The target first model parameter sets are the parameter sets whose fitness values are lower than a preset fitness threshold in each round of training and validation of the initial detection model. Cluster analysis is performed on multiple target first model parameter groups to obtain the target parameter region.
7. The image detection method according to claim 6, characterized in that, Selecting multiple second model parameter groups in the target parameter region includes: Within the target parameter region, taking multiple core parameter combinations for each parameter category within the target parameter region as the center, the multiple second model parameter groups are randomly sampled based on the first search step size; The target parameter region includes multiple parameter categories, each parameter category includes multiple target first model parameter groups, and the core parameter group is the target first model parameter group with the smallest fitness value among the parameter categories.
8. The image detection method according to claim 7, characterized in that, The step of training and validating the initial detection model using the training image data and the validation image data based on the second algorithm and the plurality of second model parameter sets, and determining the target parameters from the plurality of second model parameter sets, includes: For each second model parameter group, the initial detection model is trained and validated using training image data and validation image data to obtain the fitness value corresponding to each of the multiple second model parameter groups; The target first model parameter group or second model parameter group with the smallest fitness value of the preset number of groups is determined as multiple updated core parameter combinations, and multiple second iterative model parameter groups are sampled in the target parameter region based on the updated core parameter combinations. The initial detection model is trained and validated based on each second iteration parameter set until a second preset number of iterations is reached, resulting in multiple candidate model parameter sets. The candidate model parameter set is the parameter set with the lowest fitness value in each round of training and validation of the initial detection model. The candidate model parameter groups are trained and evaluated in their entirety to obtain evaluation index values. The candidate model parameter group with the highest evaluation index value is then used as the target parameter.
9. The image detection method according to claim 6, characterized in that, Before resampling multiple sets of first iteration parameters from the preset parameter search space, the method further includes: Obtain the scene type of the training image data, wherein the scene type is used to indicate the scene in which the training image data was collected; In response to the fitness values corresponding to the plurality of first model parameter groups meeting the preset fitness conditions corresponding to the scene type, the first search radius is dynamically expanded to sample the plurality of first iteration parameter groups based on the expanded search radius. Different scene types correspond to different preset fitness conditions, and the preset fitness conditions include at least the degree of fitness value fluctuation and the average accuracy value.
10. The image detection method according to claim 8, characterized in that, Before sampling multiple sets of second-iteration model parameters within the target parameter region based on the updated core parameter combination, the method further includes: After training and validating the initial detection model with training image data and validation image data for each second model parameter group, obtain the target classification corresponding to each image in the training image data, and the frequency of occurrence of the images of the target classification in the training image data; In response to the occurrence frequency meeting a preset frequency condition, the first search step size is dynamically reduced to sample the multiple second iterative model parameter groups based on the reduced search step size.
11. The image detection method according to claim 1, characterized in that, The method further includes: After obtaining the hybrid model and the target detection model through parameter tuning, the hybrid model and the target detection model are subjected to lightweight processing and layer clipping. Deploy a lightweight hybrid model with layer clipping and an object detection model; In response to the detection result that the image to be detected continuously fails to meet the preset reliability conditions, the detection result is transmitted to the cloud, and the detection strategy is adjusted based on the feedback data from the cloud.
12. The image detection method according to claim 1, characterized in that, The method further includes: Real-time image data is acquired, and the real-time image data is decomposed into single-frame images and preprocessed to obtain the image to be detected. The preprocessing includes at least image denoising, size standardization, and pixel value normalization.
13. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the image detection method as described in any one of claims 1 to 12 when executing the computer program.
14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the image detection method as described in any one of claims 1 to 12.
Citation Information
Patent Citations
Image target detection method and device, equipment and storage medium
CN113936256A
Image detection method and device, equipment and storage medium
CN116797903A