Computer vision target detection fruit recognition system based on MobileNet and DETR

Through the deep integration of MobileNet and DETR, the existing fruit recognition technology solves the problems of low accuracy and high computational complexity in detecting small and dense targets, achieving efficient and accurate fruit recognition, which is suitable for real-time detection and resource-constrained environments. application.

CN118629031APending Publication Date: 2024-09-10QINGDAO UNIV
View PDF 0 Cites 5 Cited by

Patent Information

Application Number
CN202410807174.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-21
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

Existing fruit recognition technology has low accuracy when detecting small and dense targets in complex scenes, is prone to missed detection or misdetection, has high computational complexity, low efficiency, and complex model structure, making it unsuitable for real-time detection and resource-constrained environments. application.

Method used

Using the deep fusion of MobileNet and DETR, feature extraction is performed through MobileNet and DETR's self-attention mechanism is used for target detection, simplifying post-processing steps, achieving end-to-end target detection, and reducing computational complexity and resource requirements.

Benefits of technology

It improves the detection performance of small targets and dense targets, simplifies the model structure, achieves efficient fruit recognition, is suitable for real-time detection and applications in resource-constrained environments, and improves the overall efficiency and recognition accuracy of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118629031A
    Figure CN118629031A
Patent Text Reader

Abstract

The invention belongs to the technical field of computer vision, and relates to a computer vision target detection fruit recognition system based on MobileNet and DETR, the MobileNet is adopted as a feature extraction network, the model parameter quantity and the calculation quantity are greatly reduced through depth separable convolution, and it is ensured that the system efficiently runs in a resource limited environment; the self-attention mechanism of DETR is utilized to effectively model the long-distance dependency relationship in the image, and the detection performance of small targets and dense targets is improved; besides, end-to-end target detection is realized by utilizing DETR, complex post-processing steps of traditional target detection are simplified, the overall efficiency of the system is improved, and efficient feature extraction and target detection are realized; aiming at the specific requirements of fruit identification, the model is optimized and adjusted, so that the model achieves the optimal performance in fruit classification and detection, high precision and high efficiency are ensured, and the method can be widely applied to various scenes in a diversified manner; the whole technological process is simple, the principle is reliable, fruit recognition and detection are accurate, and real-time response is fast.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of computer vision and relates to a computer vision target detection fruit recognition system based on MobileNet and DETR. Through the deep fusion of MobileNet and DETR, different types of fruits can be efficiently and accurately recognized and judged in a variety of environments. Background Art

[0002] With the rapid development of computer vision technology, target detection has gradually been able to be maturely applied in various fields. The popularization of automation has made fruit recognition and detection play a key role in agricultural production and the food industry. The automatic recognition and classification of fruits using image information can not only improve production efficiency, but also ensure the quality and safety of fruits. Traditional fruit recognition methods mainly design algorithms based on features such as shape, size, color and texture. These methods perform well in specific controlled environments. However, under natural conditions, due to the complexity and variability of lighting, occlusion and background, the difficulty of recognition increases significantly, making it difficult for existing technologies to meet the needs of practical applications. In addition, existing fruit recognition methods and systems have high computational complexity, low efficiency and complex structure, making it difficult to adapt to the actual application needs of automation.

[0003] In the prior art, Chinese patent CN114663769B discloses a fruit recognition method based on YOLO v5, which combines SKnet with the residual module to design a new module to replace the residual module in YOLO v5, and uses dilated convolution to reduce the complexity of the model, thereby realizing automatic recognition of fruits in supermarkets. The clustering analysis of the prediction box in this method enables the model to better predict the shape of fruits; the improved YOLOv5 feature extraction network extracts features for most fruits on the market, and assigns different feature weights to different channels, reducing the loss of important features during the transmission process and improving the recognition rate of fruits.

[0004] Chinese patent CN115294507B discloses a method for dynamic video data recognition based on fruit shape, which relates to the field of computer vision. The specific steps of the method are as follows: the first step is to form a recognition system with a high-definition camera, high-speed memory, GPU, motherboard and memory, and the wired network or 5G communication module connects the recognition system to a cloud computer; the second step is to form a concave rolling assembly line with rollers, and the high-definition cameras are separated on both sides of the concave rolling assembly line, collect the video of the fruit rolling on the concave rolling assembly line, transmit the video to the cloud computer, and number the fruits appearing in the video one by one; the third step is to give the three-dimensional image of the fruit the size of the real fruit; the fourth step is to generate a QR code based on the appearance information of the fruit, paste it on the fruit, and classify the fruit by grade. Although the YOLO used in the above two patents has the advantage of high speed and is suitable for real-time detection applications, its performance is insufficient when detecting small targets and dense targets. Its single-stage architecture divides the entire image into fixed grids, each of which predicts only a small number of bounding boxes, which can easily lead to missed or false detections in complex scenes, especially in the case of small and dense objects. In addition, the accuracy of the model is relatively poor, making it difficult to accurately identify multiple types of fine objects.

