An image recognition method and system based on transfer learning and ResNet50 neural network

By improving the ResNet50 neural network, introducing the Huber loss function, ECA-Net attention mechanism, and bidirectional pyramid structure, and combining transfer learning and five-fold cross-validation, the shortcomings of convolutional neural networks in deformation and small target recognition are solved, achieving high-precision and fast image recognition.

CN116824239BActive Publication Date: 2026-03-06LIANYUNGANG JILIAN SECURITY EQUIPMENT TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-19
Publication Date
2026-03-06

AI Technical Summary

Technical Problem

In existing technologies, convolutional neural networks are sensitive to deformation and have poor recognition performance, especially in the detection of images with unclear boundaries, uneven lighting, and small objects. In addition, training requires a large amount of data.

Method used

An improved ResNet50 neural network is adopted, incorporating the Huber loss function, ECA-Net attention mechanism, and bidirectional pyramid structure. The Ranger optimizer is used, combined with transfer learning and five-fold cross-validation for training and optimization.

Benefits of technology

It improved the model's recognition accuracy and robustness, enhanced the ability to identify small objects, reduced the amount of training, avoided overfitting, and improved training speed and generalization ability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116824239B_ABST
    Figure CN116824239B_ABST
Patent Text Reader

Abstract

This invention discloses an image recognition method and system based on transfer learning and a ResNet50 neural network. The method includes constructing a ResNet50 neural network as a baseline model and optimizing and improving it; training the optimized baseline model using transfer learning to establish an image pre-recognition model; establishing a sample image dataset and preprocessing the images within the dataset; dividing the preprocessed sample image dataset into training and test sets using five-fold cross-validation based on the image pre-recognition model; training the image pre-recognition model using the training set to obtain an image recognition model; and testing the trained image recognition model using the test set. The system includes a data processing module, a model training module, and a model analysis module. This invention solves the problems of poor recognition performance, low accuracy, difficulty in accurately detecting and locating small objects, and the need for large amounts of data during model training in existing image recognition methods.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image recognition technology, and in particular to an image recognition method and system based on transfer learning and ResNet50 neural network. Background Technology

[0002] Image recognition refers to the analysis, processing, and understanding of input digital images using computers to perform tasks such as image classification, object detection, or scene segmentation. Current technologies often employ multi-layer convolutional neural networks (CNNs) for feature extraction and classification, achieving high-precision recognition on large datasets; examples include GoogLeNet, VGGNet, and ResNet.

[0003] CNNs use multi-layer convolutional operations and non-linear activation functions to extract features from input data, thereby learning more abstract and high-level feature representations and improving the model's classification and recognition accuracy. However, in practical applications, the following drawbacks exist: CNNs are sensitive to the deformation of the input image, which may affect the model's classification and recognition accuracy; for images with unclear boundaries or uneven lighting, CNNs perform poorly in recognition; and the network model requires a large dataset to obtain a reliable model during training. Furthermore, because small objects are small in size, their information in the image is sparse, making them difficult to capture by the shallow features of CNNs. CNNs typically detect small objects by performing convolutional operations with small receptive fields in shallow feature layers, making it difficult for CNNs to accurately detect and locate small objects. Summary of the Invention

[0004] Purpose of the invention: The purpose of this invention is to provide an image recognition method and system based on transfer learning and ResNet50 neural network that achieves high accuracy and speed in image recognition.

[0005] Technical Solution: To achieve the above objectives, the present invention provides an image recognition method based on transfer learning and ResNet50 neural network, comprising the following steps:

[0006] Step S1: Construct a ResNet50 neural network as a baseline model, and optimize and improve the model to obtain an optimized and improved ResNet50 neural network model;

[0007] Step S2: Train the optimized and improved ResNet50 neural network model using transfer learning to establish an image pre-recognition model;

[0008] Step S3: Establish a sample image dataset and perform preprocessing operations on the images within the sample image dataset;

[0009] Step S4: Based on the image pre-recognition model, the preprocessed sample image dataset is divided into training and test sets using the five-fold cross-validation method;

[0010] Step S5: Train the image pre-recognition model using the training set from step S4, and fine-tune the model parameters again to obtain the image recognition model.

