Light-weight crayfish quality rapid detection method based on pattern recognition
By improving the YOLOv8 network, combining robotic arms and industrial cameras to collect data and perform manual screening, the problems of low crayfish quality detection efficiency and large errors are solved, and more efficient and accurate crayfish detection is achieved, which is suitable for commercial processing needs.
Patent Information
- Application Number
- CN202411170327.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2024-12-17
AI Technical Summary
The quality detection efficiency of crayfish in the existing technology is low, the error is large, the model training cost is high, and it is not suitable for complex backgrounds. Although the recognition and classification accuracy of the EfficientNetB0 network under noise image processing is the best, it does not meet commercial needs, and the number of samples is small and not universal. sex.
Using the improved YOLOv8 network, the YOLOv8 backbone network is optimized through the PP-HGNetv2 model, the HGStem and deep convolution DWConv structure are introduced, and the HGBlock is improved using dynamic convolution and lightweight convolution, and the original loss function is replaced as the alphaIOU boundary loss function, combining the robotic arm and Industrial cameras collect and manually screen photography data, use LabelImg to label the data set and perform data enhancement.
It improves the detection accuracy of crayfish, lightens the network model, reduces the detection cost, is suitable for commercial processing needs, overcomes the problem of classification single-in-classification, and improves detection efficiency and accuracy.
Smart Images