[0005] Chinese patent CN109784204A discloses a method for identifying and extracting the main stalk of stacked string fruits for parallel robots, which relates to the field of computer vision. The method constructs a stereoscopic vision detection system for such fruits based on Kinect sensors, obtains three-dimensional visual information, constructs a data set, and increases its distribution range through image processing methods. A convolutional neural network is constructed to increase the feature quantity. The existing Faster R-CNN is improved based on the constructed CNN architecture, and a coarse-to-fine and parameter sharing strategy is designed to realize the cascade of Faster R-CNN to reduce background interference. A multi-transfer learning training strategy is designed to train the network until the accuracy meets the standard, and the trained coarse-to-fine cascade Faster R-CNN that meets the test accuracy requirements is used to realize the online main stalk recognition and extraction of stacked string fruits in the parallel robot fruit sorting system, and improve the accuracy and efficiency of recognition and extraction, laying a foundation for the parallel robot based on stereo vision to realize accurate, fast, and non-destructive automatic sorting of stacked string fruits.

[0006] Chinese patent CN110348514A discloses a jade identification method and device based on the Faster R-CNN model, the method comprising: obtaining an image to be identified containing jade; using a pre-trained Faster R-CNN model to identify the style category of jade in the image to be identified. The embodiment of the present invention is applied to the pre-trained Faster R-CNN model for jade identification. When identifying, it is only necessary to use the image to be identified containing jade. Compared with the prior art that requires users to master certain jade identification knowledge, the embodiment of the present invention does not require users to master any jade identification knowledge, and solves the technical problem that many users in the prior art cannot accurately identify the style category of jade. The Faster R-CNN model used in the above two patents performs well in detection accuracy, but it requires multiple convolution operations in the generation of candidate regions and classification stages, which increases the computing time and resource consumption, has high computational complexity, and is slow, which is not suitable for real-time detection applications; and its model structure is complex, and it is difficult to deploy on devices with limited computing resources, which is not conducive to diversified promotion and application.

[0007] The above-mentioned prior art has problems such as low accuracy in detecting small and dense targets, easy missed detection or false detection in complex scenes, high computational complexity, low efficiency, and complex models. After searching and analyzing by the inventor, the inventor has not disclosed a fruit recognition system that can efficiently and accurately identify and judge different types of fruits in a variety of environments by deeply integrating MobileNet and DETR. Therefore, inventing a computer vision target detection fruit recognition system based on MobileNet and DETR can improve the shortcomings of the prior art, achieve high-precision and high-efficiency fruit recognition, improve the detection performance of small and dense targets, simplify the model structure, and adapt to the real-time detection requirements and resource-constrained environments. Summary of the invention

[0008] The purpose of the present invention is to overcome the shortcomings of the prior art. Based on the improvement of the prior art, a fruit recognition system is designed to provide a deep fusion of MobileNet and DETR, which can efficiently and accurately identify and judge different types of fruits in a variety of environments, and in particular, a computer vision target detection fruit recognition system based on MobileNet and DETR, which solves the problems of low accuracy in the prior art for small and dense target detection, easy missed detection or false detection in complex scenes, high computational complexity, low efficiency, and complex model.

[0009] In order to achieve the above-mentioned purpose, the present invention provides a computer vision target detection and fruit recognition system based on MobileNet and DETR, including an image input device, a fruit recognition method and an output device. The image input device is a device that can capture and transmit pictures, videos, and images, and the output device can output results and perform visual display.

[0010] Wherein, the fruit identification method comprises the following steps:

[0011] S1: Feature extraction model training: collect training images and form a training data set, process the training images and use them for MobileNet model training to obtain a feature extraction model;

[0012] S2: Input image preprocessing: Scale the input image to 224x224 pixels, normalize it to the range [0,1], and use TensorFlow Lite's image preprocessing library to perform real-time preprocessing on the input image;

[0013] S3: Input feature extraction: Input the preprocessed input image into the feature extraction model, extract feature information of the input image and output a high-dimensional feature map;

[0014] S4: Object detection: The feature map output by the feature extraction model is input into the DETR model for position encoding. The DETR model performs global feature modeling on the feature map through the self-attention mechanism and outputs the fruit category and bounding box coordinates.

[0015] S5: Output data processing: Apply confidence threshold to filter low confidence output data, and use non-maximum suppression to remove redundant bounding boxes;

[0016] S6: Final data output: The processed fruit categories and bounding boxes are displayed on the output device in real time.

[0017] In the fruit identification method according to the present invention, step S1 specifically comprises the following steps:

[0018] S11: Collect training images: collect different types of fruit images as training images through image input devices and the Internet, and annotate the training image environment, category, number, and bounding box information to form a training data set;

[0019] S12: Processing training images: Use data augmentation techniques such as rotation, flipping, random scaling, random cropping, random arrangement, and color adjustment to process the training images to enrich the background of the object to be detected;

[0020] S13: The processed training images are put into the MobileNet model for training until the results gradually converge and no longer increase, thereby obtaining a trained feature extraction model.

