Moso bamboo age discrimination method based on visible light image
Through the age discrimination method of bamboo based on visible light images, the target detection and image segmentation model are used to solve the problem of large age discrimination deviation of bamboo in the prior art, and the rapid and accurate age discrimination are achieved, and work efficiency and intelligent monitoring capabilities are improved.
Patent Information
- Application Number
- CN202411874824.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-04-04
AI Technical Summary
The existing age determination methods for bamboo rely on manual investigation, have large deviations and lack simple and precise technical means, making it difficult to meet the needs of modern bamboo management.
The age discrimination method of bamboo based on visible light images is adopted. By constructing a data set, training the object detection model and image segmentation model, combining preprocessing technology and loss function optimization, the rapid and accurate discrimination of bamboo age is achieved.
It has achieved rapid and accurate identification of the age of bamboo, improved the work efficiency of forestry farmers and forestry management departments, promoted intelligent monitoring of bamboo parameters, and reduced dependence on experience.
Smart Images

Figure CN119762864A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of forestry application and promotion, and in particular to a method for distinguishing the age of bamboo based on visible light images. Background Art
[0002] As an economic bamboo species, moso bamboo has significant advantages in ecological functions and economic benefits due to its fast growth rate, high yield, short felling period and wide range of uses. Due to the biological characteristics of moso bamboo that it grows into bamboo shoots from underground stems, moso bamboo forests have formed a special management model of uneven-aged forests. Accurately identifying bamboos of different ages is the key to scientific felling and management of moso bamboo, and is also the key foundation for ensuring the sustainable supply of moso bamboo resources and promoting the healthy development of the bamboo industry.
[0003] However, due to the impact of rural labor force outflow, forest farmer gap and the evolution of new forest farmer knowledge structure, the traditional experience of determining age is no longer sustainable: the existing bamboo age determination method relies on manual investigation, which is limited by the investigators' experience and technical level of bamboo, and the investigation results usually have large deviations. In addition, there is still no simple and accurate technical means for determining bamboo age, which is difficult to meet the needs of modern bamboo management. Summary of the invention
[0004] In view of this, the purpose of the present invention is to provide a method for distinguishing the age of bamboo based on visible light images, taking easily acquired visible light images as the key, and by means of image analysis and processing, quickly and accurately estimating the age parameters of bamboo to distinguish the age of bamboo, which is convenient for bamboo farmers to actually operate and improves the accuracy and efficiency of their work.
[0005] The present invention specifically adopts the following technical solutions: A method for distinguishing the age of bamboo based on visible light images: constructing a data set based on the visible light images of bamboo; performing target detection through a bamboo target detection model obtained through training to extract the bamboo area in the image; then performing detailed segmentation of the extracted image through an image segmentation model to obtain the bamboo poles in the visible light image, and establishing a data set for constructing a bamboo age discrimination model; after further preprocessing, the bamboo age discrimination model obtained through training is used to distinguish the bamboo age.
[0006] Furthermore, the bamboo target detection model adopts YOLOv8.
[0007] Furthermore, the image segmentation model adopts SAM.
[0008] Furthermore, the preprocessing includes: limiting contrast adaptive histogram equalization to redistribute pixel intensity values, enhancing the contrast of the local area in the image, introducing a limiting threshold parameter to enhance the color contrast of the bamboo poles in the image; and perturbing, tensorizing and normalizing the image information.
[0009] Furthermore, the age discrimination model uses the ResNet-101 residual network as the baseline network, freezes the parameters of the first two blocks of the network, trains the network parameters of the third, fourth blocks and the output part, and replaces the output part of the network with an adaptive average pooling layer and two adjacent fully connected layers, and the number of output categories is 4.
[0010] Furthermore, the Label Smoothing Regularization technique is used to smooth the labels in the data set of the age discrimination model.
[0011] Furthermore, the age discrimination model introduces Focal Loss as a part of the loss function.
[0012] Furthermore, the training process of the age discrimination model includes: Set the pre-training model path and data set reading path, use stochastic gradient descent SGD as the optimization algorithm, set the learning rate, number of learning rate changes, and weight decay coefficient; The GradCAM algorithm is introduced to visualize the weight parameters of the model in the image to view the focus area of the model training, and to tune the model parameters based on the relevant indicators of the model; Compare and check the trained models, and select the model with the best indicators as the best training model; Use the trained model to perform predictive reasoning on samples in the test set to verify the age discrimination model.
[0013] And, an electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the method for distinguishing the age of bamboo based on visible light images as described above are implemented.
[0014] A non-transitory computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of a method for distinguishing the age of bamboo based on visible light images as described above.
[0015] Compared with the prior art, the present invention and its preferred embodiments have at least the following beneficial effects: (1) It can quickly and accurately determine the age of bamboo, which can help forest farmers and forestry management departments improve work efficiency and promote the development of intelligent monitoring of bamboo parameters; (2) Compared with the traditional method of manually determining the age of bamboo, this method uses a scientific method to replace manual experience judgment. Even forest farmers without relevant experience can easily use this solution to make quick and accurate judgments. (3) Data acquisition is simple. In the specific implementation process of collecting raw data, it can be achieved through a mobile phone or a device with visible light collection function. It is suitable as a basic and innovative technology for promoting intelligent and automated monitoring of bamboo parameters. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The present embodiment is further described in detail below with reference to the accompanying drawings and specific implementation methods: Figure 1 is a schematic flow chart of a method for distinguishing the age of bamboo based on visible light images according to an embodiment of the present invention; Figure 2 , Figure 3 They are respectively a method for labeling and making a bamboo target detection data set and an actual detection result diagram in an embodiment of the present invention; Figure 4 This is a result image of bamboo poles obtained by detailed segmentation using the image segmentation model SAM in an embodiment of the present invention.
[0017] Figure 5 This is a diagram showing the effect of using contrast-limited adaptive histogram equalization to enhance an image in an embodiment of the present invention.
[0018] Figure 6 , Figure 7 They are respectively the file structure of the data set and the network structure diagram of the model used in the embodiment of the present invention.
[0019] Figure 8 This is a result diagram of model attention visualization using GradCAM in an embodiment of the present invention. DETAILED DESCRIPTION
[0020] Hereinafter, the specific embodiments of the present application will be described in detail with reference to the accompanying drawings. According to these detailed descriptions, those skilled in the art can clearly understand the present application and can implement the present application. Without violating the principles of the present application, the features in the various embodiments can be combined to obtain new implementations, or certain features in certain embodiments can be replaced to obtain other preferred implementations.
[0021] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0022] In order to make the features and advantages of the present invention more clearly understood, the following embodiments are specifically described in detail as follows: The embodiment of the present invention provides a method for distinguishing the age of bamboo based on visible light images, comprising the following steps: Step 1: After obtaining the visible light image data of bamboo, select some images to establish a data set for building a bamboo target detection model and divide it; Step 2: Train and verify the target detection model to obtain the optimal detection model weight file; Step 3: Use the target detection model to perform target detection on the bamboo visible light image and extract the image containing the bamboo part; Step 4: Use the image segmentation model SAM to perform detailed segmentation on the extracted image, obtain the bamboo stem part in the visible light image, and establish a data set for building a bamboo age discrimination model; Step 5: Process the images in the dataset by using contrast-constrained adaptive histogram equalization and a variety of image preprocessing methods to improve the accuracy and robustness of subsequent age discrimination; Step 6: Improve the model structure and loss function, and further build a bamboo age discrimination model; Step 7: Train and verify the bamboo age discrimination model to obtain the age discrimination model weight file with the best discrimination accuracy; Step 8: Import the bamboo image to be detected, detect its position and output the target age result.
[0023] As a preferred embodiment of this embodiment, step 1 further specifically includes: Step 1.1: Import the initial data, select the visible light images that meet the requirements, manually select the bamboo part in the image through LabelImg software, annotate the target detection information, and follow the format <classid><ratio of central horizontal coordinate to image width><ratio of central vertical coordinate to image height><ratio of frame width to image width><ratio of frame height to image height> represents the annotated text file; Step 1.2: Divide the corresponding label data and image data into training set, validation set, and test set in a ratio of 8:1:1 to obtain the data set required for the final training.
[0024] As a preferred embodiment of this embodiment, step 2 further specifically includes: Step 2.1: Based on the target detection model YOLOv8, set the pre-trained model path, dataset reading path, set other parameters to default, and start training the target detection model; Step 2.2: Check the change curve of indicators related to the model; Step 2.3: Compare and check the trained models, and select the model with the best indicators as the best training model; Step 2.4: Use the trained model to perform predictive reasoning on the samples of the test set to verify the target detection model.
[0025] As a preferred embodiment of this embodiment, step 5 further specifically includes: Step 5.1: Contrast-limited adaptive histogram equalization can redistribute pixel intensity values, enhance the contrast of local areas in the image, introduce a limiting threshold parameter to prevent excessive enhancement of local details and reduce noise, thereby enhancing the color contrast of the bamboo stems in the image and making the texture features of the bamboo stems and sheaths clearer; Step 5.2: Use the Resize, RandomRotation, ColorJitter, ToTensor, and Normalize methods in the torchvision module in the Python software library to preprocess the enhanced image. By perturbing, tensorizing, and normalizing the image information, the model's prediction results have higher accuracy and robustness.
[0026] As a preferred embodiment of this embodiment, step 6 further specifically includes: Step 6.1: The age discrimination model uses the ResNet-101 residual network as the baseline network. To improve the utilization of image information and the effect of model pre-training, the parameters of the first two blocks of the network are frozen, and the network parameters of the third, fourth blocks and output part are trained. At the same time, to meet the output requirements of age discrimination, the output part of the network is replaced with an adaptive average pooling layer and two adjacent fully connected layers, and the number of output categories is 4; Step 6.2: Since the age of bamboo is continuous, and the labels of bamboo image training are discrete, we use Label Smoothing Regularization to "smooth" the labels in the dataset, so that the model will not be overconfident in judging bamboo of a certain age, reduce the deviation of the model, and improve the performance of the model. Step 6.3: To address the problem of uneven classification difficulty caused by the small differences between bamboos of similar ages and significant differences between bamboos of large age differences, Focal Loss is introduced as part of the loss function. By assigning lower weights to samples that are easy to classify and higher weights to samples that are difficult to classify, the contribution of easy-to-classify negative samples to the loss is reduced, allowing the model to focus more on samples that are difficult to classify.
[0027] As a preferred embodiment of this embodiment, step 7 further specifically includes: Step 7.1: Set the pre-trained model path and the dataset reading path, use the stochastic gradient descent method SGD as the optimization algorithm, manually set the learning rate, number of learning rate changes, weight decay coefficient and other parameters, and start training the age discrimination model; Step 7.2: Introduce the GradCAM algorithm, which visualizes the weight parameters of the model in the image to view the focus area of the model training, and tunes the model parameters based on the relevant indicators of the model; Step 7.3: Compare and check the trained models, and select the model with the best indicators as the best training model; Step 7.4: Use the trained model to perform predictive reasoning on the samples of the test set to verify the age discrimination model.
[0028] The following further demonstrates and introduces the solution of the present invention through a test and verification example: Reference Figure 1 First, in order to build a bamboo target detection model, this study first imported the initial data and used LabelImg software to refer to Figure 2 , manually select the bamboo part in the image, perform target detection information annotation, and use the YOLO annotation format <category ID><center horizontal coordinate to image width ratio><center vertical coordinate to image height ratio><frame width to image width ratio><frame height to image height ratio> to represent the annotated text file.
[0029] The labeled data is divided into training set, validation set, and test set in a ratio of 8:1:1. The target detection model YOLOv8 is used as the training model. The pre-trained model path and data set reading path are set. Other parameters are set to default to perform model training. Compare and check the trained models, select the model with the best indicators as the best training model, and use this model to predict and infer the samples in the test set to verify the target detection model. The results are referenced to Figure 3 .
[0030] The trained target detection model is used to detect the target of the bamboo visible light image, and the image containing the bamboo part is extracted. Then the image segmentation model SAM is used to segment the bamboo poles in the visible light image. The results are referenced Figure 4 , establish a data set for the construction of bamboo age discrimination model.
[0031] Then, the image is enhanced by limited contrast adaptive histogram equalization method, which can redistribute pixel intensity values, enhance the contrast of local areas in the image, introduce limited threshold parameters to prevent excessive enhancement of local details and reduce noise, thereby enhancing the color contrast of bamboo stems in the image and making the texture features of bamboo stems and sheaths clearer. The results refer to Figure 5 .
[0032] Secondly, the enhanced image is preprocessed using the Resize, RandomRotation, ColorJitter, ToTensor, and Normalize methods in the torchvision module in the Python software library. The Resize method adjusts the image size, the RandomRotation method shifts the image at a small angle, the ColorJitter method makes the image brightness, contrast, and saturation fluctuate within a small range, the ToTensor method converts the image into a tensor required by the model, and the Normalize method normalizes the image. By preprocessing the image information, the prediction results of the model can have higher accuracy and robustness.
[0033] Then, the preprocessed image is referred to Figure 6 The data were divided into training set, validation set and test set in the ratio of 8:1:1, and then divided into four categories according to the age classification of bamboo: grade I, grade II, grade III, grade IV and above.
[0034] The age discrimination model uses the ResNet-101 residual network as the baseline network. In order to improve the utilization of image information and meet the output requirements of age discrimination and the effect of model pre-training, the parameters of the first two blocks of the network are frozen, and only the network parameters of the third, fourth and output parts are trained. The output part of the network is replaced by an adaptive average pooling layer and two adjacent fully connected layers. The number of output categories is 4, and the network structure is referenced Figure 7 ; Based on the network structure, the loss function of the model is improved. Since the age growth of bamboo is continuous, while the labels of bamboo image training are discrete, Label SmoothingRegularization is used to "smooth" the labels in the data set so that the model will not be overconfident in judging bamboo of a certain age, reduce the bias of the model, and improve the performance of the model. At the same time, in view of the problem of uneven classification difficulty caused by the small differences between bamboos of similar ages and significant differences between bamboos of large age differences, FocalLoss is introduced as part of the loss function. By assigning lower weights to samples that are easy to classify and higher weights to samples that are difficult to classify, the contribution of easy-to-classify negative samples to the loss is reduced, and the model pays more attention to samples that are difficult to classify.
[0035] Finally, set the pre-trained model path and the dataset reading path, use the stochastic gradient descent method SGD as the optimization algorithm, manually set the learning rate, the number of learning rate changes, the weight decay coefficient and other parameters, and start training and verifying the age discrimination model. The GradCAM algorithm is introduced in the model verification process. This algorithm visualizes the model's weight parameters in the image to view the focus area of the model training, and adjusts the model parameters in combination with the model's relevant indicators. The visualization results are shown in the figure below. Figure 8 As shown. Figure 8 It can also be seen that when the model is used for age discrimination, the model's main focus area is the sheath ring part of the bamboo and the skin of the bamboo pole, that is, the color of the bamboo pole. Therefore, according to the results of the model's focus, the parameters of the image preprocessing can be adjusted to improve the model's effect on image feature extraction.
[0036] Compare and check the trained models, select the model with the best indicators as the best training model, and finally use the trained model to perform predictive reasoning on the samples of the test set to verify the age discrimination model.
[0037] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0038] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0039] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0040] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0041] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the present invention should be understood by people with ordinary skills in the field to which the present invention belongs. "First", "second" and similar words used in the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "comprise" and similar words mean that the elements or objects appearing before the word include the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0042] The present invention is not limited to the above-mentioned optimal implementation mode. Anyone can derive other various forms of a method for distinguishing the age of bamboo based on visible light images under the inspiration of the present invention. All equivalent changes and modifications made according to the scope of the patent application of this embodiment should fall within the scope of the present invention.< / classid>
Claims
1. A method for distinguishing the age of bamboo based on visible light images, characterized in that: A data set is constructed based on visible light images of bamboo; target detection is performed using the trained bamboo target detection model to extract the bamboo area in the image; the extracted image is then segmented in detail using the image segmentation model to obtain the bamboo poles in the visible light image, and a data set is established for constructing a bamboo age discrimination model; After further preprocessing, the bamboo age discrimination model obtained through training is used to discriminate the bamboo age.
2. The method for distinguishing the age of bamboo based on visible light images according to claim 1, characterized in that: The bamboo target detection model adopts YOLOv8.
3. The method for distinguishing the age of bamboo based on visible light images according to claim 1, characterized in that: The image segmentation model adopts SAM.
4. The method for distinguishing the age of bamboo based on visible light images according to claim 1, characterized in that: The preprocessing includes: limiting contrast adaptive histogram equalization to redistribute pixel intensity values, enhancing the contrast of the local area in the image, introducing a limiting threshold parameter to enhance the color contrast of the bamboo poles in the image; and perturbing, tensorizing and normalizing the image information.
5. The method for distinguishing the age of bamboo based on visible light images according to claim 1, characterized in that: The age discrimination model uses the ResNet-101 residual network as the baseline network, freezes the parameters of the first two blocks of the network, trains the network parameters of the third, fourth blocks and the output part, and replaces the output part of the network with an adaptive average pooling layer and two adjacent fully connected layers, and the number of output categories is 4.
6. The method for distinguishing the age of bamboo based on visible light images according to claim 1, characterized in that: The Label Smoothing Regularization technique is used to smooth the labels in the data set of the age discrimination model.
7. The method for distinguishing the age of bamboo based on visible light images according to claim 1, characterized in that: The age discrimination model introduces Focal Loss as part of the loss function.
8. The method for distinguishing the age of bamboo based on visible light images according to claim 1, characterized in that: The training process of the age discrimination model includes: Set the pre-training model path and data set reading path, use stochastic gradient descent SGD as the optimization algorithm, set the learning rate, number of learning rate changes, and weight decay coefficient; The GradCAM algorithm is introduced to visualize the weight parameters of the model in the image to view the focus area of the model training, and to tune the model parameters based on the relevant indicators of the model; Compare and check the trained models, and select the model with the best indicators as the best training model; Use the trained model to perform predictive reasoning on samples in the test set to verify the age discrimination model.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the method for distinguishing the age of bamboo based on visible light images as described in any one of claims 1 to 8 are implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of a method for distinguishing the age of bamboo based on visible light images as described in any one of claims 1 to 8 are implemented.