Figure CN119152256A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of rapid detection of crayfish quality based on neural network, and in particular to a rapid detection method of lightweight crayfish quality based on pattern recognition. Background Art
[0002] As an important aquatic product, lobsters are sourced from both local farming and large quantities of imports from Southeast Asia. Primary processed products are mainly quick-frozen products, including quick-frozen shrimp tails, shrimp meat and whole limbs. For a long time, the freshness and defect detection of crayfish have mainly relied on manual methods, which are inefficient and have low error neural network accuracy. The market price of lobsters is significantly affected by freshness, so its quality inspection is particularly critical.
[0003] In the prior art, there is a model that improves the YOLOv4 neural network to predict whether crayfish is qualified or not. Although it has a high recognition rate under a single background, the data set is single, the training cost is high, the training efficiency is low, and the detection effect under a complex background is unknown. Subsequent improved technologies use an improved YOLOv5 neural network to predict the qualified and unqualified classification of crayfish. Although it has been improved on the basis of the aforementioned prior art, it has the defects of simple classification that cannot meet commercial needs, and the model training time is still long, the convergence is slow, the training cost is high, and the model size is large.
[0004] At present, by comparing the recognition and classification accuracy of four networks, EfficientNetB0, ResNet50, VGG16, and VGG19, on processed crayfish samples under three different noise image processing conditions, it is concluded that the EfficientNetB0 network has the best effect, which provides a means for grading the size characteristics of crayfish, but it does not meet the actual commercial processing needs, and the small number of samples makes it not universal. Summary of the invention
[0005] The purpose of the present invention is to provide a lightweight crayfish quality rapid detection method based on pattern recognition, which solves the problem that in the prior art, by comparing the recognition and classification accuracies of processed crayfish samples under three different noise image processing using four networks, EfficientNetB0, ResNet50, VGG16, and VGG19, it is concluded that the EfficientNetB0 network has the best effect, and a means is proposed for grading the size characteristics of crayfish, but it does not meet the actual commercial processing needs, and the number of samples is small and not universal.
[0006] To achieve the above object, the present invention provides a method for rapid quality detection of lightweight crayfish based on pattern recognition, comprising:
[0007] Take photos of crayfish and collect data to obtain images;
[0008] Manual screening of images of qualified quality;
[0009] Each picture is labeled and the improved YOLOv8 network is used for fast detection.
[0010] The steps for collecting crayfish photo data are as follows:
[0011] Using a robotic arm and an industrial camera, continuous photography is performed from above the crayfish. Different batches of crayfish are photographed and numbered.
[0012] Among them, the specific requirements for manually screening images of qualified quality are:
[0013] The image shows the five major types of appearance quality defects of crayfish, including fresh intact shrimp, fresh broken shrimp, dead intact shrimp, dead broken shrimp and detached limbs.
[0014] The specific method of labeling each picture and using the improved YOLOv8 network to achieve fast detection is as follows:
[0015] Use LabelImg to annotate the dataset, annotate each picture with a label, use a rectangular frame to frame the entire shrimp body, and export it as a txt file in yolo format. After exporting the yolo format file, use brightening, darkening, rotation, Gaussian blur, and salt and pepper methods to enhance the data.
[0016] Among them, the improved YOLOv8 network is specifically as follows:
[0017] The YOLOv8 backbone network is optimized and improved through the PP-HGNetv2 model, the HGBlock in the PP-HGNetV2 network is improved, the C2f module of the original neck network is improved with the RepNCSPELAN4 module, and the original loss function is replaced with the alphaIOU boundary loss function;
[0018] The specific requirements for optimizing and improving the YOLOv8 backbone network through the PP-HGNetv2 model are:
[0019] The PP-HGNetv2 model is used to design the YOLOv8 backbone network, and the HGStem and deep convolution DWConv structures are introduced to obtain a larger field of view and make the network have fewer parameters.
[0020] The specific requirements for improving HGBlock in the PP-HGNetV2 network are:
[0021] Use dynamic convolution blocks and lightweight convolutions to improve HGBlock in the PP-HGNetV2 network, obtain dynamic high-performance network modules, and then replace HGBlock;
[0022] The present invention discloses a lightweight crayfish quality rapid detection method based on pattern recognition. First, data of crayfish photos is collected. Then, images of qualified quality are screened manually, and each image is labeled. Rapid detection is achieved by using an improved YOLOv8 network. The crayfish detection accuracy is further improved by improving the YOLOv8 neural network. The network model is lightweight to make it more convenient to deploy, thereby improving detection efficiency and reducing the labor cost of manual detection. It is more in line with the commercial processing and classification needs of crayfish, overcomes the characteristics of the traditional single classification of crayfish, and makes it more in line with the commercial crayfish processing and grading needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.
[0024] Figure 1 It is a schematic diagram of the detection process of the present invention.
[0025] Figure 2 It is a schematic diagram of the classification method of the present invention.
[0026] Figure 3 It is a crayfish prediction classification flow chart of the present invention.
[0027] Figure 4 It is a schematic diagram of the detection of fresh death of crayfish of the present invention.
[0028] Figure 5 It is a structural diagram of the YOLOv8 improved network model of the present invention.
[0029] Figure 6 1 is a structural diagram of the HG-Block before and after the improvement of the present invention.
[0030] Figure 7 It is a structural diagram of RepNCSPELAN4 of the present invention.
[0031] Figure 8 It is a comparison diagram of the detection effect of the present invention. DETAILED DESCRIPTION
[0032] Embodiments of the present invention are described in detail below. Examples of the embodiments are shown in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, but should not be construed as limiting the present invention.
[0033] See also Figures 1 to 8 ,in, Figure 1 It is a schematic diagram of the detection process of the present invention, Figure 2 is a schematic diagram of the classification method of the present invention, Figure 3 is a crayfish prediction classification flow chart of the present invention, Figure 4 This is a schematic diagram of the detection of fresh death of crayfish of the present invention. Figure 5 It is the structure diagram of the YOLOv8 improved network model of the present invention, Figure 6 This is the HG-Block structure diagram before and after the improvement of the present invention. Figure 7 is the RepNCSPELAN4 structure diagram of the present invention, Figure 8 It is a comparison diagram of the detection effect of the present invention.
[0034] The present invention provides a method for rapid quality detection of lightweight crayfish based on pattern recognition, comprising:
[0035] Take photos of crayfish and collect data;
[0036] Manual screening of images of qualified quality;
[0037] Each picture is labeled and the improved YOLOv8 network is used for fast detection.
[0038] Furthermore, the steps for collecting crayfish photo data are as follows:
[0039] Using a robotic arm and an industrial camera, continuous shooting was performed from above the crayfish, with an image resolution of 1280×924 pixels and saved in JPG format. The video frame rate was 48 frames per second, and an image was extracted every 6 frames. A total of 4325 images were obtained and numbered.
[0040] Furthermore, the specific requirements for manually screening images of qualified quality are:
[0041] Since some images may be blurred due to the vibration of the camera, qualified images were manually screened out, and the images have the five major types of appearance quality defects of crayfish, including 1053 fresh whole shrimps, 1046 fresh broken shrimps, 1015 dead whole shrimps, 986 dead broken shrimps and 1500 detached limbs.
[0042] Furthermore, the specific method of annotating each image and using the improved YOLOv8 network to achieve fast detection is as follows:
[0043] Use LabelImg to annotate the dataset, annotate each picture with a label, use a rectangular frame to frame the entire shrimp body, and export it as a txt file in yolo format. After exporting the yolo format file, use brightening, darkening, rotation, Gaussian blur and pepper and salt methods to enhance the data, increase the complexity of the dataset, and improve the stability of the network under complex backgrounds.
[0044] Furthermore, the improved YOLOv8 network is as follows:
[0045] The YOLOv8 backbone network is optimized and improved through the PP-HGNetv2 model, the HGBlock in the PP-HGNetV2 network is improved, the C2f module of the original neck network is improved with the RepNCSPELAN4 module, and the original loss function is replaced with the alphaIOU boundary loss function;
[0046] The specific methods for optimizing and improving the YOLOv8 backbone network through the PP-HGNetv2 model are as follows:
[0047] The PP-HGNetv2 model is used to design the YOLOv8 backbone network, and the HGStem and deep convolution DWConv structures are introduced to obtain a larger field of view and make the network have fewer parameters.
[0048] Furthermore, the specific methods to improve HGBlock in the PP-HGNetV2 network are as follows:
[0049] Use dynamic convolution blocks (DynamicConv) and lightweight convolutions (GhostConv, RepConv) to improve HGBlock in the PP-HGNetV2 network, and obtain dynamic high-performance network modules (DynamicHGBlock), (RepHGBlock, GhostHGBlock) modules, and then replace HGBlock;
[0050] Dynamic convolution introduces a method based on the attention mechanism to dynamically aggregate multiple convolution kernels, so that the model can be adaptively adjusted according to the input features. Specifically, dynamic convolution does not improve performance by increasing the depth or width of the network, but uses multiple small convolution kernels in parallel in the same layer and combines these convolution kernels through attention weights. Although each dynamic convolution layer contains multiple convolution kernels, the additional computational cost is relatively low because the convolution kernel itself is small, so this dynamic aggregation method can still effectively enhance the representation ability of the network under limited computing resources. The traditional or static perceptron model is y=g(W T x+b), where W and b are weight matrices and bias vectors, respectively, g is the activation function, and the dynamic perceptron is constructed by combining multiple (K) linear functions to define;
[0051]
[0052] πk represents the kth linear function The attention weight, and the total weight and bias are all functions of the input x, and they share the same attention mechanism. In addition, the attention weights π k (x) is not fixed, but varies with the input x; it represents the optimal aggregation of the linear model for a particular input Therefore, the aggregated model is a nonlinear function, which makes the dynamic perceptron more expressive than the static perceptron;
[0053] Attention weight π in dynamic convolutional layer k (x) is calculated using the following formula:
[0054] π k (x)=softmax(FC(ReLU(FC(GAP(x)))))
[0055] In the above formula, GAP stands for global average pooling and FC stands for fully connected layer. The above formula processes the features after global average pooling through two layers of fully connected networks (with ReLU activation function in the middle), and then normalizes it through the softmax function to produce attention weights for weighted convolution kernels; compared with static perceptrons, dynamic perceptrons have the same number of output channels, but the model size is larger, and two additional calculations are introduced: Calculate the attention weight π k (x), and attention-based parameter aggregation and The additional computational cost of the above two items is much less than the computational Costs;
[0056] In the original design, HG-Block consists of two standard convolutional layers in series, supplemented by two lightweight convolution (LightConv) layers and a residual connection. The above configuration provides the network with basic feature extraction capabilities; in the improved design, dynamic convolution (DynamicConv) replaces the lightweight convolution layer in the original structure; compared with the convolution of the prior art, dynamic convolution can dynamically adjust the parameters of the filter according to the input features, so that the network can adapt to different data distributions and feature patterns. In DynamicConv, a Single-DynamicConv is included, which uses conditional convolution (CondConv2d) and a post-linear transformation (Linear) to adjust the convolution weights to provide targeted feature modulation, embeds Sigmoid linear unit (SiLU) as the activation function, and integrates two-dimensional batch normalization (BatchNorm 2d) to stabilize the training process. SiLU provides a smoother gradient flow than traditional ReLU, which helps to avoid the problem of gradient disappearance. Batch normalization standardizes the distribution of layer inputs, which helps to improve the learning speed and generalization ability of the network. This improvement achieves more efficient feature extraction and enhances the adaptability of the network, providing an effective method for processing complex feature extraction tasks, especially in ever-changing visual data.
[0057] Furthermore, the specific method of using the RepNCSPELAN4 module to improve the C2f module of the original neck network is as follows:
[0058] The network performance is improved by optimizing the information flow and parameter utilization. The input of the convolutional neural network structure passes through a convolutional layer (Conv1(c1, c3)), followed by a segmentation operation. This segmentation operation divides the feature map into two branches with a channel number of C / 2, one of which is directly passed, and the other branch enters a RepNCSP submodule (RepNCSP(c3 / 2, c4)), and the submodule further processes the information through a convolutional layer (Conv1(c4, c4)), and then concatenates the outputs of the two branches (Concat, c3=3*2+c4) and passes through a convolutional layer (Conv1 (c, c2)) to reduce the dimension; at the same time, the feature map in the RepNCSP module path passes through two convolutional layers (Conv1(c1, c_) and Conv2(c1, c_)) and then is input to the RepNBottleneck module. The RepNBottleneck module contains an expansion factor e to control the number of channels in the convolutional layer. Further convolutional layers (Conv3) and scale transformation operations ensure that the size and number of channels of the feature map are adapted to subsequent operations. In the subsequent RepConvN module, the feature map undergoes an optional shortcut connection. If a specific condition (If c1=c2 and shortcut is true), the features are enhanced by adding and merging. A combination of convolution operations is implemented inside the module. First, a convolution with a spatial resolution of 3x3 (Conv1(c1, c2)) is performed, followed by a 1x1 convolution (Conv1(c1, c2)) to optimize the computational efficiency of the network. Finally, through the above complex feature processing and optimization path, RepNCSPELAN4 can effectively learn features, thereby improving performance on specific tasks. The alphaIOU boundary loss function is used to replace the original loss function, thereby improving the network bounding box regression performance and lobster feature detection effect.
[0059] When using a rapid quality detection method for lightweight crayfish based on pattern recognition, the parameters are set as follows:
[0060]
[0061]
[0062] According to the results of the comparative test, YOLOv8n, YOLOv5n and the improved algorithm were selected to compare the detection effects on the crayfish industrial production line. Three scenarios were selected to identify single crayfish (Group A), easily confused (Group B) and dense crayfish (Group C) to visually verify the algorithm. The network model structure diagram was improved by combining YOLOv8. The YOLOv8 backbone network was improved by using the PP-HGNetv2 model to obtain a larger field of view while reducing the number of network parameters, and the alphaIOU boundary loss function was used to replace the original loss function. The HG-Block was improved by dynamic convolution (DynamicConv), so that the dynamic convolution can dynamically adjust the parameters of the filter according to the input features, so that the network can adapt to different data distributions and feature patterns, thereby improving the detection efficiency. The method of judging the life and death of crayfish by the intersection and union ratio of the crayfish head and tail positioning frame was combined with the existing technology to improve the yolov8 neural network to further improve the detection accuracy of crayfish, and the network model was lightweight to make it more convenient to deploy, thereby improving the detection efficiency, and reducing the labor cost of manual detection, which is more suitable for crayfish. The demand for commercial processing and classification of crayfish is overcome by overcoming the characteristics of the traditional single classification of crayfish, making it more in line with the needs of commercial crayfish processing and grading. Specifically, through the cooperation of a robotic arm and an industrial camera, continuous shooting is performed from above the crayfish, and the image resolution is 1280×924 pixels, saved in JPG format, and the video frame rate is 48 frames per second. An image is extracted every 6 frames, and a total of 4325 images are obtained and numbered. Because some graphics will be affected by the vibration of the camera and appear blurred, qualified images are manually screened out, and the images have the characteristics of crayfish. Five major types of appearance quality defects, combined with a schematic diagram of the grading method, include 1053 fresh intact shrimps, 1046 fresh damaged shrimps, 1015 dead intact shrimps, 986 dead damaged shrimps, and 1500 detached limbs, to facilitate the use of LabelImg to annotate the dataset. Each image is annotated with at least one label, and a rectangular frame is used to frame all parts of the shrimp body and export it as a txt file in yolo format; the data is enhanced using brightening, darkening, rotation, Gaussian blur, and pepper and salt methods to increase the complexity of the dataset and improve the stability of the network under complex backgrounds.
[0063] What is disclosed above is only one or more preferred embodiments of the present application, and cannot be used to limit the scope of rights of the present application. Ordinary technicians in this field can understand that all or part of the processes of implementing the above embodiments and equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A method for rapid detection of lightweight crayfish quality based on pattern recognition, characterized in that: The steps include: Take photos of crayfish and collect data to obtain images; Manual screening of images of qualified quality; Label each image and use the improved YOLOv8 network for fast detection.
2. The method for rapid detection of lightweight crayfish quality based on pattern recognition according to claim 1, characterized in that: The steps for collecting crayfish photo data are as follows: Using a robotic arm and an industrial camera, continuous photography is performed from above the crayfish. Different batches of crayfish are photographed and numbered.
3. The method for rapid detection of lightweight crayfish quality based on pattern recognition as claimed in claim 2, characterized in that: In the steps of manually screening images of qualified quality: The image shows the five major types of appearance quality defects of crayfish, including fresh intact shrimp, fresh broken shrimp, dead intact shrimp, dead broken shrimp and detached limbs.
4. The method for rapid detection of lightweight crayfish quality based on pattern recognition as claimed in claim 3, characterized in that: The specific steps for labeling each image and using the improved YOLOv8 network to achieve fast detection are as follows: Use LabelImg to annotate the dataset, annotate each image with a label, use a rectangular frame to frame the entire shrimp body, and export it to a txt file in yolo format; After exporting the YOLO format file, the data is enhanced by brightening, darkening, rotating, Gaussian blurring, and salt and pepper.
5. The method for rapid detection of lightweight crayfish quality based on pattern recognition as claimed in claim 4, characterized in that: Improve the YOLOv8 network specifically as follows: The YOLOv8 backbone network is optimized and improved through the PP-HGNetv2 model, the HGBlock in the PP-HGNetV2 network is improved, the C2f module of the original neck network is improved with the RepNCSPELAN4 module, and the original loss function is replaced with the alphaIOU boundary loss function; The specific way to optimize and improve the YOLOv8 backbone network through the PP-HGNetv2 model is: The PP-HGNetv2 model is used to design the YOLOv8 backbone network, and the HGStem and deep convolution DWConv structures are introduced to obtain a larger field of view and reduce the number of network parameters.
6. The method for rapid detection of lightweight crayfish quality based on pattern recognition as claimed in claim 5, characterized in that: The specific method to improve HGBlock in PP-HGNetV2 network is: Dynamic convolution blocks and lightweight convolutions are used to improve the HGBlock in the PP-HGNetV2 network to obtain a dynamic high-performance network module, which then replaces the HGBlock.
Citation Information
Cited By
Lightweight yarn defect detection method based on improved YOLOv8n network
CN119672027A
Low-illumination target detection method based on multi-dimensional attention mechanism
CN119832220A
A Low-Light Object Detection Method Based on Multi-Dimensional Attention Mechanism
CN119832220B
Water surface floating object identification and detection method, equipment and product
CN119888450A