[0021] The types of fruits described in step S11 include eight or more of the following: apple, pear, grape, red grape, date, citrus, pomelo, peach, watermelon, apricot, melon, cantaloupe, lychee, sugarcane, persimmon, lemon, banana, mango, pineapple, cantaloupe, plum, pomegranate, wolfberry, hawthorn, coconut, mulberry, water chestnut, grapefruit, strawberry, tangerine, papaya, orange, cherry tomato, longan, cucumber, loquat, mangosteen, rambutan, fig, brown, star fruit, ginseng fruit, kiwi, guava, bayberry, ebony, blueberry, prune, sugar apple, hundred flower fruit, yellow peel, cherry, yacon, durian, dragon fruit, guava, jackfruit, passion fruit, monk fruit, and wax apple.

[0022] The MobileNet model in step S12 is a MobileNet V2 model.

[0023] In step S13, the feature size of the input training image can be expressed as:

[0024] D F ×D F ×M

[0025] Where D F It is the length and width unit representing pixels in the image space. M represents the number of channels of the image. It is commonly divided into three channels of RGB according to the color space.

[0026] In the fruit identification method according to the present invention, step S3 specifically comprises the following steps:

[0027] S31: Apply the filter to the input image or feature map through a sliding window for convolution to generate a feature map; for the input image I and the filter K, the output O of the convolution operation is defined as:

[0028] O(i,j)=I(i+m,j+n)·K(m,n)

[0029] mn

[0030] Where i and j are the coordinates of the output image, and m and n are the coordinates of the filter;

[0031] S32: Through depth convolution and point-by-point convolution, convolution operations are applied to each input channel separately, and the output of depth convolution is linearly combined between channels using 1x1 convolution; for input feature map I and depth convolution filter K dw And the point-by-point convolution filter K pw , the output O of the depthwise separable convolution can be obtained by the following two steps:

[0032] O dw (i,j,k)=I(i+m,j+n,k)·K(m,n,k)

[0033] mn

[0034] Where k is the channel index, O dw is the intermediate output of the depthwise convolution;

[0035] O(i,j,l)= k O dw (i,j,k)·K pw (1,1,k,l)

[0036] Where l is the output channel index of the point-by-point convolution;

[0037] S33: Average pooling is performed on the feature map by applying a sliding window on the input feature map to calculate the average of all values ​​in the window, thereby reducing the size of the feature map; for the input feature map I and the window size is p×p, the output feature map O is defined as:

[0038]

[0039] S34: Use a fully connected layer for output, and its output O is defined as:

[0040] O=W·I+b

[0041] Where W is the weight matrix, I is the input vector, and b is the bias vector;

[0042] S35: Using the SoftMax activation function, after exponential operation, sum normalization, and probability calculation, the input vector is converted into a probability distribution so that the value of each element is between 0 and 1 and the sum is 1. For the input vector z, the output σ(z) of the SoftMax function is defined as:

[0043]

[0044] Where n is the dimension of the input vector.

[0045] The specific steps of the convolution operation in step S31 are as follows:

[0046] S31-1: Filter initialization: define a 3x3 or 5x5 filter;

[0047] S31-2: Sliding window: Slide the filter on the input image, starting from the upper left corner, and perform dot product operations point by point;

[0048] S31-3: Calculate eigenvalues: accumulate the dot product results of the filters to obtain the eigenvalues ​​of the corresponding positions;

[0049] S31-4: Generate feature map: Repeat the above steps until the filter covers the entire input image and generates a feature map.

[0050] The specific steps of the average pooling operation in step S33 are as follows:

[0051] S33-1: Window partitioning: Divide the input feature map into non-overlapping or overlapping sub-regions according to the stride;

[0052] S33-2: Calculate the average value: calculate the average value for each sub-region;

[0053] S33-3: Generate downsampled graph: Use the average value to form a new downsampled feature graph.

[0054] In the fruit identification method according to the present invention, step S4 specifically comprises the following steps:

[0055] S41: Process the feature map through the Transformer encoder-decoder;

[0056] S42: Define M query embedding vectors Q: Q = [q1, q2, ..., q M ], each query embedding vector q1 is a learnable vector of fixed dimension, M query embedding vectors are initialized, and the query embedding vectors are optimized by back propagation during the training process;

[0057] S43: The query embedding is used as one of the inputs of the decoder and processed together with the encoded features to generate the final detection result.

[0058] The specific steps of the Transformer encoder-decoder processing in step S41 are as follows:

[0059] S41-1: Perform multi-head self-attention operation on the input sequence. Each head independently calculates the attention weight and combines the results. The self-attention mechanism is calculated through the query, key, and value matrices:

[0060]

[0061] Where Q, K, and V are the query, key, and value matrices after the input features are linearly transformed, respectively. k is the dimension of the key, K T is the transpose operation of the key-value matrix;

[0062] S41-2: Perform residual connection and normalization on self-attention output and input features:

[0063] E l =LayerNorm(F'+MHSA(F'))

