Method, device and equipment for fine-grained image classification of silkworms in grid cocoons
The VGG16 network optimized for image acquisition, segmentation and training are used to classify cocoons, which solves the problems of low efficiency and high miss selection rate of traditional cocoons, and realizes efficient automation and intelligence of the cocoon industry.
Patent Information
- Application Number
- CN202211265398.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-17
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2042-10-17
AI Technical Summary
In traditional methods, the classification efficiency of silk cocoons is low, the labor intensity is high, and the missed selection rate is high, which affects the quality of silk products. The existing deep learning methods are not suitable for silk cocoon classification.
The fine-grained image classification method of square cypress mulberry silkworms is used to collect, segment, construct the cocoon data set and train the full convolutional network FCN to optimize the VGG16 network for cocoon identification and classification.
The efficiency of cocoon sorting and industrial automation level have been improved, the missed selection rate has been reduced, and the accuracy and intelligence of cocoon classification have been improved.
Smart Images

Figure CN115601592B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a method, device and equipment for classifying fine-grained images of silkworms in a grid cocoon. Background Art
[0002] Silkworms are reeled to extract silk from cocoons, which are then processed into silk and related products. Due to differences in silkworm species, individual individuals, and the silkworm rearing environment, cocoons with yellow spots, rotten cocoons, oily cocoons, and thin skins may form. Reeling these cocoons can affect silk quality, increase the number of thread drops, increase the number of reeling breaks, or even prevent reeling, significantly impacting the quality of silk products.
[0003] In traditional technology, before reeling silk, yellow-spotted cocoons, rotten cocoons and other lower cocoons are mainly removed manually. This cocoon sorting method has high labor costs, and the accuracy of cocoon selection is easily affected by subjective factors such as the technical level and mental state of the personnel. It has disadvantages such as high labor intensity and high misselection rate, which seriously restricts the development of my country's mulberry silk and silk industry.
[0004] Currently, computer image processing technology and deep learning methods are gradually being applied to the field of silkworm cocoon quality inspection, but they are rarely applied to the field of silkworm cocoon identification and classification. In addition, existing deep learning methods are not suitable for silkworm cocoon classification. Therefore, it is necessary to design a method that can quickly identify and classify square cocoons to meet market needs. Summary of the Invention
[0005] In view of this, the present application provides a method, device and equipment for fine-grained image classification of grid-column silkworms to solve the problem of slow classification of grid-column silkworm cocoons in traditional technologies.
[0006] In a first aspect, an embodiment of the present application provides a method for fine-grained image classification of silkworms in a checkered cocoon, comprising:
[0007] Performing image acquisition on the checkered cocoon to obtain image information of the front and back sides of the cocoon;
[0008] Segmenting the gridded silkworm cocoon image information to generate a cocoon dataset;
[0009] Constructing a fine-grained classification model for silkworm cocoon images and performing training and testing using the silkworm cocoon dataset;
[0010] The trained fine-grained classification model for silkworm cocoons is used to classify and identify grid-column silkworm cocoons.
[0011] In a possible implementation, the image acquisition of the checkered cocoons to obtain the image information of the front and back sides of the cocoons includes:
[0012] Collect grid cluster images under different lighting conditions at different time periods. Place the grid cluster horizontally and set the camera above the grid cluster, facing the center of the grid cluster. Ensure that the grid cluster accounts for 75%-80% of the image.
[0013] Turn the cocoon over to ensure that the camera is facing the center of the cocoon and collect image information from the back of the cocoon to ensure that the image information of both the front and back sides of the cocoon are collected.
[0014] A possible implementation method is to segment the grid-column silkworm cocoon image information to create a silkworm cocoon dataset, including:
[0015] The collected grid cocoon images were annotated using the labelme annotation software, and the edge contours of the cocoons in the images were annotated. Multiple grid cocoon images were annotated, and the corresponding mask images were generated through the image processing method of the OpenCV library function as the training set.
[0016] Build a fully convolutional network FCN;
[0017] Use the trained fully convolutional network (FCN) to segment all the cocoon cluster images. Use OpenCV library functions to perform binarization, threshold processing, and corrosion operations on the segmented images to complete the image denoising process and obtain the mask image of the cocoon cluster image.
[0018] Performing rectangular segmentation on the checkered cocoon mask image and the corresponding original checkered cocoon image, removing the background such as the checkered cocoon, and obtaining an independent cocoon image;
[0019] Based on the OpenCV library function, Python script statements are used to perform brightness changes, contrast changes, add noise, and randomly flip horizontally or vertically on the cocoon images after segmentation of the grid cocoon cluster to perform data enhancement and establish a cocoon dataset.
[0020] In one possible implementation, constructing a fully convolutional network (FCN) includes:
[0021] The multi-level features of the image are learned through the stacking of 15 layers of convolution and pooling;
[0022] Then replace the fully connected layer with an equivalent convolutional layer with a predicted depth of 2;
[0023] The FCN model has three prediction layers in the shallow, middle, and deep convolutional layers. The third prediction result is added and fused with the first two prediction results, and then upsampled again through deconvolution to obtain a 568×568×2 image.
[0024] The output size is restored to its original size by cropping the gray part;
[0025] By finding the maximum numerical probability of each pixel as the classification of the pixel, the spatial information in the original input image is retained;
[0026] The labeled grid cluster mask image training set is trained. The grid cluster images and the corresponding labeled mask images are placed in different folders. The training batch epoch is set to 100. The SGD network optimizer is used with the learning rate lr set to 0.001 and the momentum set to 0.7.
[0027] A possible implementation method of constructing a fine-grained classification model for silkworm cocoon images and performing training and testing using the silkworm cocoon dataset includes:
[0028] Conduct a preliminary experiment on silkworm cocoon recognition, using AlexNet, VGG16, ResNet50 and other networks to identify and classify silkworm cocoons;
[0029] Based on the VGG16 network, the network is optimized and improved;
[0030] The constructed and optimized VGG model for silkworm cocoon classification is used to train the silkworm cocoon dataset. The trained VGG model for silkworm cocoon classification is then used to perform actual recognition and classification of grid cocoon images.
[0031] One possible implementation method is that the VGG16 network contains an input layer, 13 convolutional layers, an activation function, 4 pooling layers, 3 fully connected layers, and a Softmax layer. Each convolutional layer consists of a set of convolution kernels that perform convolution operations with the given input to extract image features. The activation function is a nonlinear mapping used to simulate complex nonlinear functions, thereby enhancing the expressive power of the network model. The pooling layer reduces the dimensionality of the input image and the dimensionality of the extracted feature map, thereby reducing the number of parameters for network training and reducing overfitting. The first two convolutional layers and the first pooling layer are regarded as a group of shallow networks. By changing the convolution kernel size, step size, and pooling parameters of the first three layers of the network, the shallow network structure parameters are optimized.
[0032] In a second aspect, an embodiment of the present application provides a device for fine-grained image classification of silkworms in a checkered cocoon, characterized by comprising:
[0033] An image acquisition module is used to acquire images of the square-column mulberry cocoon to obtain image information of the front and back sides of the cocoon;
[0034] An image segmentation module, configured to segment the gridded cocoon image information to produce a cocoon dataset;
[0035] A model building module, used to build a fine-grained classification model for silkworm cocoon images, and to perform training and testing using the silkworm cocoon dataset;
[0036] The classification and recognition module is used to classify and recognize grid-column mulberry cocoons using the trained fine-grained classification model for cocoon images.
[0037] In a third aspect, an embodiment of the present application provides an electronic device, including:
[0038] processor;
[0039] Memory;
[0040] And a computer program, wherein the computer program is stored in the memory, and the computer program includes instructions, which, when executed by the processor, enable the electronic device to execute the method described in any possible implementation of the first aspect.
[0041] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which includes a stored program, wherein when the program is running, the device where the computer-readable storage medium is located is controlled to execute the method described in any possible implementation method of the first aspect.
[0042] In this application, a neural network and image processing technique are used to segment gridded cocoon images. This method is less affected by image background and pixel size, and achieves high segmentation accuracy. A fine-grained classification model for cocoon images is constructed, improving the efficiency of cocoon sorting, the automation and intelligence level of the cocoon industry, and the efficiency of classification and recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0044] Figure 1 A schematic diagram of a flow chart of a fine-grained image classification method for square-column silkworms provided in an embodiment of the present application;
[0045] Figure 2 A schematic diagram of labeling a collected grid cluster image using labelme labeling software is provided for the embodiment of this application;
[0046] Figure 3 Schematic diagram of the segmentation of a grid-like cocoon image by the fully convolutional network (FCN) provided in an embodiment of the present application;
[0047] Figure 4 A schematic diagram of a fine-grained image classification device for square-column silkworms provided in an embodiment of the present application;
[0048] Figure 5 A schematic diagram of a device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0049] In order to better understand the technical solution of the present application, the embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0050] It should be clear that the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0051] The terms used in the embodiments of the present application are for the purpose of describing specific embodiments only and are not intended to limit the present application. The singular forms "a", "an", "the" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise.
[0052] It should be understood that the term "and / or" as used herein simply describes a relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A alone, A and B together, or B alone. Furthermore, the character " / " in this document generally indicates an "or" relationship between the associated objects.
[0053] Figure 1 A schematic diagram of a method for fine-grained image classification of square-column silkworms provided in an embodiment of the present application is provided. Figure 1 The fine-grained image classification method for silkworms in a checkered cocoon in this embodiment includes:
[0054] S101, collecting images of the grid-clustered silkworm cocoons to obtain image information of the front and back sides of the cocoons.
[0055] In this embodiment, the image capture device is a camera, and images of the cocoon are captured under natural light at different time periods. The cocoon is placed horizontally, and the camera is positioned above the cocoon, centered on the cocoon, ensuring that the cocoon occupies 75%-80% of the captured image. The cocoon is then flipped over, with the camera centered on the cocoon, to capture images of the back of the cocoon, ensuring that both the front and back sides of the cocoon are captured.
[0056] S102, segmenting the grid-clustered silkworm cocoon image information to generate a cocoon dataset.
[0057] See also Figure 2, labelme annotation software was used to annotate the collected grid cluster images, the edge contours of the cocoons in the images were annotated, multiple grid cluster cocoon images were annotated, and the corresponding mask images were generated through the image processing method of the OpenCV library function as the training set.
[0058] To build a fully convolutional network (FCN), we first learn the multi-level features (featuremap) of the image through a stack of 15 layers of convolution and pooling. Then, we replace the fully connected layer with an equivalent convolution layer with a prediction depth of 2 (silkworm cocoon + background). The FCN model has three prediction layers in the shallow, middle, and deep convolution layers. The third prediction result is added and fused with the first two prediction results, and then upsampled again through deconvolution to obtain a 568×568×2 image. Finally, the gray part is cropped to restore the output size to the original size. The network structure is as follows: Figure 1 As shown. Finally, the maximum numerical description (probability) of each pixel is obtained as the classification of the pixel, while retaining the spatial information in the original input image. The deconvolution formula is as follows:
[0059] in kernel is the convolution kernel size, padding It's filling. stride is the step length.
[0060] The labeled grid cluster mask image training set is trained. The grid cluster images and the corresponding labeled mask images are placed in different folders. The training batch epoch is set to 100. The SGD network optimizer is used with the learning rate lr set to 0.001 and the momentum set to 0.7.
[0061] Use the trained fully convolutional network FCN to segment all the cocoon cluster images. Use OpenCV library functions and other image processing methods to perform binarization, threshold processing and corrosion operations on the segmented images to complete the image denoising process and obtain the mask image of the grid cluster cocoon image, as shown in the following figure: Figure 3 shown.
[0062] The grid cluster cocoon mask image and the corresponding original grid cluster image are segmented by positioning rectangles, and the background such as the grid cluster is removed to obtain an independent cocoon image with a pixel size of 224×112.
[0063] Based on the OpenCV library function, Python script statements are used to perform brightness changes, contrast changes, add noise, and randomly flip horizontally or vertically on the cocoon images after segmentation of the grid cocoon cluster to perform data enhancement and establish a cocoon dataset.
[0064] S103, constructing a fine-grained classification model for silkworm cocoons, performing training and testing on the silkworm cocoons dataset, and using the trained fine-grained classification model for silkworm cocoons to classify and identify grid-column silkworm cocoons.
[0065] A preliminary experiment on silkworm cocoon recognition was conducted, and the AlexNet, VGG16, ResNet50 and other networks were used to identify and classify silkworm cocoons. The results showed that large convolution kernels and overly deep networks are not suitable for silkworm cocoon classification. The VGG16 network has the structural characteristics of small convolution kernels and deep networks, and is more suitable for fine-grained image classification of silkworm cocoons.
[0066] Based on the VGG16 network, the network was optimized and improved. CNN is primarily used as a classifier in image recognition. Its input raw image data undergoes a series of operations, including convolution, pooling, and nonlinear activation function mapping, to abstract the extracted image features layer by layer. After passing through the fully connected layer and output layer, the category of the input image is determined.
[0067] The VGG16 network consists of an input layer, 13 convolutional layers, activation functions, four pooling layers, three fully connected layers, and a softmax layer. Each convolutional layer extracts image features by convolving a set of kernels with the input. The activation function is a nonlinear mapping primarily used to simulate complex nonlinear functions, thereby enhancing the expressive power of the network model. The pooling layer reduces the dimensionality of the input image, reducing the dimensionality of the extracted feature maps. This reduces the number of parameters required for network training and significantly reduces overfitting.
[0068] The first two convolutional layers and the first pooling layer were used as a shallow network. The shallow network structure parameters were optimized by varying the convolution kernel size, stride, and pooling parameters of the first three layers. After multiple rounds of experiments, we concluded that a silkworm cocoon classification model with a 3×3 kernel size and stride of 2 for Conv1, a 3×3 kernel size and stride of 1 for Conv2, and a 1×1 kernel size and stride of 1 for Pool 1 was more suitable for fine-grained image classification in the silkworm cocoon dataset. Based on the experimental results, a VGG model for fine-grained cocoon image classification was constructed. The network structure is shown in Table 1.
[0069] Table 1 Network structure parameters
[0070] Network structure Number of convolutional layers Number of channels Convolution kernel size Number of pooling layers Fully connected layer VGG16 13 64×2-128×2-256×3-512×6 3×3 5 4096-4096-2
[0071] The constructed and optimized VGG model for silkworm cocoon classification is used to train the silkworm cocoon dataset. The trained VGG model for silkworm cocoon classification is then used to perform actual recognition and classification of gridded silkworm cocoon images.
[0072] Corresponding to the above embodiments, the present application also provides a device for classifying fine-grained images of silkworms in grid cocoons.
[0073] See also Figure 4 , is a structural block diagram of a fine-grained image classification device for square-column silkworms provided in an embodiment of the present application. Figure 4 As shown, the square-column silkworm fine-grained image classification device 20 mainly includes the following modules.
[0074] The image acquisition module 201 is used to acquire images of the square-column silkworm cocoons to obtain image information of the front and back sides of the cocoons;
[0075] An image segmentation module 202 is configured to segment the gridded cocoon image information to generate a cocoon dataset;
[0076] The classification and recognition module 203 is used to construct a fine-grained classification model for cocoon images, perform training and testing on the cocoon dataset, and use the trained fine-grained classification model for cocoon images to classify and recognize grid-column mulberry cocoons.
[0077] It should be pointed out that the specific contents involved in the embodiments of the present application can be found in the description of the above method embodiments. For the sake of brevity, they will not be repeated here.
[0078] Corresponding to the above embodiment, an embodiment of the present application further provides an electronic device.
[0079] See also Figure 5 , is a schematic diagram of the structure of a device provided in an embodiment of the present application. Figure 5 As shown, the device 300 may include: a processor 301, a memory 302, and a communication unit 303. These components communicate via one or more buses. Those skilled in the art will appreciate that the electronic device structure shown in the figure does not limit the embodiments of the present application. It may be a bus structure or a star structure, and may include more or fewer components than shown, or combine certain components, or arrange the components differently.
[0080] The communication unit 303 is used to establish a communication channel so that the electronic device can communicate with other devices.
[0081] The processor 301 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. It runs or executes software programs and / or modules stored in the memory 302, and calls data stored in the memory to perform various functions of the electronic device and / or process data. The processor can be composed of an integrated circuit (IC), for example, it can be composed of a single packaged IC, or it can be composed of multiple packaged ICs with the same or different functions. For example, the processor 301 can include only a central processing unit (CPU). In the embodiment of the present application, the CPU can be a single computing core or multiple computing cores.
[0082] The memory 302 is used to store execution instructions of the processor 301. The memory 302 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0083] When the execution instructions in the memory 302 are executed by the processor 301 , the electronic device 300 is enabled to execute part or all of the steps in the above method embodiment.
[0084] Corresponding to the above embodiment, embodiments of the present application further provide a computer-readable storage medium, wherein the computer-readable storage medium may store a program. When the program is executed, the program may control the device containing the computer-readable storage medium to execute some or all of the steps of the above method embodiments. In a specific implementation, the computer-readable storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0085] Corresponding to the above embodiment, an embodiment of the present application further provides a computer program product, which includes executable instructions. When the executable instructions are executed on a computer, the computer executes some or all of the steps in the above method embodiment.
[0086] In the embodiments of the present application, "at least one" refers to one or more, and "more" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent the existence of A alone, the existence of A and B at the same time, and the existence of B alone. Among them, A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can be represented by: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.
[0087] Those skilled in the art will appreciate that the various units and algorithm steps described in the embodiments disclosed herein can be implemented using a combination of electronic hardware, computer software, and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0088] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0089] In the several embodiments provided in this application, if any function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, or the part that contributes to the existing technology, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of this application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, and other media that can store program code.
[0090] The above description is merely a specific embodiment of the present application. Any person skilled in the art may easily conceive of variations or substitutions within the technical scope disclosed in this application, and such variations or substitutions shall be within the scope of protection of this application. The scope of protection of this application shall be subject to the scope of protection of the claims.
Claims
1. A fine-grained image classification method for silkworms in a grid cocoon, characterized in that: include: Performing image acquisition on the checkered cocoon to obtain image information of the front and back sides of the cocoon; The square cocoon image information is segmented using a trained fully convolutional network (FCN) to create a cocoon dataset; Constructing a fine-grained classification model for silkworm cocoons, performing training and testing on the silkworm cocoon dataset, and using the trained fine-grained classification model for silkworm cocoons to classify and identify grid-column silkworm cocoons; The method of constructing a fine-grained classification model for silkworm cocoon images and performing training and testing on the silkworm cocoon dataset includes: Conduct a preliminary experiment on silkworm cocoon recognition and use AlexNet, VGG16, and ResNet50 networks to identify and classify silkworm cocoons; Based on the VGG16 network, the network is optimized and improved; The constructed and optimized VGG model for silkworm cocoon classification is used to train the silkworm cocoon dataset. The trained VGG model for silkworm cocoon classification is then used to perform recognition and classification of grid cocoon images. The VGG16 network consists of an input layer, 13 convolutional layers, an activation function, 4 pooling layers, 3 fully connected layers and a Softmax layer; each convolutional layer consists of a set of convolution kernels that perform convolution operations with the given input to extract image features. The activation function is a nonlinear mapping, which is used to simulate complex nonlinear functions, thereby enhancing the expressive ability of the network model; the pooling layer reduces the dimensionality of the input image, reducing the dimension of the extracted feature map, thereby reducing the number of parameters for network training and reducing overfitting; the first two convolutional layers and the first pooling layer are regarded as a group of shallow networks, and the shallow network structure parameters are optimized by changing the convolution kernel size, step size and pooling parameters of the first three layers of the network. The silkworm cocoon classification model with a convolution kernel size of 3×3 and a step size of 2, a convolution kernel size of 3×3 and a step size of 1 for Conv 2, and a size of 1×1 and a step size of 1 for Pool 1 is more suitable for fine-grained image classification of the silkworm cocoon dataset.
2. The method for classifying fine-grained images of silkworms in checkered cocoons according to claim 1, characterized in that: The image acquisition of the checkered cocoons to obtain the checkered cocoon image information of the front and back sides of the cocoons includes: Collect grid cluster images under different lighting conditions at different time periods. Place the grid cluster horizontally and set the camera above the grid cluster, facing the center of the grid cluster. Ensure that the grid cluster accounts for 75%-80% of the image. Turn the cocoon over to ensure that the camera is facing the center of the cocoon and collect image information from the back of the cocoon to ensure that the image information of both the front and back sides of the cocoon are collected.
3. The method for classifying fine-grained images of silkworms in checkered cocoons according to claim 2, wherein: Segmenting the grid-clustered silkworm cocoon image information to create a silkworm cocoon dataset includes: The collected grid cocoon images were annotated using the labelme annotation software, and the edge contours of the cocoons in the images were annotated. Multiple grid cocoon images were annotated, and the corresponding mask images were generated through the image processing method of the OpenCV library function as the training set. Build a fully convolutional network FCN; Use the trained fully convolutional network (FCN) to segment all the cocoon cluster images. Use OpenCV library functions to perform binarization, threshold processing, and corrosion operations on the segmented images to complete the image denoising process and obtain the mask image of the cocoon cluster image. Performing rectangular segmentation on the checkered cluster cocoon mask image and the corresponding original checkered cluster image, removing the checkered cluster background, and obtaining an independent cocoon image; Based on the OpenCV library function, Python script statements are used to perform brightness changes, contrast changes, add noise, and randomly flip horizontally or vertically on the cocoon images after segmentation of the grid cocoon cluster to perform data enhancement and establish a cocoon dataset.
4. The method for classifying fine-grained images of silkworms in checkered cocoons according to claim 3, wherein: The construction of the fully convolutional network FCN includes: The multi-level features of the image are learned through the stacking of 15 layers of convolution and pooling; Then replace the fully connected layer with an equivalent convolutional layer with a predicted depth of 2; The FCN model has three prediction layers in the shallow, middle, and deep convolutional layers. The third prediction result is added and fused with the first two prediction results, and then upsampled again through deconvolution to obtain a 568×568×2 image. The output size is restored to its original size by cropping the gray part; By finding the maximum numerical probability of each pixel as the classification of the pixel, the spatial information in the original input image is retained; The labeled grid cluster mask image training set is trained. The grid cluster images and the corresponding labeled mask images are placed in different folders. The training batch epoch is set to 100. The SGD network optimizer is used with the learning rate lr set to 0.001 and the momentum set to 0.
7.
5. A fine-grained image classification device for mulberry silkworms in a grid cocoon, characterized in that: include: An image acquisition module is used to acquire images of the square-column mulberry cocoon to obtain image information of the front and back sides of the cocoon; An image segmentation module is used to segment the gridded cocoon image information using a trained fully convolutional network (FCN) to produce a cocoon dataset; A classification and recognition module is used to construct a fine-grained classification model for silkworm cocoons, perform training and testing on the silkworm cocoons dataset, and use the trained fine-grained classification model for silkworm cocoons to classify and recognize grid-column silkworm cocoons. The method of constructing a fine-grained classification model for silkworm cocoon images and performing training and testing on the silkworm cocoon dataset includes: Conduct a preliminary experiment on silkworm cocoon recognition and use AlexNet, VGG16, and ResNet50 networks to identify and classify silkworm cocoons; Based on the VGG16 network, the network is optimized and improved; The constructed and optimized VGG model for silkworm cocoon classification is used to train the silkworm cocoon dataset. The trained VGG model for silkworm cocoon classification is then used to perform recognition and classification of grid cocoon images. The VGG16 network consists of an input layer, 13 convolutional layers, an activation function, 4 pooling layers, 3 fully connected layers and a Softmax layer; each convolutional layer consists of a set of convolution kernels that perform convolution operations with the given input to extract image features. The activation function is a nonlinear mapping, which is used to simulate complex nonlinear functions, thereby enhancing the expressive ability of the network model; the pooling layer reduces the dimensionality of the input image, reducing the dimension of the extracted feature map, thereby reducing the number of parameters for network training and reducing overfitting; the first two convolutional layers and the first pooling layer are regarded as a group of shallow networks, and the shallow network structure parameters are optimized by changing the convolution kernel size, step size and pooling parameters of the first three layers of the network. The silkworm cocoon classification model with a convolution kernel size of 3×3 and a step size of 2, a convolution kernel size of 3×3 and a step size of 1 for Conv 2, and a size of 1×1 and a step size of 1 for Pool 1 is more suitable for fine-grained image classification of the silkworm cocoon dataset.
6. A fine-grained image classification device for silkworms in a grid cocoon, characterized in that: include: processor; Memory; and a computer program, wherein the computer program is stored in the memory, the computer program comprising instructions, which, when executed by the processor, cause the device to perform the method according to any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the method according to any one of claims 1 to 4.