A lightweight target image detection method and device based on deep learning
By constructing a 6-layer CNN D-Mini neural network model and combining pooling, dimensionality reduction, and the DenseNet architecture, the problem of high computational resource consumption in deep learning for flower image recognition is solved, and efficient image recognition is achieved on lightweight devices.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA TELECOM DIGITAL INTELLIGENCE TECH CO LTD
- Filing Date
- 2022-08-10
- Publication Date
- 2026-06-05
AI Technical Summary
Existing deep learning methods for flower image recognition suffer from high computational resource consumption and are difficult to apply on lightweight devices such as microcontrollers.
A D-Mini neural network model containing a 6-layer convolutional neural network (CNN) is constructed. The complexity of the neural network is reduced through pooling, dimensionality reduction, and regularization. The DenseNet architecture is adopted to improve network efficiency. Combined with sliding window and smoothing processing, the target image detection results are output.
It achieves efficient image recognition on lightweight devices, reduces resource consumption, improves recognition accuracy, and achieves a recognition effect of 91%.
Smart Images

Figure CN115240051B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing technology, and in particular relates to a lightweight target image detection method and apparatus based on deep learning. Background Technology
[0002] With the continuous advancement of artificial intelligence, its role in classification is becoming increasingly important, especially in computer vision. Driven by AI, deep learning has achieved significant breakthroughs. In convolutional neural networks (CNNs), AlexNet was at the forefront of image classification in 2012, and the GoogleNet architecture in 2014 surpassed it. The ResNet architecture in 2015 far outperformed previous architectures in classification processing. On the large-scale ILSVRC2012 (ImageNet) dataset, DenseNet achieved similar accuracy to ResNet, but used less than half the number of parameters, approximately half the number of FLOPs. Therefore, ResNet's advantage lies in its network depth, which allows for accurate matching of the objective function. The DenseNet architecture addresses the issues of excessive parameters and overfitting in the ResNet architecture through clustering. The DenseNet framework is a convolutional neural network framework. By improving the Tradaboosting deep learning method within the DenseNet framework, the improved CNN-Tradaboosting can be implemented within convolutional neural networks.
[0003] Theoretically, the more detailed the image, the higher the accuracy of deep learning. However, the cost is a geometrically increasing computational power. In the multi-class classification task of the Flower-Data dataset, due to the difficulty of identifying flowers, their shape, size, and style, it is difficult to distinguish many different types of flowers by appearance features, which is difficult for deep learning to achieve. Summary of the Invention
[0004] The main objective of this invention is to overcome the shortcomings and deficiencies of the prior art and provide a lightweight target image detection method and device based on deep learning. By constructing a D-Mini neural network model containing a 6-layer convolutional neural network (CNN), and performing a second processing on the D-Mini neural network model, a target image detection model is obtained. The image data to be identified is input into the target image detection model, and the detection and recognition results are output. This reduces the complexity of the neural network, can be applied to lightweight microcontrollers, and reduces resource consumption.
[0005] According to one aspect of the present invention, a lightweight target image detection method based on deep learning is provided, the method comprising the following steps:
[0006] S1: Collect sample data, perform a first process on the sample data, and obtain the model training dataset;
[0007] S2: Construct a D-Mini neural network model, input the data in the model training dataset into the D-Mini neural network model, perform a second processing on the D-Mini neural network model to obtain a target image detection model, wherein the D-Mini neural network model is composed of a 6-layer convolutional neural network CNN;
[0008] S3: Input the image data to be identified into the target image detection model, detect and output the recognition result.
[0009] Preferably, the process of collecting sample data and performing a first process on the sample data to obtain the model training dataset includes:
[0010] The sample data is compressed to obtain a three-dimensional tensor dataset, which is a list dataset composed of three two-dimensional tensors.
[0011] The three-dimensional tensor dataset is subjected to data encoding and transformation processing, namely pooling and dimensionality reduction, to obtain a model training dataset in two-dimensional tensor form.
[0012] Preferably, the D-Mini neural network model consists of a 6-layer convolutional neural network (CNN), and the parameter configuration of each layer includes:
[0013] The first CNN layer has a Max_len parameter configured to be 20, a hidden_dim hidden layer configured to be 30, a kernel_size parameter configured to be 2, and a bias parameter configured to be True. The first neural network layer uses average pooling operation, and then proceeds to the second layer.
[0014] The second CNN layer has a Max_len parameter of 30, a hidden_dim parameter of 60, a kernel_size parameter of 2, a bias parameter of True, a stride parameter of None, a padding parameter of 0, a ceil_mode parameter of False, and a count_include_pad parameter of True. The second neural network uses max pooling. After the operation is completed, the third layer is entered.
[0015] The third CNN layer has a Max_len parameter of 60, a hidden_dim parameter of 100, a kernel_size parameter of 2, a bias parameter of True, a stride parameter of None, a padding parameter of 0, a ceil_mode parameter of False, and a count_include_pad parameter of True. The third neural network uses max pooling. After the operation is completed, the fourth layer is entered.
[0016] The fourth CNN layer has a Max_len parameter set to 100, a hidden_dim parameter set to 140, a kernel_size parameter set to 2, a bias parameter set to True, a stride parameter set to None, a padding parameter set to 0, a ceil_mode parameter set to False, and a count_include_pad parameter set to True. The fourth neural network layer uses max pooling. After the operation is completed, the fifth layer is introduced.
[0017] The fifth CNN layer has the following parameters: Max_len = 140, hidden_dim = 160, kernel_size = 2, bias = True, stride = None, padding = 0, ceil_mode = False, count_include_pad = True. The fourth neural network layer uses max pooling. After the operation is completed, the fifth layer is entered.
[0018] The sixth CNN layer has the following parameters: Max_len = 160, hidden_dim = 190, kernel_size = 2, bias = True, stride = None, padding = 0, ceil_mode = False, count_include_pad = True. The sixth CNN layer uses max pooling, and after the operation, the output data is regularized.
[0019] Preferably, the second processing of the D-Mini neural network model includes:
[0020] A sliding window operation is performed on the neural network of the D-Mini model to determine whether there are any anomalies in the values of each sliding window. If anomalies are found, the abnormal data is smoothed.
[0021] Preferably, the second processing of the D-Mini neural network model includes:
[0022] The output data of the D-Mini neural network model is rounded and decoded to obtain three-dimensional tensor data. The three-dimensional tensor data is then input into the Fast-R-CNN model to complete the training of the model and obtain the target image detection model.
[0023] According to another aspect of the present invention, the present invention also provides a lightweight target image detection device based on deep learning, the device comprising:
[0024] The processing module is used to collect sample data, perform a first processing on the sample data, and obtain a model training dataset;
[0025] The training module is used to construct a D-Mini neural network model, input the data in the model training dataset into the D-Mini neural network model, perform a second processing on the D-Mini neural network model to obtain a target image detection model, wherein the D-Mini neural network model is composed of a 6-layer convolutional neural network CNN;
[0026] The recognition module is used to input the image data to be recognized into the target image detection model, detect and output the recognition result.
[0027] Preferably, the processing module collects sample data and performs a first processing on the sample data to obtain a model training dataset including:
[0028] The sample data is compressed to obtain a three-dimensional tensor dataset, which is a list dataset composed of three two-dimensional tensors.
[0029] The three-dimensional tensor dataset is subjected to data encoding and transformation processing, namely pooling and dimensionality reduction, to obtain a model training dataset in two-dimensional tensor form.
[0030] Preferably, the training module constructs a D-Mini neural network model, which consists of a 6-layer convolutional neural network (CNN), and the parameter configuration of each layer includes:
[0031] The first CNN layer has a Max_len parameter configured to be 20, a hidden_dim hidden layer configured to be 30, a kernel_size parameter configured to be 2, and a bias parameter configured to be True. The first neural network layer uses average pooling operation, and then proceeds to the second layer.
[0032] The second CNN layer has a Max_len parameter of 30, a hidden_dim parameter of 60, a kernel_size parameter of 2, a bias parameter of True, a stride parameter of None, a padding parameter of 0, a ceil_mode parameter of False, and a count_include_pad parameter of True. The second neural network uses max pooling. After the operation is completed, the third layer is entered.
[0033] The third CNN layer has a Max_len parameter of 60, a hidden_dim parameter of 100, a kernel_size parameter of 2, a bias parameter of True, a stride parameter of None, a padding parameter of 0, a ceil_mode parameter of False, and a count_include_pad parameter of True. The third neural network uses max pooling. After the operation is completed, the fourth layer is entered.
[0034] The fourth CNN layer has a Max_len parameter set to 100, a hidden_dim parameter set to 140, a kernel_size parameter set to 2, a bias parameter set to True, a stride parameter set to None, a padding parameter set to 0, a ceil_mode parameter set to False, and a count_include_pad parameter set to True. The fourth neural network layer uses max pooling. After the operation is completed, the fifth layer is introduced.
[0035] The fifth CNN layer has the following parameters: Max_len = 140, hidden_dim = 160, kernel_size = 2, bias = True, stride = None, padding = 0, ceil_mode = False, count_include_pad = True. The fourth neural network layer uses max pooling. After the operation is completed, the fifth layer is entered.
[0036] The sixth CNN layer has the following parameters: Max_len = 160, hidden_dim = 190, kernel_size = 2, bias = True, stride = None, padding = 0, ceil_mode = False, count_include_pad = True. The sixth CNN layer uses max pooling, and after the operation, the output data is regularized.
[0037] Preferably, the second processing of the D-Mini neural network model by the training module includes:
[0038] A sliding window operation is performed on the neural network of the D-Mini model to determine whether there are any anomalies in the values of each sliding window. If anomalies are found, the abnormal data is smoothed.
[0039] Preferably, the second processing of the D-Mini neural network model by the training module includes:
[0040] The output data of the D-Mini neural network model is rounded and decoded to obtain three-dimensional tensor data. The three-dimensional tensor data is then input into the Fast-R-CNN model to complete the training of the model and obtain the target image detection model.
[0041] Beneficial effects: This invention constructs a D-Mini neural network model containing a 6-layer convolutional neural network (CNN), performs a second processing on the D-Mini neural network model to obtain a target image detection model, inputs the image data to be identified into the target image detection model, detects and outputs the recognition result, which can reduce the complexity of the neural network, can be applied to lightweight microcontrollers, and reduce resource consumption.
[0042] The features and advantages of the present invention will become clear from the following accompanying drawings and a detailed description of specific embodiments thereof. Attached Figure Description
[0043] Figure 1 This is a flowchart of a lightweight target image detection method based on deep learning;
[0044] Figure 2 This is a schematic diagram of a lightweight target image detection device based on deep learning. Detailed Implementation
[0045] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0046] Example 1
[0047] The dataset in this embodiment can be an image dataset of any object; this embodiment is not limited to this. The following explanation uses a Flower-Data dataset of 9000 collected flower images as an example.
[0048] Figure 1This is a flowchart of a lightweight object image detection method based on deep learning. Figure 1 As shown, this embodiment provides a lightweight target image detection method based on deep learning, the method including the following steps:
[0049] S1: Collect sample data, perform a first process on the sample data, and obtain the model training dataset.
[0050] Preferably, the process of collecting sample data and performing a first process on the sample data to obtain the model training dataset includes:
[0051] The sample data is compressed to obtain a three-dimensional tensor dataset, which is a list dataset composed of three two-dimensional tensors.
[0052] The three-dimensional tensor dataset is subjected to data encoding and transformation processing, namely pooling and dimensionality reduction, to obtain a model training dataset in two-dimensional tensor form.
[0053] Specifically, the FlowerData dataset is a dataset describing the characteristics of flowers. Externally, most flowers are round, and the angles and curvatures of their petals are highly similar. The 9000 images cover 300-320 flower species. The images are framed from top to bottom, primarily identifying flower types based on petals and stamens, relying heavily on shape, thus significantly increasing the difficulty of identification. For this data, the first preprocessing step is to convert the images to black and white and sharpen the contours. Wavelet transform can be used for this black and white processing. Initially, the images are 4000*4000 square images at camera size. A uniform compression process is needed, reducing the original pixel features of the 4000*4000 images to 2560*2560 pixels. This results in the pre-processed black and white image dataset M, containing 9000 black and white images of 2560*2560 pixels, forming a 3D tensor data structure for neural network training.
[0054] Further processing is needed for M because D-Mini is a lightweight neural network. Therefore, further processing of the D-Mini input is required. Theoretically, the more detailed the image, the higher the accuracy of deep learning, but at the cost of exponentially increased computational power. Due to the difficulty of identifying flower datasets—their shape, size, and style—many different types of flowers are difficult to distinguish based on appearance features alone, which is challenging for deep learning. To achieve a lightweight neural network design, lower-resolution images must be used. However, achieving good performance with low-resolution images often significantly increases the complexity of the deep learning model design. Extracting deeper features greatly increases the model's load. This embodiment uses lightweight image data features on top of a lightweight network.
[0055] Take the 2560*2560 three-dimensional tensor image data in M, perform a max pooling operation, and use a 2*2 sliding window to perform the sliding operation to obtain a new 1280*1280 image. The choice of pooling operation depends on the type of image. If there are many differential features, that is, there are many differences between the data, that is, the fluctuations between adjacent data are large, max pooling is used. If the differences are not obvious, average pooling is sufficient. Generally, two pooling operations are required to reduce the dimension of the image and further sharpen the features to obtain 640*640 image data.
[0056] A 3D tensor is a list dataset composed of three 2D tensors. For example, a 640x640 image data set, where each image's 3D tensor (i.e., three 2D tensors) is merged into a single 2D tensor. The image is composed of the three primary colors (R, G, B), which are stored sequentially within the three 2D tensors. A 2D tensor is equivalent to a 2x2 matrix. A 640x640 pixel image means that both its length and width are 640 pixels, meaning each of the three 2D tensors is 640x640 pixels, and the RGB information for each pixel in the 2D tensor corresponds to that tensor. Now we need to encode the data using information like k = (a, b, c)i, where a, b, and c are the RGB primary color information of the i-th pixel in a 640*640 pixel array. We then standardize this information, assuming there are N different types of points like (a, b, c)i. k = (a, b, c)i represents assigning the RGB information of the i-th pixel to k, where k is within the range (1, N). This achieves the encryption process. After a series of operations, we can convert three two-dimensional tensors into a single 640*640 two-dimensional tensor.
[0057] S2: Construct a D-Mini neural network model, input the data from the model training dataset into the D-Mini neural network model, perform a second processing on the D-Mini neural network model to obtain a target image detection model, wherein the D-Mini neural network model consists of a 6-layer convolutional neural network CNN.
[0058] Preferably, the D-Mini neural network model consists of a 6-layer convolutional neural network (CNN), and the parameter configuration of each layer includes:
[0059] The first CNN layer has a Max_len parameter configured to be 20, a hidden_dim hidden layer configured to be 30, a kernel_size parameter configured to be 2, and a bias parameter configured to be True. The first neural network layer uses average pooling operation, and then proceeds to the second layer.
[0060] The second CNN layer has a Max_len parameter of 30, a hidden_dim parameter of 60, a kernel_size parameter of 2, a bias parameter of True, a stride parameter of None, a padding parameter of 0, a ceil_mode parameter of False, and a count_include_pad parameter of True. The second neural network uses max pooling. After the operation is completed, the third layer is entered.
[0061] The third CNN layer has a Max_len parameter of 60, a hidden_dim parameter of 100, a kernel_size parameter of 2, a bias parameter of True, a stride parameter of None, a padding parameter of 0, a ceil_mode parameter of False, and a count_include_pad parameter of True. The third neural network uses max pooling. After the operation is completed, the fourth layer is entered.
[0062] The fourth CNN layer has a Max_len parameter set to 100, a hidden_dim parameter set to 140, a kernel_size parameter set to 2, a bias parameter set to True, a stride parameter set to None, a padding parameter set to 0, a ceil_mode parameter set to False, and a count_include_pad parameter set to True. The fourth neural network layer uses max pooling. After the operation is completed, the fifth layer is introduced.
[0063] The fifth CNN layer has the following parameters: Max_len = 140, hidden_dim = 160, kernel_size = 2, bias = True, stride = None, padding = 0, ceil_mode = False, count_include_pad = True. The fourth neural network layer uses max pooling. After the operation is completed, the fifth layer is entered.
[0064] The sixth CNN layer has the following parameters: Max_len = 160, hidden_dim = 190, kernel_size = 2, bias = True, stride = None, padding = 0, ceil_mode = False, count_include_pad = True. The sixth CNN layer uses max pooling, and after the operation, the output data is regularized.
[0065] Specifically, after encoding in step S1, a 640*640 one-dimensional matrix is obtained. Next, it is put into the D-Mini neural network. The D-Mini mainly consists of a 6-layer CNN. Densenet empowers the CNN, enabling the CNN to be reused, increasing the efficiency of the CNN, and improving the training effect of the CNN. Compared with a general 6-layer CNN, the 6-layer CNN of the Densenet architecture is equivalent to a general 13-layer CNN, which has a better effect on lightweight applications.
[0066] The first CNN layer (CNN1) has a Max_len parameter set to 20, a hidden_dim parameter set to 30, a kernel_size parameter set to 2, and a bias parameter set to True. In this first layer, we used average pooling. After the first convolutional layer, before accurately moving to the second convolutional layer, the data needs to undergo average pooling. Then, it proceeds to the second layer.
[0067] The second CNN layer (CNN2) has a Max_len parameter set to 30, a hidden_dim parameter set to 60, a kernel_size parameter set to 2, and a bias parameter set to True. Max pooling is configured with stride set to None, padding set to 0, ceil_mode set to False, and count_include_pad set to True. After this operation, the input will proceed to the third layer.
[0068] The third CNN layer (CNN3) has a Max_len parameter set to 60, a hidden_dim parameter set to 100, a kernel_size parameter set to 2, and a bias parameter set to True. Max pooling is configured with stride set to None, padding set to 0, ceil_mode set to False, and count_include_pad set to True. After this operation, the input will proceed to the fourth layer.
[0069] The fourth CNN layer (CNN4) has a Max_len parameter set to 100, a hidden_dim parameter set to 140, a kernel_size parameter set to 2, and a bias parameter set to True. Max pooling is configured with stride set to None, padding set to 0, ceil_mode set to False, and count_include_pad set to True. After this operation, the input will proceed to the fifth layer.
[0070] The fifth CNN layer (CNN5) has a Max_len parameter set to 140, a hidden_dim parameter set to 160, a kernel_size parameter set to 2, and a bias parameter set to True. Max pooling is configured with stride set to None, padding set to 0, ceil_mode set to False, and count_include_pad set to True. Max pooling was used in the fourth neural network layer, and after this operation, the input will proceed to the sixth layer.
[0071] The sixth CNN layer (CNN6) has a Max_len parameter set to 160, a hidden_dim parameter set to 190, a kernel_size parameter set to 2, and a bias parameter set to True. Max pooling is configured with stride set to None, padding set to 0, ceil_mode set to False, and count_include_pad set to True. Max pooling is used in this sixth neural network layer. After this operation, subsequent steps are performed.
[0072] After completing the above operations, the output data is regularized with the dorupout parameter set to 0.5. The linear method uses hidden_dim = 160 and output_size as input for computation. output_size is the length of the data output from the fifth CNN layer. Next, the activation function is configured, using softmax with the dim parameter set to 1. After the above data processing, the data is finally output as a one-dimensional feature value with a range. The data is placed into one of these ranges after processing, which is the data classification process.
[0073] The DenseNet mapping configuration is as follows: (6-->3, 3-->4, 4-->5, 5-->6, 6-->2, 2-->5, 5-->6). This means that after the first to sixth layers of the CNN are completed, execution will continue according to the mapping relationship designed by DenseNet.
[0074] The DenseNet architecture is used. The thirteen layers above are expanded into a single thirteen-layer neural network. The model is first trained using a six-layer neural network. After one cycle, a total of 13 layers are processed. This means the data enters from Conv1 and exits from Conv6. Next, starting from layer 7, the `Max_len` is configured to match the `Max_len` of layer 6, and `hidden_dim = Max_len + 6`. This parameter must be correct. Then, 6-->3 represents completing a full cycle of the CNN, from CNN1 to CNN6. Data from CNN6 then exits from CNN3. After this series of operations, ..., finally, 5-->6 represents entering CNN5 and then CNN6. DenseNet allows the neural network to be folded, improving utilization; a six-layer neural network achieves the effect of a thirteen-layer network. (We name this six-layer DenseNet neural network CNN1-CNN6). The specific order is as follows: 6-->3-->4-->5-->6; 6-->2-->5-->6.
[0075] Preferably, the second processing of the D-Mini neural network model includes:
[0076] A sliding window operation is performed on the neural network of the D-Mini model to determine whether there are any anomalies in the values of each sliding window. If anomalies are found, the abnormal data is smoothed.
[0077] Specifically, after processing by the CNN network described above, the parameters undergo a large number of iterations. That is, after training, the input 640*640 two-dimensional tensor data is run through six layers of the network. The window size of each sliding window is 2*2. The neural network sliding window mechanism is executed with a step size of 1. After being executed by the 13 layers of the D-Mini CNN, the CNN connections all use average pooling. After a series of runs, a 614*614 two-dimensional tensor is obtained. When obtaining this tensor, this embodiment not only configures a pooling layer for each neural network layer, but also equips it with a degeneracy smoothing processing strategy. When performing sliding window processing in the neural network, this strategy automatically takes the three sliding windows before and after, compares the seven sliding windows each time, and judges the parts with large data differences in the 2*2 sliding windows among the seven sliding windows. The standard for judging the size of the difference is to use the average value. If it is found that one sliding window is more than 1.4 times higher than the other six sliding windows, or the six sliding window values are much higher than 1.8 times of one sliding window, then smoothing processing is required. The part with the higher or lower fluctuation value is assigned the average value of the six sliding windows and output. That is to say, after the data passes through a CNN layer, it not only passes through a pooling layer, but also a degeneracy smoothing processing mechanism to complete the judgment.
[0078] Preferably, the second processing of the D-Mini neural network model includes:
[0079] The output data of the D-Mini neural network model is rounded and decoded to obtain three-dimensional tensor data. The three-dimensional tensor data is then input into the Fast-R-CNN model to complete the training of the model and obtain the target image detection model.
[0080] Specifically, firstly, a rounding operation is performed on the 614*614 two-dimensional tensor, and then the data is decoded. During the encryption operation, we have the operation k = (a, b, c)i, and the mapping relationship between k and the tuples a, b, c is saved during encryption. Now, the mapping relationship needs to be returned based on the numbers. The degeneracy smoothing process in the previous step is designed to ensure that this mapping relationship holds true. Because some elements are amplified by the neural network features, resulting in no matching items when the data is restored during decoding, this embodiment restores the 614*614 two-dimensional tensor into a three-dimensional tensor. Finally, this three-dimensional tensor is put into the simplified parameter Fast-R-CNN to complete the final training.
[0081] The parameter values are set as follows: base_lr = 0.001 (learning rate), lr_policy = 'step' (the sliding window mode should follow a step-by-step approach), step_size = 30 (number of images per epoch), display = 20, iteration: the data is used for one forward-backward training iteration, batchsize: the number of training images per iteration, epoch: one epoch means training the network with all training images once, max = 1365 (maximum number of iterations).
[0082] The dataset has 9000 images, and the batch size is 614. Therefore, one epoch requires 9000 / 614 = 15 iterations. Its max-iteration is 1350, so there are a total of 1350 / 15 = 90 epochs. When the learning rate (LR) decays depends on the step size, and how much it decays depends on the gamma. That is, if the step size is 500, the base_lr is 0.01, and the gamma is 0.1, then when it reaches the first 500 iterations, the LR decays for the first time. The decayed LR = lrgamma = 0.01 + 0.1 = 0.001. This process is repeated thereafter. Therefore, the step size is the decay step size of the LR, and the gamma is the decay coefficient of the LR. The number of iterations for Fast-R-CNN is modified to max_iters = [2730, 1365, 2730, 1365].
[0083] After training, its accuracy can reach 91%, saving 40% of computing power.
[0084] S3: Input the image data to be identified into the target image detection model, detect and output the recognition result.
[0085] Specifically, after completing the classification task of all Flower-Data datasets, a random flower photo can be provided. After processing the photo, it can be input into the target image detection model of this embodiment to output the result of flower type identification.
[0086] This embodiment constructs a D-Mini neural network model containing a 6-layer convolutional neural network (CNN), performs a second processing on the D-Mini neural network model to obtain a target image detection model, inputs the image data to be identified into the target image detection model, detects and outputs the recognition result, which can reduce the complexity of the neural network, can be applied to lightweight microcontrollers, and reduce resource consumption.
[0087] Example 2
[0088] Figure 2This is a schematic diagram of a lightweight target image detection device based on deep learning. Figure 2 As shown, this embodiment also provides a lightweight target image detection device based on deep learning, the device comprising:
[0089] Processing module 201 is used to collect sample data and perform a first process on the sample data to obtain a model training dataset;
[0090] Training module 202 is used to construct a D-Mini neural network model, input the data in the model training dataset into the D-Mini neural network model, perform a second processing on the D-Mini neural network model to obtain a target image detection model, wherein the D-Mini neural network model is composed of a 6-layer convolutional neural network CNN;
[0091] The recognition module 203 is used to input the image data to be recognized into the target image detection model, detect and output the recognition result.
[0092] Preferably, the processing module 201 collects sample data and performs a first processing on the sample data to obtain a model training dataset including:
[0093] The sample data is compressed to obtain a three-dimensional tensor dataset, which is a list dataset composed of three two-dimensional tensors.
[0094] The three-dimensional tensor dataset is subjected to data encoding and transformation processing, namely pooling and dimensionality reduction, to obtain a model training dataset in two-dimensional tensor form.
[0095] Preferably, the training module 202 constructs a D-Mini neural network model, which consists of a 6-layer convolutional neural network (CNN), and the parameter configuration of each layer includes:
[0096] The first CNN layer has a Max_len parameter configured to be 20, a hidden_dim hidden layer configured to be 30, a kernel_size parameter configured to be 2, and a bias parameter configured to be True. The first neural network layer uses average pooling operation, and then proceeds to the second layer.
[0097] The second CNN layer has a Max_len parameter of 30, a hidden_dim parameter of 60, a kernel_size parameter of 2, a bias parameter of True, a stride parameter of None, a padding parameter of 0, a ceil_mode parameter of False, and a count_include_pad parameter of True. The second neural network uses max pooling. After the operation is completed, the third layer is entered.
[0098] The third CNN layer has a Max_len parameter of 60, a hidden_dim parameter of 100, a kernel_size parameter of 2, a bias parameter of True, a stride parameter of None, a padding parameter of 0, a ceil_mode parameter of False, and a count_include_pad parameter of True. The third neural network uses max pooling. After the operation is completed, the fourth layer is entered.
[0099] The fourth CNN layer has a Max_len parameter set to 100, a hidden_dim parameter set to 140, a kernel_size parameter set to 2, a bias parameter set to True, a stride parameter set to None, a padding parameter set to 0, a ceil_mode parameter set to False, and a count_include_pad parameter set to True. The fourth neural network layer uses max pooling. After the operation is completed, the fifth layer is introduced.
[0100] The fifth CNN layer has the following parameters: Max_len = 140, hidden_dim = 160, kernel_size = 2, bias = True, stride = None, padding = 0, ceil_mode = False, count_include_pad = True. The fourth neural network layer uses max pooling. After the operation is completed, the fifth layer is entered.
[0101] The sixth CNN layer has the following parameters: Max_len = 160, hidden_dim = 190, kernel_size = 2, bias = True, stride = None, padding = 0, ceil_mode = False, count_include_pad = True. The sixth CNN layer uses max pooling, and after the operation, the output data is regularized.
[0102] Preferably, the training module 202 performs a second processing on the D-Mini neural network model, including:
[0103] A sliding window operation is performed on the neural network of the D-Mini model to determine whether there are any anomalies in the values of each sliding window. If anomalies are found, the abnormal data is smoothed.
[0104] Preferably, the training module 202 performs a second processing on the D-Mini neural network model, including:
[0105] The output data of the D-Mini neural network model is rounded and decoded to obtain three-dimensional tensor data. The three-dimensional tensor data is then input into the Fast-R-CNN model to complete the training of the model and obtain the target image detection model.
[0106] The specific implementation process of the functions implemented by each module in this embodiment 2 is the same as the implementation process of each step in embodiment 1, and will not be repeated here.
[0107] The above description is only a preferred embodiment of the present invention and does not limit the patent scope of the present invention. All equivalent structural transformations made under the concept of the present invention using the contents of the present invention specification and drawings, or direct / indirect applications in other related technical fields, are included within the patent protection scope of the present invention.
Claims
1. A lightweight target image detection method based on deep learning, characterized in that, The method includes the following steps: S1: Collect sample data, perform a first process on the sample data, and obtain the model training dataset; S2: Construct a D-Mini neural network model, input the data in the model training dataset into the D-Mini neural network model, perform a second processing on the D-Mini neural network model to obtain a target image detection model, wherein the D-Mini neural network model is composed of a 6-layer convolutional neural network CNN; S3: Input the image data to be identified into the target image detection model, detect and output the recognition result; The D-Mini neural network model consists of a 6-layer convolutional neural network (CNN), and the parameter configurations of each layer include: The first CNN layer has a Max_len parameter configured to be 20, a hidden_dim hidden layer configured to be 30, a kernel_size parameter configured to be 2, and a bias parameter configured to be True. The first neural network layer uses average pooling operation, and then proceeds to the second layer. The second CNN layer has a Max_len parameter set to 30, a hidden_dim parameter set to 60, a kernel_size parameter set to 2, a bias parameter set to True, a stride parameter set to None, a padding parameter set to 0, a ceil_mode parameter set to False, and a count_include_pad parameter set to True. The second neural network layer uses max pooling. After the operation is completed, the third layer is entered. The third CNN layer has a Max_len parameter set to 60, a hidden_dim parameter set to 100, a kernel_size parameter set to 2, a bias parameter set to True, a stride parameter set to None, a padding parameter set to 0, a ceil_mode parameter set to False, and a count_include_pad parameter set to True. The third neural network layer uses max pooling. After the operation is completed, the fourth layer is entered. The fourth CNN layer has a Max_len parameter set to 100, a hidden_dim hidden layer set to 140, a kernel_size parameter set to 2, a bias parameter set to True, a stride parameter set to None, a padding parameter set to 0, a ceil_mode parameter set to False, and a count_include_pad parameter set to True. The fourth neural network layer uses max pooling. After the operation is completed, the fifth layer is introduced. The fifth CNN layer has the following parameters: Max_len = 140, hidden_dim = 160, kernel_size = 2, bias = True, stride = None, padding = 0, ceil_mode = False, count_include_pad = True. The fourth neural network layer uses max pooling. After the operation is completed, the fifth layer is entered. The sixth CNN layer has the following parameters: Max_len = 160, hidden_dim = 190, kernel_size = 2, bias = True, stride = None, padding = 0, ceil_mode = False, count_include_pad = True. The sixth CNN layer uses max pooling, and after the operation, the output data is regularized.
2. The method according to claim 1, characterized in that, The collected sample data undergoes a first processing step to obtain the model training dataset, which includes: The sample data is compressed to obtain a three-dimensional tensor dataset, which is a list dataset composed of three two-dimensional tensors. The three-dimensional tensor dataset is subjected to data encoding and transformation processing, namely pooling and dimensionality reduction, to obtain a model training dataset in two-dimensional tensor form.
3. The method according to claim 1, characterized in that, The second processing of the D-Mini neural network model includes: A sliding window operation is performed on the neural network of the D-Mini model to determine whether there are any anomalies in the values of each sliding window. If anomalies are found, the abnormal data is smoothed.
4. The method according to claim 3, characterized in that, The second processing of the D-Mini neural network model includes: The output data of the D-Mini neural network model is rounded and decoded to obtain three-dimensional tensor data. The three-dimensional tensor data is then input into the Fast-R-CNN model to complete the training of the model and obtain the target image detection model.
5. A lightweight target image detection device based on deep learning, characterized in that, The device includes: The processing module is used to collect sample data, perform a first processing on the sample data, and obtain a model training dataset; The training module is used to construct a D-Mini neural network model, input the data in the model training dataset into the D-Mini neural network model, perform a second processing on the D-Mini neural network model to obtain a target image detection model, wherein the D-Mini neural network model is composed of a 6-layer convolutional neural network CNN; The recognition module is used to input the image data to be recognized into the target image detection model, detect it, and output the recognition result; The training module constructs a D-Mini neural network model, which consists of a 6-layer convolutional neural network (CNN). The parameter configurations for each layer include: The first CNN layer has a Max_len parameter configured to be 20, a hidden_dim hidden layer configured to be 30, a kernel_size parameter configured to be 2, and a bias parameter configured to be True. The first neural network layer uses average pooling operation, and then proceeds to the second layer. The second CNN layer has a Max_len parameter set to 30, a hidden_dim parameter set to 60, a kernel_size parameter set to 2, a bias parameter set to True, a stride parameter set to None, a padding parameter set to 0, a ceil_mode parameter set to False, and a count_include_pad parameter set to True. The second neural network layer uses max pooling. After the operation is completed, the third layer is entered. The third CNN layer has a Max_len parameter set to 60, a hidden_dim parameter set to 100, a kernel_size parameter set to 2, a bias parameter set to True, a stride parameter set to None, a padding parameter set to 0, a ceil_mode parameter set to False, and a count_include_pad parameter set to True. The third neural network layer uses max pooling. After the operation is completed, the fourth layer is entered. The fourth CNN layer has a Max_len parameter set to 100, a hidden_dim hidden layer set to 140, a kernel_size parameter set to 2, a bias parameter set to True, a stride parameter set to None, a padding parameter set to 0, a ceil_mode parameter set to False, and a count_include_pad parameter set to True. The fourth neural network layer uses max pooling. After the operation is completed, the fifth layer is introduced. The fifth CNN layer has the following parameters: Max_len = 140, hidden_dim = 160, kernel_size = 2, bias = True, stride = None, padding = 0, ceil_mode = False, count_include_pad = True. The fourth neural network layer uses max pooling. After the operation is completed, the fifth layer is entered. The sixth CNN layer has the following parameters: Max_len = 160, hidden_dim = 190, kernel_size = 2, bias = True, stride = None, padding = 0, ceil_mode = False, count_include_pad = True. The sixth CNN layer uses max pooling, and after the operation, the output data is regularized.
6. The apparatus according to claim 5, characterized in that, The processing module collects sample data and performs a first processing on the sample data to obtain a model training dataset, including: The sample data is compressed to obtain a three-dimensional tensor dataset, which is a list dataset composed of three two-dimensional tensors. The three-dimensional tensor dataset is subjected to data encoding and transformation processing, namely pooling and dimensionality reduction, to obtain a model training dataset in two-dimensional tensor form.
7. The apparatus according to claim 5, characterized in that, The training module performs a second processing on the D-Mini neural network model, including: A sliding window operation is performed on the neural network of the D-Mini model to determine whether there are any anomalies in the values of each sliding window. If anomalies are found, the abnormal data is smoothed.
8. The apparatus according to claim 7, characterized in that, The training module performs a second processing on the D-Mini neural network model, including: The output data of the D-Mini neural network model is rounded and decoded to obtain three-dimensional tensor data. The three-dimensional tensor data is then input into the Fast-R-CNN model to complete the training of the model and obtain the target image detection model.