[0064] Where F' is the input feature with position encoding, E lis the output of layer l;

[0065] S41-3: Perform feedforward neural network transformation on the normalized features, which includes two linear layers and a nonlinear activation function. The feedforward neural network formula is:

[0066] FFN(x)=ReLU(W1+b1)W2+b2

[0067] Where W and b are weight and bias constants, and ReLU is the activation function;

[0068] S41-4: The encoder is stacked in multiple layers, and each layer is processed in turn and outputs a new feature representation.

[0069] The image input device involved in the present invention is one of a camera and a scanner, and the output device is a mobile device, a PC, and a web terminal. Visualization is achieved by using an IP camera program of a mobile device or a PyCharm-Py Qt5 library in Python on a PC.

[0070] The present invention adopts MobileNet as the feature extraction network, and greatly reduces the number of model parameters and calculations through deep separable convolution, ensuring that the system runs efficiently in a resource-constrained environment; and utilizes the self-attention mechanism of DETR to effectively model long-distance dependencies in the image, thereby improving the detection performance of small targets and dense targets; in addition, DETR realizes end-to-end target detection, simplifies the complex post-processing steps of traditional target detection, improves the overall efficiency of the system, and realizes efficient feature extraction and target detection.

[0071] Compared with the prior art, the present invention has the following advantages: (1) The present invention adopts MobileNet as the feature extraction network, and greatly reduces the model parameters and calculation amount through deep separable convolution, ensuring that the system can run efficiently on mobile devices and embedded systems; (2) DETR is used for target detection, and the long-distance dependency in the image is effectively modeled through the self-attention mechanism, thereby improving the detection performance of small targets and dense targets; (3) DETR simplifies the complex post-processing steps of traditional target detection, such as non-maximum suppression (NMS), to achieve end-to-end target detection. Through the combination of MobileNet and DETR, the model training process and reasoning steps are simplified, and the overall efficiency of the system is improved; (4) According to the specific needs of fruit recognition, the model is optimized and adjusted to achieve the best performance in fruit classification and detection, ensuring high precision and high efficiency, and can be widely used in various scenarios; its overall process is simple, the principle is reliable, the fruit recognition and detection is accurate, the real-time response is fast, the robustness is good, the application range is wide, and it is environmentally friendly. BRIEF DESCRIPTION OF THE DRAWINGS

[0072] Figure 1The invention discloses a flow chart showing the working principle of the fruit identification method. DETAILED DESCRIPTION

[0073] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and specific embodiments.

[0074] Embodiment 1:

[0075] like Figure 1 As shown, this embodiment relates to a computer vision target detection and fruit recognition system based on MobileNet and DETR, including an image input device, a fruit recognition method and an output device. The image input device is a device that can capture and transmit pictures, videos, and images, and the output device can output results and perform visual display.

[0076] Wherein, the fruit identification method comprises the following steps:

[0077] S1: Feature extraction model training: collect training images and form a training data set, process the training images and use them for MobileNet model training to obtain a feature extraction model;

[0078] S2: Input image preprocessing: Scale the input image to 224x224 pixels, normalize it to the range [0,1], and use TensorFlow Lite's image preprocessing library to perform real-time preprocessing on the input image;

[0079] S3: Input feature extraction: Input the preprocessed input image into the feature extraction model, extract feature information of the input image and output a high-dimensional feature map;

[0080] S4: Object detection: The feature map output by the feature extraction model is input into the DETR model for position encoding. The DETR model performs global feature modeling on the feature map through the self-attention mechanism and outputs the fruit category and bounding box coordinates.

[0081] S5: Output data processing: Apply confidence threshold to filter low confidence output data, and use non-maximum suppression to remove redundant bounding boxes;

[0082] S6: Final data output: The processed fruit categories and bounding boxes are displayed on the output device in real time.

[0083] In the fruit identification method involved in this embodiment, step S1 specifically includes the following steps:

[0084] S11: Collect training images: collect different types of fruit images as training images through image input devices and the Internet, and annotate the training image environment, category, number, and bounding box information to form a training data set;

[0085] S12: Processing training images: Use data augmentation techniques such as rotation, flipping, random scaling, random cropping, random arrangement, and color adjustment to process the training images to enrich the background of the object to be detected;

[0086] S13: The processed training images are put into the MobileNet model for training until the results gradually converge and no longer increase, thereby obtaining a trained feature extraction model.

[0087] The types of fruits described in step S11 include eight or more of the following: apple, pear, grape, red grape, date, citrus, pomelo, peach, watermelon, apricot, melon, cantaloupe, lychee, sugarcane, persimmon, lemon, banana, mango, pineapple, cantaloupe, plum, pomegranate, wolfberry, hawthorn, coconut, mulberry, water chestnut, grapefruit, strawberry, tangerine, papaya, orange, cherry tomato, longan, cucumber, loquat, mangosteen, rambutan, fig, brown, star fruit, ginseng fruit, kiwi, guava, bayberry, ebony, blueberry, prune, sugar apple, hundred flower fruit, yellow peel, cherry, yacon, durian, dragon fruit, guava, jackfruit, passion fruit, monk fruit, and wax apple.