[0011] Step S6: Use the test set from step S4 to test the image recognition model trained in step S5 and obtain the image recognition results.

[0012] Step S1, which involves selecting a ResNet50 neural network as a baseline model and optimizing and improving it to obtain an optimized and improved ResNet50 neural network model, refers to improving the Huber loss function, introducing the ECA-Net attention mechanism and constructing a bidirectional pyramid structure into the ResNet50 neural network to improve the model, and then selecting an optimizer to optimize the improved ResNet50 neural network, thereby obtaining the optimized and improved ResNet50 neural network model. This includes the following sub-steps:

[0013] Step S101: Construct a ResNet50 neural network as a baseline model, which includes five stages:

[0014] The first stage: The input image pixel values ​​pass through a convolutional layer, a BN layer, a ReLU activation function, and a MaxPooling layer to obtain the output;

[0015] The second to fifth stages are all composed of bottleneck layers, which contain 3, 4, 6 and 3 bottleneck layers respectively.

[0016] Step S102: Select the improved Huber loss function as the loss function for the ResNet50 neural network;

[0017] The improved expression for the Huber loss function is as follows:

[0018]

[0019] Where E(x) represents the improved loss function, δ represents the residual critical value, y represents the actual value, and f(x) represents the predicted value;

[0020] Step S103: Improve the ResNet50 neural network by introducing the ECA-Net attention mechanism;

[0021] The ECA-Net attention mechanism generates weights for each channel through a one-dimensional convolution of size k, i.e.:

[0022] ω=δ(C1D k (y))

[0023] In the formula, C1D k Let represent a one-dimensional convolution with a kernel size of k, where y represents the number of channels and δ represents the sigmoid activation function; k is related to the channel dimension, and the larger the channel dimension, the larger the range of local cross-channel interactions k.

[0024] The value of k is determined by an adaptive function C related to the channel dimension, i.e.:

[0025]

[0026] In the formula, || odd Represented as the nearest odd number, γ and b are set to 2 and 1 respectively; C is an adaptive function;

[0027] Step S104: Improve the ResNet50 neural network by introducing the constructed bidirectional pyramid structure. The bidirectional pyramid structure is used to fuse the high-resolution shallow features and deep features in the feature layer of the ResNet50 neural network.

[0028] Step S105: Selecting an optimizer to optimize the improved ResNet50 neural network means using the new Ranger optimizer as the optimizer for training the improved ResNet50 model, thereby obtaining the optimized and improved ResNet50 neural network model.

[0029] In step S101, the first stage, the calculation process of the input image pixel value convolutional layer is as follows:

[0030]

[0031] Where x represents the array of pixel values ​​of the input image samples; padding represents the number of layers that pad each edge of the input with zeros, in order to maintain the consistent size of the feature maps before and after the convolutional layer.

[0032] kernelsize represents the size of the convolution kernel, and stride represents the convolution stride;

[0033] The BN layer calculates the mean of the feature maps generated by the convolutional layer as follows:

[0034]

[0035] Where m represents the total number of input image samples, x i This represents an array of pixel values ​​for a given set of image samples, i = 1, 2, ..., m;

[0036] The BN layer calculates the standard deviation of the feature maps generated by the convolutional layer as follows:

[0037]

[0038] The normalization process of the BN layer on the feature maps generated by the convolutional layer is as follows:

[0039]

[0040] Where ε represents the offset;

[0041] The normalized feature map is reconstructed and transformed as follows:

[0042] y i =γ×x i +β,

[0043] Among them, γ, x i β and β are respectively

[0044] The formula for the ReLU activation function is:

[0045] f(x) = max(0,x)

[0046] MaxPooling layer: The entire image is divided into several small blocks of the same size without overlap. Within each block, only the largest number is taken, and other nodes are discarded. The original planar structure is maintained to obtain the output result.

[0047] In step S104, the fusion process of high-resolution shallow features and deep features in the ResNet50 neural network feature layer is as follows:

[0048] The input image is pooled to obtain the feature layer Conv7-2; the feature map P of Conv7-2 is then processed. 7-2 Upsampling is performed to generate a feature map P′ with the same height and width as the feature map of Conv6-2 layer. 7-2 The dimensions are 10×10×256; the number of channels in the Conv6-2 layer is adjusted to 256 using a 1×1 convolution to generate the feature map P′. 6-2 So that the feature map P′ 7-2 The dimension remains unchanged after fusion with the side edges; the feature map P′ is fused using the Concat feature fusion method. 6-2 and P′ 7-2 The feature map P″ is generated by splicing. 6-2 After two upsampling and side-fusion processes, the top-down pyramid output feature map P′ can be obtained at feature layer Conv4-3. 4-3Then, 1×1 convolutions are used to change the number of channels in feature layers pool1, pool2, and pool3, bilinear interpolation is used for downsampling, and feature fusion is performed using the Add method. This yields a feature map P″ containing positional and detail information at feature layer Conv4-3. 4-3 Then, the feature map P 4-3 , P′ 4-3 , P″ 4-3 Summing the corresponding elements yields the final fused feature map P″′. 4-3 .

[0049] In step S2, the optimized and improved ResNet50 neural network model is trained using transfer learning to establish an image pre-recognition model. Specifically, a large number of images are randomly selected from the ImageNet dataset and divided into a training set and a test set in a 4:1 ratio.

[0050] The optimized ResNet50 neural network model is pre-trained using the training set. Specifically, the convolutional blocks near the input are frozen in the pre-trained model, while the initial layer weights remain unchanged. The remaining convolutional blocks near the output and the fully connected classifier are trained using the training set to obtain new weights. These new weights are calculated by subtracting the backpropagation error from the initial weights. When the backpropagation error is positive, the weight values ​​are decreased; when the backpropagation error is negative, the weight values ​​are increased. The optimized ResNet50 neural network model after training and fine-tuning the weight values ​​is the image pre-recognition model. The performance of the image pre-recognition model, including image recognition accuracy and loss rate, is evaluated using the test set.

[0051] The establishment of the sample image dataset in step S3 refers to acquiring multiple sets of sample images using an image acquisition device; and performing preprocessing operations on the images in the sample image dataset, including cropping, flipping, rotating, and color enhancement operations.

[0052] In step S4, the image pre-recognition model uses a five-fold cross-validation method to divide the preprocessed sample image dataset into training and test sets to avoid overfitting of the model on specific datasets. Specifically:

[0053] The preprocessed sample image dataset is divided into five equal-sized subsets. One subset is selected as the validation set, and the other four subsets are selected as the training set. This process is repeated five times, with a different subset used as the validation set each time. Finally, the average value of the evaluation results of the five recognition models is obtained. The data from each set is compared, and the set with the best data is used as the final standard for dividing the training and test sets.

[0054] In step S5, training the image pre-recognition model using the training set from step S4 and fine-tuning the model parameters to obtain the image recognition model means inputting the image values ​​from the training set into the image pre-recognition model, passing through internal convolutional layers, BN layers, ReLU activation functions, and MaxPooling layers to obtain the image prediction value, and then calculating the deviation between the prediction value and the true value using the Huber loss function. If the deviation is greater than a set threshold, the weight parameters of the ResNet50 neural network are fine-tuned, and the process is repeated until the deviation is less than or equal to the threshold, thus completing the training.

[0055] Specifically, step S5 involves testing the image recognition model trained in step S5 using the test set from step S4 to obtain the image recognition result. This is achieved by inputting the image values ​​from the test set into the image recognition model trained in step S5, adding a Softmax classifier to the model, and obtaining the probability of each image classification result from the classifier, such that the range of each probability value is [0,1], and the sum of all probability values ​​is 1. The one with the highest probability is the final image recognition result.

[0056] The present invention also provides an image recognition system based on transfer learning and ResNet50 neural network according to the above method, including a data processing module, a model training module, and a model analysis module;

[0057] The data processing module refers to the process of acquiring multiple sets of sample images using image acquisition equipment and performing preprocessing operations on the images;

[0058] The model training module includes training and fine-tuning the ResNet-50 network structure, and building an image recognition model based on the ResNet-50 network structure.

[0059] The model analysis module is used to perform performance analysis on image recognition models.

[0060] Beneficial effects: The present invention has the following advantages:

[0061] 1. The image recognition method described in this invention uses the ResNet50 neural network as the baseline model and introduces improved Huber loss function, ECA-Net attention mechanism and bidirectional pyramid structure and other techniques to improve and optimize it, thereby improving the performance and robustness of the model, enhancing the model's classification ability and recognition accuracy, and also enabling the model to have higher recognition accuracy for small target objects.

[0062] 2. The image recognition method described in this invention selects the Ranger optimizer to optimize the improved baseline model, which can effectively handle the problems of gradient vanishing and gradient exploding, and further improve the accuracy and training speed of the model.

[0063] 3. The image recognition method described in this invention uses transfer learning technology, that is, it uses existing data to train the improved and optimized model and establish an image pre-recognition model. This avoids the problem of initializing parameters when training the model from scratch, and also solves the problem of insufficient sample quantity, reduces the training amount of the model, and improves training efficiency.

[0064] 4. This invention uses a five-fold cross-validation method to evaluate the performance of the image pre-recognition model, thereby dividing the preprocessed sample image dataset into a test set and a training set, avoiding overfitting of the model on a specific dataset and improving the model's generalization ability. Attached Figure Description

[0065] Figure 1 This is a schematic diagram of the method flow of the present invention;

[0066] Figure 2 This is a schematic diagram illustrating the process of training an image pre-recognition model. Detailed Implementation

[0067] The technical solution of the present invention will be described in detail below with reference to the embodiments and accompanying drawings.

[0068] like Figure 1 As shown, the image recognition method based on transfer learning and ResNet50 neural network of the present invention includes the following steps:

[0069] Step S1: Construct a ResNet50 neural network as a baseline model, and optimize and improve the model to obtain an optimized and improved ResNet50 neural network model;

[0070] Step S2: Train the optimized and improved ResNet50 neural network model using transfer learning to establish an image pre-recognition model;

[0071] Step S3: Establish a sample image dataset and perform preprocessing operations on the images within the sample image dataset;

[0072] Step S4: Based on the image pre-recognition model, the preprocessed sample image dataset is divided into training and test sets using the five-fold cross-validation method;

[0073] Step S5: Train the image pre-recognition model using the training set from step S4, and fine-tune the model parameters again to obtain the image recognition model.

[0074] Step S6: Use the test set from step S4 to test the image recognition model trained in step S5 and obtain the image recognition results.

[0075] Step S1, which involves selecting a ResNet50 neural network as a baseline model and optimizing and improving it to obtain an optimized and improved ResNet50 neural network model, refers to improving the Huber loss function, introducing the ECA-Net attention mechanism and constructing a bidirectional pyramid structure into the ResNet50 neural network to improve the model, and then selecting an optimizer to optimize the improved ResNet50 neural network, thereby obtaining the optimized and improved ResNet50 neural network model. This includes the following sub-steps:

[0076] Step S101: Construct a ResNet50 neural network as a baseline model, which includes five stages:

[0077] The first stage: The input image pixel values ​​pass through a convolutional layer, a BN layer, a ReLU activation function, and a MaxPooling layer to obtain the output;

[0078] The second to fifth stages are all composed of bottleneck layers, which contain 3, 4, 6 and 3 bottleneck layers respectively.

[0079] Step S102: Select the improved Huber loss function as the loss function for the ResNet50 neural network;

[0080] The improved expression for the Huber loss function is as follows:

[0081]

[0082] Where E(x) represents the improved loss function, δ represents the residual critical value, y represents the actual value, and f(x) represents the predicted value;

[0083] Step S103: Improve the ResNet50 neural network by introducing the ECA-Net attention mechanism;

[0084] The ECA-Net attention mechanism generates weights for each channel through a one-dimensional convolution of size k, i.e.:

[0085] ω=δ(C1D k (y))

[0086] In the formula, C1D k Let represent a one-dimensional convolution with a kernel size of k, where y represents the number of channels and δ represents the sigmoid activation function; k is related to the channel dimension, and the larger the channel dimension, the larger the range of local cross-channel interactions k.

[0087] The value of k is determined by an adaptive function C related to the channel dimension, i.e.:

[0088]

[0089] In the formula, || odd Represented as the nearest odd number, γ and b are set to 2 and 1 respectively; C is an adaptive function;