[0088] The MobileNet model in step S12 is a MobileNet V2 model.

[0089] In step S13, the feature size of the input training image can be expressed as:

[0090] D F ×D F ×M

[0091] Where D F It is the length and width unit representing pixels in the image space. M represents the number of channels of the image. It is commonly divided into three channels of RGB according to the color space.

[0092] In the fruit identification method involved in this embodiment, step S3 specifically includes the following steps:

[0093] S31: Apply the filter to the input image or feature map through a sliding window for convolution to generate a feature map; for the input image I and the filter K, the output O of the convolution operation is defined as:

[0094] O(i,j)=I(i+m,j+n)·K(m,n)

[0095] mn

[0096] Where i and j are the coordinates of the output image, and m and n are the coordinates of the filter;

[0097] S32: Through depth convolution and point-by-point convolution, convolution operations are applied to each input channel separately, and the output of depth convolution is linearly combined between channels using 1x1 convolution; for input feature map I and depth convolution filter K dw And the point-by-point convolution filter K pw , the output O of the depthwise separable convolution can be obtained by the following two steps:

[0098] O dw (i,j,k)=I(i+m,j+n,k)·K(m,n,k)

[0099] mn

[0100] Where k is the channel index, O dw is the intermediate output of the depthwise convolution;

[0101] O(i,j,l)= k O dw (i,j,k)·K pw (1,1,k,l)

[0102] Where l is the output channel index of the point-by-point convolution;

[0103] S33: Average pooling is performed on the feature map by applying a sliding window on the input feature map to calculate the average of all values ​​in the window, thereby reducing the size of the feature map; for the input feature map I and the window size is p×p, the output feature map O is defined as:

[0104]

[0105] S34: Use a fully connected layer for output, and its output O is defined as:

[0106] O=W·I+b

[0107] Where W is the weight matrix, I is the input vector, and b is the bias vector;

[0108] S35: Using the SoftMax activation function, after exponential operation, sum normalization, and probability calculation, the input vector is converted into a probability distribution so that the value of each element is between 0 and 1 and the sum is 1. For the input vector z, the output σ(z) of the SoftMax function is defined as:

[0109]

[0110] Where n is the dimension of the input vector.

[0111] The specific steps of the convolution operation in step S31 are as follows:

[0112] S31-1: Filter initialization: define a 3x3 or 5x5 filter;

[0113] S31-2: Sliding window: Slide the filter on the input image, starting from the upper left corner, and perform dot product operations point by point;

[0114] S31-3: Calculate eigenvalues: accumulate the dot product results of the filters to obtain the eigenvalues ​​of the corresponding positions;

[0115] S31-4: Generate feature map: Repeat the above steps until the filter covers the entire input image and generates a feature map.

[0116] The specific steps of the average pooling operation in step S33 are as follows:

[0117] S33-1: Window partitioning: Divide the input feature map into non-overlapping or overlapping sub-regions according to the stride;

[0118] S33-2: Calculate the average value: calculate the average value for each sub-region;

[0119] S33-3: Generate downsampled graph: Use the average value to form a new downsampled feature graph.

[0120] In the fruit identification method involved in this embodiment, step S4 specifically includes the following steps:

[0121] S41: Process the feature map through the Transformer encoder-decoder;

[0122] S42: Define M query embedding vectors Q: Q = [q1, q2, ..., q M ], each query embedding vector q1 is a learnable vector of fixed dimension, M query embedding vectors are initialized, and the query embedding vectors are optimized by back propagation during the training process;

[0123] S43: The query embedding is used as one of the inputs of the decoder and processed together with the encoded features to generate the final detection result.

[0124] The specific steps of the Transformer encoder-decoder processing in step S41 are as follows:

[0125] S41-1: Perform multi-head self-attention operation on the input sequence. Each head independently calculates the attention weight and combines the results. The self-attention mechanism is calculated through the query, key, and value matrices:

[0126]

[0127] Where Q, K, and V are the query, key, and value matrices after the input features are linearly transformed, respectively. k is the dimension of the key, K T is the transpose operation of the key-value matrix;

[0128] S41-2: Perform residual connection and normalization on self-attention output and input features:

[0129] E l =LayerNorm(F'+MHSA(F'))

[0130] Where F' is the input feature with position encoding, E l is the output of layer l;

[0131] S41-3: Perform feedforward neural network transformation on the normalized features, which includes two linear layers and a nonlinear activation function. The feedforward neural network formula is:

[0132] FFN(x)=ReLU(W1+b1)W2+b2

[0133] Where W and b are weight and bias constants, and ReLU is the activation function;

[0134] S41-4: The encoder is stacked in multiple layers, and each layer is processed in turn and outputs a new feature representation.

[0135] The image input device involved in this embodiment is a camera or a scanner, and the output device is a mobile device, a PC, or a web device. Visualization is achieved using the IP camera program of the mobile device or the PyCharm-PyQt5 library in Python on the PC.