[0090] Step S104: Improve the ResNet50 neural network by introducing the constructed bidirectional pyramid structure. The bidirectional pyramid structure is used to fuse the high-resolution shallow features and deep features in the feature layer of the ResNet50 neural network.

[0091] Step S105: Selecting an optimizer to optimize the improved ResNet50 neural network means using the new Ranger optimizer as the optimizer for training the improved ResNet50 model, thereby obtaining the optimized and improved ResNet50 neural network model.

[0092] In step S101, the first stage, the calculation process of the input image pixel value convolutional layer is as follows:

[0093]

[0094] Where x represents the array of pixel values ​​of the input image samples; padding represents the number of layers that pad each edge of the input with zeros, in order to maintain the consistent size of the feature maps before and after the convolutional layer.

[0095] kernelsize represents the size of the convolution kernel, and stride represents the convolution stride;

[0096] The BN layer calculates the mean of the feature maps generated by the convolutional layer as follows:

[0097]

[0098] Where m represents the total number of input image samples, x i This represents an array of pixel values ​​for a given set of image samples, i = 1, 2, ..., m;

[0099] The BN layer calculates the standard deviation of the feature maps generated by the convolutional layer as follows:

[0100]

[0101] The normalization process of the BN layer on the feature maps generated by the convolutional layer is as follows:

[0102]

[0103] Where ε represents the offset;

[0104] The normalized feature map is reconstructed and transformed as follows:

[0105] y i =γ×x i +β,

[0106] Among them, γ, x i β and β are respectively

[0107] The formula for the ReLU activation function is:

[0108] f(x) = max(0,x)

[0109] MaxPooling layer: The entire image is divided into several small blocks of the same size without overlap. Within each block, only the largest number is taken, and other nodes are discarded. The original planar structure is maintained to obtain the output result.

[0110] In step S104, the fusion process of high-resolution shallow features and deep features in the ResNet50 neural network feature layer is as follows:

[0111] The input image is pooled to obtain the feature layer Conv7-2; the feature map P of Conv7-2 is then processed. 7-2 Upsampling is performed to generate a feature map P′ with the same height and width as the feature map of Conv6-2 layer. 7-2 The dimensions are 10×10×256; the number of channels in the Conv6-2 layer is adjusted to 256 using a 1×1 convolution to generate the feature map P′. 6-2 So that the feature map P′ 7-2 The dimension remains unchanged after fusion with the side edges; the feature map P′ is fused using the Concat feature fusion method. 6-2 and P′ 7-2 The feature map P″ is generated by splicing. 6-2 After two upsampling and side-fusion processes, the top-down pyramid output feature map P′ can be obtained at feature layer Conv4-3. 4-3 Then, 1×1 convolutions are used to change the number of channels in feature layers pool1, pool2, and pool3, bilinear interpolation is used for downsampling, and feature fusion is performed using the Add method. This yields a feature map P″ containing positional and detail information at feature layer Conv4-3. 4-3 Then, the feature map P 4-3 , P′ 4-3 , P″ 4-3 Summing the corresponding elements yields the final fused feature map P″′. 4-3 .

[0112] In step S2, the optimized and improved ResNet50 neural network model is trained using transfer learning to establish an image pre-recognition model. Specifically, a large number of images are randomly selected from the ImageNet dataset and divided into a training set and a test set in a 4:1 ratio.

[0113] The optimized ResNet50 neural network model is pre-trained using the training set. Specifically, the convolutional blocks near the input are frozen in the pre-trained model, while the initial layer weights remain unchanged. The remaining convolutional blocks near the output and the fully connected classifier are trained using the training set to obtain new weights. These new weights are calculated by subtracting the backpropagation error from the initial weights. When the backpropagation error is positive, the weight values ​​are decreased; when the backpropagation error is negative, the weight values ​​are increased. The optimized ResNet50 neural network model after training and fine-tuning the weight values ​​is the image pre-recognition model. The performance of the image pre-recognition model, including image recognition accuracy and loss rate, is evaluated using the test set.