[0136] The MobileNet V2 model involved in this embodiment consists of three parts, namely expansion convolution, depthwise separable convolution, and projection convolution, which are respectively composed of convolutional neural network (CNN), deep convolutional network (Dept h CNN), and the final average pooling and fully connected layers, which can convert the original image from graph to feature; the MobileNet model structure used to process the image is as follows:

[0137]

[0138]

[0139] This embodiment adopts the MobileNet V2 model structure as the convolutional neural network part, adds position encoding information, and fuses image data features as encoder input. After self-attention, normalization, and feedforward multi-layer encoders and self-attention, cross-attention, normalization, and feedforward multi-layer decoders are converted to obtain predicted attention heads with different attention levels. The recognition is determined according to the threshold. If recognized, the detection box is assigned and the result is output. If not recognized, no processing or labeling is performed.

[0140] The fruit identification system involved in this embodiment can run on low-cost hardware devices, significantly reducing the cost of computing resources and energy consumption, and reducing the expenditure of enterprises on hardware investment and maintenance; it can also improve the efficiency of fruit identification and classification, reduce the time and labor costs in the production process, and can work 24 hours a day without interruption, improve the work efficiency and production capacity of the production line, reduce the damage or waste of fruits caused by classification errors, improve resource utilization, and reduce the impact on the environment. The fruit identification system can be applied to the fruit industry in a diversified manner, such as automated orchard management, fruit maturity detection and pest and disease identification, improve agricultural production efficiency, and reduce labor costs; it can also be used in food processing and packaging processes to achieve classification and quality inspection of fruits on the assembly line to ensure food safety and quality.

[0141] Embodiment 2:

[0142] This embodiment provides an application of the fruit identification system based on Embodiment 1 on a mobile device.

[0143] The processor involved in this embodiment is a high-performance mobile processor, such as Qualcomm Snapdragon 8 series, with a memory size of at least 4GB RAM, the camera is a high-definition camera that supports 1080p video recording, the operating system is Android system or iOS system, and the development environment is TensorFlow Lite for MobileNet model and PyTorch Mobile for DETR model.

[0144] The workflow steps involved in this embodiment are:

[0145] S1: Feature extraction model training: Collect training images and form a training data set. After processing the training images, use them to train the MobileNet V2 model to obtain a feature extraction model.

[0146] S2: Input image preprocessing: Scale the input image to 224x224 pixels, normalize it to the range [0,1], and use TensorFlow Lite's image preprocessing library to perform real-time preprocessing on the input image;

[0147] S3: Input feature extraction: Input the preprocessed input image into the feature extraction model, extract feature information of the input image and output a high-dimensional feature map;

[0148] S4: Object detection: The feature map output by the feature extraction model is input into the DETR model for position encoding. The DETR model performs global feature modeling on the feature map through the self-attention mechanism and outputs the fruit category and bounding box coordinates.

[0149] S5: Output data processing: Apply confidence threshold to filter low confidence output data, and use non-maximum suppression to remove redundant bounding boxes;

[0150] S6: Final data output: The recognition results (fruit category and bounding box) are displayed in real time on the screen of the mobile device, and a simple user interface is provided to display the number and type of fruits detected, as well as the detection time, confidence level and location coordinates.

[0151] The system involved in this embodiment is applied to multiple mobile devices for testing to evaluate the real-time performance and accuracy of the system. The results show that the system can run in real time on high-performance mobile devices, and the recognition accuracy rate reaches more than 95%.

[0152] Embodiment 3:

[0153] This embodiment provides an application of the fruit identification system based on Embodiment 1 in an embedded device, which can be applicable to agricultural automation equipment.

[0154] The processor involved in this embodiment is an embedded processor, such as NVIDIA Jetson Nano, with a memory size of at least 2GB RAM, the camera is an industrial-grade camera that supports high-definition image acquisition, the operating system is embedded Linux, and the development environment is TensorFlow Lite and PyTorch.

[0155] The workflow steps involved in this embodiment are:

[0156] S1: Feature extraction model training: Collect a dataset of images of various fruits in the orchard, annotate the categories and bounding box information of the fruits, process the training images and use them for training the MobileNet V2 model to obtain a feature extraction model;

[0157] S2: Input image preprocessing: Scale the input image to 224x224 pixels and normalize it to the range [0,1] to implement an efficient image preprocessing algorithm on embedded devices;

[0158] S3: Input feature extraction: The preprocessed input image is input into the feature extraction model, feature information of the input image is extracted and a high-dimensional feature map is output; the feature extraction model is optimized to run efficiently on embedded devices;

[0159] S4: Object detection: The feature map output by the feature extraction model is input into the DETR model for position encoding. The DETR model performs global feature modeling on the feature map through the self-attention mechanism and outputs the fruit category and bounding box coordinates.

[0160] S5: Output data processing: Apply confidence threshold to filter low confidence output data, and use non-maximum suppression to remove redundant bounding boxes;

[0161] S6: Final data output: The recognition results (fruit category and bounding box) are displayed in real time on the screen of the mobile device, and a simple user interface is provided to display the number and type of detected fruits, as well as the detection time, confidence level and location coordinates; the recognition results are transmitted to an automated control system, such as a robotic arm, for automatic classification and processing of fruits. The system realizes automated orchard management through an interface with mechanical equipment.

[0162] The system involved in this embodiment was applied in an actual orchard environment for testing to evaluate the real-time performance and accuracy of the system. The results showed that the system can run efficiently on embedded devices, with a recognition accuracy rate of more than 93%, meeting the needs of automated orchard management.

[0163] Embodiment 4:

[0164] This embodiment provides an application based on the fruit identification system of Embodiment 1 and the combination of scene odor identification and a real-time odor release device, which is suitable for scenes where fruit odor needs to be released according to the surrounding environment.

[0165] The workflow steps involved in this embodiment are:

[0166] S1: Feature extraction model training: Collect a dataset of images of various fruits in the orchard, annotate the categories and bounding box information of the fruits, process the training images and use them for training the MobileNet V2 model to obtain a feature extraction model;

[0167] S2: Input image preprocessing: Scale the input image to 224x224 pixels and normalize it to the range [0,1] to implement an efficient image preprocessing algorithm on embedded devices;

[0168] S3: Input feature extraction: The preprocessed input image is input into the feature extraction model, feature information of the input image is extracted and a high-dimensional feature map is output; the feature extraction model is optimized to run efficiently on embedded devices;

[0169] S4: Object detection: The feature map output by the feature extraction model is input into the DETR model for position encoding. The DETR model performs global feature modeling on the feature map through the self-attention mechanism and outputs the fruit category and bounding box coordinates.

[0170] S5: Output data processing: Apply confidence threshold to filter low confidence output data, and use non-maximum suppression to remove redundant bounding boxes;

[0171] S6: Final data output: The recognition results (fruit categories and bounding boxes) are displayed on the screen of the output device in real time, and a simple user interface is provided to display the number and type of fruits detected;

[0172] S7: Odor release: Define the odor code according to the identified fruit category, use the Bluetooth transmission component to transmit the odor code signal to the terminal of the scene odor recognition and real-time odor release device, the terminal matches the transmitted odor code signal with its internal odor database, and selects the corresponding odor for release.

[0173] The scene odor recognition and real-time odor release device involved in this embodiment can perform recognition, signal reception and conversion, odor storage and release. Combined with the fruit recognition system in Example 1, it can achieve the effect of releasing corresponding odors in real time according to the fruit category.

Claims

1. A computer vision target detection and fruit recognition system based on MobileNet and DETR, characterized in that: The invention comprises an image input device, a fruit identification method and an output device. The image input device is a device capable of capturing and transmitting pictures, videos and images. The output device is capable of outputting results and performing visual display. The fruit identification method comprises the following steps: S1: Feature extraction model training: collect training images and form a training data set, process the training images and use them for MobileNet model training to obtain a feature extraction model; S2: Input image preprocessing: Scale the input image to 224x224 pixels, normalize it to the range [0,1], and use TensorFlow Lite's image preprocessing library to perform real-time preprocessing on the input image; S3: Input feature extraction: Input the preprocessed input image into the feature extraction model, extract feature information of the input image and output a high-dimensional feature map; S4: Object detection: The feature map output by the feature extraction model is input into the DETR model for position encoding. The DETR model performs global feature modeling on the feature map through the self-attention mechanism and outputs the fruit category and bounding box coordinates. S5: Output data processing: Apply confidence threshold to filter low confidence output data, and use non-maximum suppression to remove redundant bounding boxes; S6: Final data output: The processed fruit categories and bounding boxes are displayed on the output device in real time.

2. The computer vision target detection fruit recognition system based on MobileNet and DETR according to claim 1, characterized in that: The step S1 specifically includes the following steps: S11: Collect training images: collect different types of fruit images as training images through image input devices and the Internet, and annotate the training image environment, category, number, and bounding box information to form a training data set; S12: Processing training images: Use data augmentation techniques such as rotation, flipping, random scaling, random cropping, random arrangement, and color adjustment to process the training images to enrich the background of the object to be detected; S13: The processed training images are put into the MobileNet model for training until the results gradually converge and no longer increase, thereby obtaining a trained feature extraction model.

3. The computer vision target detection fruit recognition system based on MobileNet and DETR according to claim 2, characterized in that: The MobileNet model in step S12 is a MobileNet V2 model.

4. The computer vision target detection fruit recognition system based on MobileNet and DETR according to claim 2, characterized in that: In step S13, the characteristic size of the input training image can be expressed as: D F ×D F ×M Where D F It is the length and width unit representing pixels in the image space. M represents the number of channels of the image, which is commonly divided into three channels of RGB according to the color space.