[0114] The establishment of the sample image dataset in step S3 refers to acquiring multiple sets of sample images using an image acquisition device; and performing preprocessing operations on the images in the sample image dataset, including cropping, flipping, rotating, and color enhancement operations.

[0115] In step S4, the image pre-recognition model uses a five-fold cross-validation method to divide the preprocessed sample image dataset into training and test sets to avoid overfitting of the model on specific datasets. Specifically:

[0116] The preprocessed sample image dataset is divided into five equal-sized subsets. One subset is selected as the validation set, and the other four subsets are selected as the training set. This process is repeated five times, with a different subset used as the validation set each time. Finally, the average value of the evaluation results of the five recognition models is obtained. The data from each set is compared, and the set with the best data is used as the final standard for dividing the training and test sets.

[0117] In step S5, training the image pre-recognition model using the training set from step S4 and fine-tuning the model parameters to obtain the image recognition model refers to inputting image values ​​from the training set into the image pre-recognition model, passing through internal convolutional layers, BN layers, ReLU activation functions, and MaxPooling layers to obtain predicted image values, and then calculating the deviation between the predicted and true values ​​using the Huber loss function. If the deviation is greater than a set threshold, the weight parameters of the ResNet50 neural network are fine-tuned, and this process is iterated repeatedly until the deviation is less than or equal to the threshold, thus completing the training. Figure 2 The diagram shown illustrates the process of training an image recognition model.

[0118] Specifically, step S5 involves testing the image recognition model trained in step S5 using the test set from step S4 to obtain the image recognition result. This is achieved by inputting the image values ​​from the test set into the image recognition model trained in step S5, adding a Softmax classifier to the model, and obtaining the probability of each image classification result from the classifier, such that the range of each probability value is [0,1], and the sum of all probability values ​​is 1. The one with the highest probability is the final image recognition result.

[0119] The present invention also provides an image recognition system based on transfer learning and ResNet50 neural network according to the above method, including a data processing module, a model training module, and a model analysis module;

[0120] The data processing module refers to the process of acquiring multiple sets of sample images using image acquisition equipment and performing preprocessing operations on the images;

[0121] The model training module includes training and fine-tuning the ResNet-50 network structure, and building an image recognition model based on the ResNet-50 network structure.

[0122] The model analysis module is used to perform performance analysis on image recognition models.

[0123] The image recognition method described in this invention uses the ResNet50 neural network as the baseline model and introduces improved Huber loss function, ECA-Net attention mechanism, and bidirectional pyramid structure to improve and optimize it, thereby improving the model's performance and robustness, enhancing its classification ability and recognition accuracy, and also enabling the model to have higher recognition accuracy for small objects. Among them, the Huber loss function can make the model converge more smoothly, speed up the training process and reduce noise and fluctuations during training; the ECA-Net attention mechanism can help the model better focus on important features, improving the model's accuracy and robustness; the bidirectional pyramid structure can realize bidirectional fusion of high and low layer features, further improving the model's feature extraction and expression capabilities.

[0124] The image recognition method described in this invention uses transfer learning technology, that is, using existing data to train an improved and optimized model to establish an image pre-recognition model. This avoids the problem of initializing parameters when training the model from scratch, and also solves the problem of insufficient sample quantity, reducing the training load and improving training efficiency.

[0125] This invention employs a five-fold cross-validation method to evaluate the performance of an image pre-recognition model. This method divides the preprocessed sample image dataset into a test set and a training set, thereby avoiding overfitting of the model on a specific dataset and improving the model's generalization ability.

Claims

1. An image recognition method based on transfer learning and a ResNet50 neural network, characterized in that, Comprise the following steps: Step S1: constructing a ResNet50 neural network as a benchmark model, and optimizing and improving the model to obtain an optimized and improved ResNet50 neural network model; Step S2: training the optimized and improved ResNet50 neural network model using a transfer learning method to establish an image pre-identification model; Step S3: establishing a sample image dataset and performing preprocessing operations on the images in the sample image dataset; Step S4: based on the image pre-identification model, using a five-fold cross-validation method to divide the preprocessed sample image dataset into a training set and a test set; Step S5: using the training set in step S4 to train the image pre-identification model and fine-tuning the model parameters again to obtain an image identification model; Step S6: using the test set in step S4 to test the trained image identification model in step S5 to obtain an image identification result; Step S1 of constructing a ResNet50 neural network as a benchmark model, and optimizing and improving the model to obtain an optimized and improved ResNet50 neural network model, refers to improving the Huber loss function and introducing an ECA-Net attention mechanism and constructing a bidirectional pyramid structure in the ResNet50 neural network to improve the model, and then selecting an optimizer to optimize the improved ResNet50 neural network to obtain an optimized and improved ResNet50 neural network model, comprising the following sub-steps: Step S101: constructing a ResNet50 neural network as a benchmark model, including five stages, which are: The first stage: the input image pixel value first passes through the convolution layer, the BN layer, the ReLU activation function, and the MaxPooling layer to obtain the output; The second to fifth stages are all composed of bottleneck layers Bottleneck, which respectively contain 3, 4, 6, and 3 bottleneck layers Bottleneck; Step S102: selecting an improved Huber loss function as the loss function of the ResNet50 neural network; The expression of the improved Huber loss function is as follows: , wherein represents the improved loss function, represents the residual threshold, represents the actual value, represents the predicted value; Step S103: introducing an ECA-Net attention mechanism in the ResNet50 neural network for improvement; The ECA-Net attention mechanism generates weights for each channel through a one-dimensional convolution with a size of k, that is: , In the formula, represents a one-dimensional convolution with a kernel size of k, y represents a channel, represents a sigmoid activation function; k is related to the channel dimension, and the larger the channel dimension, the larger the range k of local cross-channel interaction; The value of k is determined through an adaptive function C related to the channel dimension, that is: , wherein is expressed as the nearest odd number, and the values of a and b are set to 2 and 1, respectively; C is an adaptive function; Step S104: introducing the constructed bidirectional pyramid structure into the ResNet50 neural network for improvement, and fusing high-resolution shallow features and deep features in the ResNet50 neural network feature layer through the bidirectional pyramid structure; Step S105: selecting an optimizer to optimize the improved ResNet50 neural network, which means using a new Ranger optimizer as the optimizer for training the improved ResNet50 model, thereby obtaining an optimized and improved ResNet50 neural network model. 2.The image recognition method based on the migration learning and ResNet50 neural network according to claim 1, characterized in that, In the first stage of step S101, the convolution layer calculation process of the input image pixel value is: , wherein, represents an input image sample pixel value array; represents the number of layers of supplementary 0 for each edge of the input, for maintaining the consistency of the feature map size before and after the convolution layer, ; denotes the size of the convolution kernel, denotes the convolution stride; The BN layer calculates the mean of the feature map generated by the convolution layer as follows: , wherein, represents the total number of input image samples, represents an array of pixel values of a certain group of input image samples, ; The BN layer calculates the standard deviation of the feature map generated by the convolution layer as follows: , The BN layer performs normalization processing on the feature map generated by the convolution layer as follows: , wherein represents an offset; The normalized feature map is reconstructed and changed as follows: , wherein respectively The ReLU activation function formula is as follows: , The MaxPooling layer: the entire image is divided into several small blocks of the same size without overlap. In each small block, only the maximum number is taken, and the remaining nodes are discarded to maintain the original plane structure to obtain the output result. 3.The image recognition method based on the transfer learning and ResNet50 neural network according to claim 1, characterized in that, In the ResNet50 neural network feature layer in step S104, the high-resolution shallow layer feature and the deep layer feature fusion process is as follows: The input image is subjected to a pooling operation, and a feature layer Conv7-2 is obtained after the pooling operation; the feature map P 7-2 of Conv7-2 is subjected to upsampling, and a feature map P′ 7-2 with the same height and width as the feature map of the Conv6-2 layer is generated, with a dimension of 10x10x256; the channel number of the Conv6-2 layer is adjusted to 256 by using a 1x1 convolution, and a feature map P′ 6-2 is generated, so that the dimension of the feature map P′ 7-2 remains unchanged after side fusion; the feature maps P′ 6-2 and P′ 7-2 are spliced by a Concat feature fusion method to generate a feature map P″ 6-2 ; after two upsampling and side fusion processes, an output feature map P′ 4-3 of a top-down pyramid is obtained at the feature layer Conv4-3; the channel number of the feature layers pool1, pool2 and pool3 is changed by using a 1x1 convolution, down-sampling is performed by using a bilinear interpolation, and feature fusion is performed by using an Add method, so that a feature map P″ 4-3 containing position and detail information is obtained at the feature layer Conv4-3; and the feature maps P 4-3 , P′ 4-3 and P″ 4-3 are subjected to corresponding element summation to obtain a finally fused feature map P″′ 4-3 . 4.The image recognition method based on the transfer learning and ResNet50 neural network according to claim 1, characterized in that, In step S2, the ResNet50 neural network model optimized and improved by using the transfer learning method is trained to establish an image pre-recognition model. Specifically, a large number of pictures are randomly selected from the ImageNet data set, and are divided into a training set and a test set according to a 4:1 ratio; The training set is used to pre-train the ResNet50 neural network model optimized and improved, that is, the convolution blocks close to the input end of the pre-training model are frozen, the initial layer weights are kept unchanged, the remaining convolution blocks close to the output end and the full connection classifier are trained with the training set, and new weights are obtained, wherein the new weights are obtained by subtracting the error of back propagation from the initial weights. When the error of back propagation is positive, the value of the weight is reduced, and when the error of back propagation is negative, the value of the weight is increased. The ResNet50 neural network model optimized and improved after training and fine-tuning of the weight value is the image pre-recognition model. The performance of the image pre-recognition model is tested by using the test set, including the accuracy and loss rate of image recognition. 5.The image recognition method based on the transfer learning and ResNet50 neural network according to claim 1, characterized in that, In step S3, the sample image data set is established by using an image acquisition device to obtain a plurality of sample images. The pre-processing operation is performed on the images in the sample image data set, including image cropping, flipping, rotating and color enhancement. 6.The image recognition method based on the transfer learning and ResNet50 neural network according to claim 1, characterized in that, In step S4, based on the image pre-recognition model, a five-fold cross-validation method is used to divide the pre-processed sample image data set into a training set and a test set to avoid overfitting of the model on a specific data set. Specifically: The pre-processed sample image data set is divided into five equal-sized subsets, one of which is taken as a validation set and the remaining four are taken as a training set. The process is repeated five times, each time using a different subset as a validation set. Finally, the average value of the five recognition model evaluation results is obtained. The data of the best group is compared, and the data of the best group is taken as the final training set and test set division standard. 7.The image recognition method based on the transfer learning and ResNet50 neural network according to claim 1, characterized in that, The training of the image pre-identification model by using the training set in step S4 and the fine-tuning of the model parameters again to obtain the image identification model in step S5 refer to inputting the image values in the training set into the image pre-identification model, obtaining image prediction values through internal convolution layers, BN layers, ReLU activation functions and MaxPooling layers, calculating the deviation of the prediction values from the true values through a Huber loss function, fine-tuning the ResNet50 neural network weight parameters if the deviation is greater than a set threshold, repeatedly iterating until the deviation is less than or equal to the threshold, and completing the training. 8.The image recognition method based on the transfer learning and ResNet50 neural network according to claim 1, characterized in that, The testing of the trained image identification model in step S5 by using the test set in step S4 to obtain the image identification result in step S5 refers to inputting the image values in the test set into the trained image identification model in step S5, adding a flexible maximum exponential function Softmax classifier to the model, obtaining the probability of each image classification result from the classifier, so that the value range of each probability value is [0, 1] and the sum of all probability values is 1, and the probability with the maximum value is the final image identification result.

9. An image recognition system based on transfer learning and ResNet50 neural network suitable for use in the method of any one of claims 1-8, characterized in that, The data processing module, the model training module and the model analysis module are included. The data processing module refers to obtaining multiple groups of sample images by using an image acquisition device and performing a pre-processing operation on the images. The model training module includes training and fine-tuning of the ResNet-50 network structure and constructing an image identification model based on the ResNet-50 network structure. The model analysis module is used for performance analysis of the image identification model.

Citation Information

Patent Citations

  • Pest and disease identification method and device based on ResNet residual network

    CN115035511A

  • Small sample SAR ship target identification method and device

    CN115272685A