5. The computer vision target detection fruit recognition system based on MobileNet and DETR according to claim 1, characterized in that: In the fruit identification method, step S3 specifically comprises the following steps: S31: Apply the filter to the input image or feature map through a sliding window for convolution to generate a feature map; for the input image I and the filter K, the output O of the convolution operation is defined as: O(i,j)=∑ m ∑ n I(i+m,j+n)·K(m,n) Where i and j are the coordinates of the output image, and m and n are the coordinates of the filter; S32: Through depth convolution and point-by-point convolution, convolution operations are applied to each input channel separately, and the output of depth convolution is linearly combined between channels using 1x1 convolution; for input feature map I and depth convolution filter K dw And the point-by-point convolution filter K pw , the output O of the depthwise separable convolution can be obtained by the following two steps: O dw (i,j,k)=∑ m ∑ n I(i+m,j+n,k)·K(m,n,k) Where k is the channel index, O dw is the intermediate output of the depthwise convolution; O(i,j,l)=∑ k O dw (i,j,k)·K pw (1,1,k,l) Where l is the output channel index of the point-by-point convolution; S33: Average pooling is performed on the feature map by applying a sliding window on the input feature map to calculate the average of all values ​​in the window, thereby reducing the size of the feature map; for the input feature map I and the window size is p×p, the output feature map O is defined as: S34: Use a fully connected layer for output, and its output O is defined as: O=W·I+b Where W is the weight matrix, I is the input vector, and b is the bias vector; S35: Using the SoftMax activation function, after exponential operation, sum normalization, and probability calculation, the input vector is converted into a probability distribution so that the value of each element is between 0 and 1 and the sum is 1. For the input vector z, the output σ(z) of the SoftMax function is defined as: Where n is the dimension of the input vector.

6. The computer vision target detection fruit recognition system based on MobileNet and DETR according to claim 5, characterized in that: The specific steps of the convolution operation in step S31 are as follows: S31-1: Filter initialization: define a 3x3 or 5x5 filter; S31-2: Sliding window: Slide the filter on the input image, starting from the upper left corner, and perform dot product operations point by point; S31-3: Calculate eigenvalues: accumulate the dot product results of the filters to obtain the eigenvalues ​​of the corresponding positions; S31-4: Generate feature map: Repeat the above steps until the filter covers the entire input image and generates a feature map.

7. The computer vision target detection fruit recognition system based on MobileNet and DETR according to claim 5, characterized in that: The specific steps of the average pooling operation in step S33 are as follows: S33-1: Window partitioning: Divide the input feature map into non-overlapping or overlapping sub-regions according to the stride; S33-2: Calculate the average value: calculate the average value for each sub-region; S33-3: Generate downsampled graph: Use the average value to form a new downsampled feature graph.

8. The computer vision target detection fruit recognition system based on MobileNet and DETR according to claim 1, characterized in that: In the fruit identification method, step S4 specifically comprises the following steps: S41: Process the feature map through the Transformer encoder-decoder; S42: Define M query embedding vectors Q: Q = [q1, q2, ..., q M ], each query embedding vector q1 is a learnable vector of fixed dimension, M query embedding vectors are initialized, and the query embedding vectors are optimized by back propagation during the training process; S43: The query embedding is used as one of the inputs of the decoder and processed together with the encoded features to generate the final detection result.

9. The computer vision target detection fruit recognition system based on MobileNet and DETR according to claim 8, characterized in that: The specific steps of the Transformer encoder-decoder processing in step S41 are as follows: S41-1: Perform multi-head self-attention operation on the input sequence. Each head independently calculates the attention weight and combines the results. The self-attention mechanism is calculated through the query, key, and value matrices: Where Q, K, and V are the query, key, and value matrices after the input features are linearly transformed, respectively. k is the dimension of the key, K T is the transpose operation of the key-value matrix; S41-2: Perform residual connection and normalization on self-attention output and input features: E l =LayerNorm(F'+MHSA(F')) Where F' is the input feature with position encoding, E l is the output of layer l; S41-3: Perform feedforward neural network transformation on the normalized features, which includes two linear layers and a nonlinear activation function. The feedforward neural network formula is: FFN(x)=ReLU(W1+b1)W2+b2 Where W and b are weight and bias constants, and ReLU is the activation function; S41-4: The encoder is stacked in multiple layers, and each layer is processed in turn and outputs a new feature representation.

10. The computer vision target detection and fruit recognition system based on MobileNet and DETR according to claim 5, characterized in that: The image input device is a camera or a scanner, and the output device is a mobile device, a PC, or a web device. Visualization is achieved using an IP camera program on a mobile device or a PyCharm-PyQt5 library in Python on a PC.

Citation Information

Cited By

  • Automatic driving 3D target detection method based on local feature coding and decoding

    CN119445536A

  • Automatic driving 3D target detection method based on local feature coding

    CN119445536B

  • Target detection error repair method based on decoupling DETR

    CN119516179A

  • Computer image processing system adopting intelligent identification technology

    CN120689572A

  • A computer image processing system using intelligent recognition technology

    CN120689572B