A bear identification method in Northwest China based on convolutional neural network
Through the identification method based on the convolutional neural network, combined with the YOLOv8n and ResNet models, using edge computing equipment and low-temperature-resistant cameras, the accurate identification and real-time eviction signals of bears in the northwest region are achieved, solving the problem of safety in areas where bears are frequently found. Threat issues ensure the safety of people and property.
Patent Information
- Application Number
- CN202410840226.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2044-06-27
AI Technical Summary
In the northwest region, where brown bears and other bears frequently appear, how to accurately identify bears so that eviction signals can be issued in a timely manner to ensure the safety of people and property.
Using a recognition method based on convolutional neural networks, by collecting and generalizing bear training data, YOLOv8n and ResNet models were constructed to identify and verify bears in pictures respectively, and combined with edge computing equipment and low-temperature-resistant cameras to capture videos in real time Data is used to calculate the risk coefficient to determine whether to issue an eviction signal.
It has achieved accurate identification and real-time judgment of bears in the northwest region, ensuring the safety of people and property in the target area, and effectively issuing eviction signals through the automatic identification system.
Smart Images

Figure CN118397660B
Abstract
Description
Technical Field
[0001] The present application belongs to the field of image recognition technology, and more specifically, relates to a method for identifying bears in the northwest region based on a convolutional neural network. Background Art
[0002] In northwestern regions such as the Qilian Mountains, with the recovery of the ecological environment, the population of wild animals such as brown bears has resumed its growth trend year by year. However, brown bears and other bears are one of the larger mammals in the world and are highly aggressive. Once they invade human residential or breeding areas, they will pose a threat to people and property. In areas where brown bears frequently appear, it is necessary not only to set up warning signs to remind people to pay attention to travel safety, but also to use expulsion devices. By sending out expulsion signals, the bears will be driven away from human residential or breeding areas under the drive-by signals. Accurately sending out expulsion signals requires accurate identification of bears entering the detection area. How to accurately identify bears has become one of the technical problems that the industry needs to solve. Summary of the invention
[0003] The purpose of this application is to provide a bear identification method in the northwest region based on a convolutional neural network, which can identify the acquired image through a convolutional neural network to determine whether it is a bear, and determine whether to issue an expulsion signal based on the identification result to ensure the safety of people and property.
[0004] To achieve the above objectives, this application is implemented through the following technical solutions:
[0005] A method for identifying bears in the northwest region based on a convolutional neural network described in this application comprises the following steps:
[0006] S1. Collect training data images of bears in the northwest region and generalize the data to produce the first and second sample data sets;
[0007] S2. Based on step S1, train and debug the first deep learning model using the first type of sample data set;
[0008] S3, based on step S1, training and debugging a second deep learning model with a second type of sample data set;
[0009] S4, deploying the first deep learning model and the second deep learning model formed in step S2 and step S3 in the electronic device in the area to be detected;
[0010] S5. Import the real-time shot picture, automatically identify it through the first deep learning model and the second deep learning model, output the identification result, and determine whether to issue an expulsion command.
[0011] As one of the preferred technical solutions, the training data images collected in step S1 described in the present application include full-body, half-body, with-face and without-face image data of bears; the generalized data processing described in step S1 includes inversion, random proportion masking, increasing or decreasing brightness, increasing or decreasing contrast, and manually marking pixel frames involving bears in the training data images through the roboflow platform, and the roboflow platform generates an image file including image category and pixel position.
[0012] As one of the preferred technical solutions, the first type of sample data set described in step S1 described in the present application refers to the collected training data pictures containing multiple Northwest bear target objects; the second type of sample data set described in step S1 refers to the collected training data pictures containing a single Northwest bear target object; the first type of sample data set and the second type of sample data set are used as training set, verification set and test set respectively, wherein the training set accounts for 70% of the first sample data set and the second type of sample data set, and the verification set and the test set each account for 15% of the first type of sample data set and the second type of sample data set.
[0013] As one of the preferred technical solutions, step S2 described in this application also includes:
[0014] S21. Construct a YOLOv8n model consisting of a convolutional neural network as the first deep learning model;
[0015] S22, sending the pictures in the first type of sample data set to the YOLOv8n model, taking the confidence of whether it is a bear as the output, taking minimizing the loss function value of the first deep learning model as the training goal, and using the back propagation algorithm and the gradient descent algorithm to iteratively train the model; when the loss function value of the first deep learning model is less than or equal to the preset first target loss function and tends to be stable, stop training;
[0016] S23. Adjust the learning rate and loU threshold according to the accuracy of the YOLOv8n model and send it to step S22 again to repeat the training until a deep learning model for bear recognition is obtained.
[0017] As one of the preferred technical solutions, step S3 described in this application includes:
[0018] S31. Construct a ResNet model consisting of a convolutional neural network as the second deep learning model;
[0019] S32. Adjust the images in the second sample data set to a height and width pixel value of 320×320, and input the adjusted images into the ResNet model. Take the predicted value of whether it is a bear as the output, select the cross entropy loss function and the stochastic gradient descent optimizer, use the Sigmod attenuation algorithm, and the learning rate decreases with the increase of training iterations. The calculation formula is as follows:
[0020] ;in The learning rate used for each round of optimization; is the initial learning rate; is the number of global iterations, is the current iteration number; , ;
[0021] S33. Continue training the ResNet model until convergence, adjust the ResNet model parameters according to the accuracy of the ResNet model, and repeat step S32 until a second deep learning model with enhanced robustness is obtained.
[0022] As one of the preferred technical solutions, the area to be detected in step S4 described in this application is divided into N areas of equal size, and M low-temperature resistant cameras are respectively set in each area of equal size. The mth low-temperature-resistant camera in the nth area is marked as follows: n ∈ [ 1 , N ] , m ∈ [ 1 , M ] ; There is also an edge computing device in each area as an electronic device for deploying the first deep learning model and the second deep learning model. The trained first deep learning model and the second deep learning model are deployed in the edge computing device respectively to process the video data transmitted by M low-temperature resistant cameras in the area, upload the video and mark the area number.
[0023] As one of the preferred technical solutions, in step S5 described in the present application, the first deep learning model and the second deep learning model deployed in the edge computing device are called by the BearCV program, and the following steps are adopted:
[0024] S51, the edge computing device reads the video data transmitted by the low-temperature resistant camera frame by frame in real time, and passes the image data read frame by frame to the first deep learning model, saves the pixel frame coordinates for the image objects with a confidence level greater than 0.5, and calculates the risk factor ;
[0025] S52, performing scaling and noise reduction on the image objects whose confidence is greater than 0.15 and less than 0.5 to obtain the input image size required by the second deep learning model;
[0026] Step S53: Input the scaled and denoised image into the second deep learning model to obtain the confidence of the target image. When the confidence is greater than 0.5, the pixel frame saved before scaling is used to calculate the risk factor. , and discard the rest.
[0027] As one of the preferred technical solutions, when scaling and denoising the image object in step S52 described in the present application, the pixel frame coordinates are first saved, and then the image is captured with the pixel frame coordinates, and proportionally scaled to a picture with a height and width pixel value of 320×320 required by the second deep learning model, and the aspect ratio of the original image is retained. A Gaussian filter is used to remove high-frequency noise, and the background color is used for filling, and then it is input into the second deep learning model to obtain the confidence of the target; the conversion formula for image scaling and denoising is as follows:
[0028] ; Wherein, H is the height of the image pixel input to the second deep learning model, and W is the width of the image pixel input to the second deep learning model; is the pixel width of the captured image, is the pixel height of the captured image; is the width of the image after scaling. is the height of the image after geometric scaling; Indicates that Gaussian filtering is performed on the image; Fill with background color .
[0029] The risk factor obtained in step S53 , whose expression is:
[0030] ;
[0031] in, is the image confidence of the first deep learning model, is the image confidence of the second deep learning model, , is the balance factor, is the pixel frame coordinate of the upper left corner of the target image, is the pixel frame coordinates at the bottom right of the target image, represents the pixel frame area, To measure the parameters, Is the risk factor.
[0032] Compared with the prior art, the beneficial effects of this application are:
[0033] This application can determine whether the animals appearing in the target area are northwestern bears, and determine whether it is necessary to issue an expulsion signal based on the obtained risk factor to ensure the safety of people and property in the target area. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 This is a flow chart of Example 1 of the present application. DETAILED DESCRIPTION
[0035] The technical solution described in this application is further described below in conjunction with the accompanying drawings and embodiments.
[0036] Example 1
[0037] A method for identifying bears in the northwest region based on a convolutional neural network comprises the following steps:
[0038] S1. Collect training data images of northwestern bears and perform generalization processing on the collected training data images to obtain a first type of sample data set and a second type of sample data set.
[0039] S2. Based on step S1, train and debug the first deep learning model using the obtained first type of sample data set.
[0040] S3. Based on step S1, train and debug a second deep learning model using the obtained second type of sample data set.
[0041] S4. Deploy the first deep learning model and the second deep learning model obtained in step S2 and step S3 in the electronic device in the area to be detected.
[0042] S5. Import the real-time shot pictures, and automatically identify the imported real-time shot pictures through the first deep learning model and the second deep learning model, output the identification results, and determine whether it is necessary to issue an expulsion signal.
[0043] Example 2
[0044] Based on Example 1, a method for identifying bears in the Northwest region based on a convolutional neural network is provided, wherein the training data images of Northwest bears obtained in step S1 should include full-body, half-body, with-face, and without-face images of bears, and the training data images of Northwest bears obtained above are generalized.
[0045] The generalized data processing described in step S1 includes inverting the training data image, covering the training data image at random proportions, increasing or decreasing the brightness of the training data image, increasing or decreasing the contrast of the training data image, manually marking the pixel frames of the bears involved in the training data image through the roboflow platform, and generating an image file including the image category and pixel position through the roboflow platform.
[0046] The first type of sample data set described in step S1 means that the collected training data images should contain multiple target objects of bears in the northwest region, and the second type of sample data set described in step S2 means that the collected training data images should only include a single target object of bears in the northwest region. The first type of sample data set and the second type of sample data set are used as the training set, validation set, and test set of the first deep learning model and the second deep learning model, respectively, wherein the training set should select 70% of the data volume of the first sample data set and the second sample data set, and the data volume selected for the validation set and the test set is 15% and 15% respectively, that is, half of the remaining data volume of the first sample data set and the second sample data set is used as the data of the validation set and the test set.
[0047] The technical solutions for the remaining parts are the same as those described in Example 1, and will not be described again here to avoid cumbersome writing.
[0048] Example 3
[0049] On the basis of Example 2, a method for identifying bears in the northwest region based on a convolutional neural network is provided. For the first deep learning model recorded in step S2, a YOLOv8n model is used as step S1. The YOLOv8n model is an object detection algorithm based on a convolutional neural network.
[0050] Step S22 is used to train the above model: the pictures in the first sample data set are sent to the YOLOv8n model, and the confidence of whether the picture is a bear is set as the output, and the minimization of the loss function value of the first deep learning model is used as the training goal. The back propagation algorithm and the gradient descent algorithm are used to iteratively train the model; when the loss function value of the first deep learning model is less than or equal to the preset first target loss function and tends to be stable, the training is stopped.
[0051] Step S23 is used to optimize the YOLOv8n model, and the learning rate and loU threshold are adjusted according to the accuracy of the YOLOv8n model, and the model is sent to step S22 again for repeated training until the first deep learning model for bear recognition with a good recognition rate is obtained.
[0052] In step S3, a ResNet model consisting of a convolutional neural network is constructed through step S31, and is used as the second deep learning model.
[0053] In step S32, the images in the second sample data set are adjusted to a height and width pixel value resolution of 320×320, and the adjusted images are input into the ResNet model. The predicted value of whether it is a bear is used as the output. The cross entropy loss function and the stochastic gradient descent optimizer are selected. The Sigmod attenuation algorithm is used, and the learning rate decreases with the increase of training iterations. The calculation formula is as follows:
[0054] L decay = L init 1 + e − x , x ∈ [ − α , α ] x = α ( 1 − 2 S decay S global ) ; in The learning rate used for each round of optimization; is the initial learning rate; is the number of global iterations, is the current iteration number; , , .
[0055] Continue to train the ResNet model through step S3 until convergence, adjust the ResNet model parameters according to the accuracy of the ResNet model, and repeat step S32 until a second deep learning model with better robustness is obtained.
[0056] The structure of the remaining parts is the same as the technical solution described in Example 2, and will not be described again here to avoid cumbersome writing.
[0057] Example 4
[0058] Based on Example 3, a method for identifying bears in the northwest region based on a convolutional neural network is provided. In step S4, the area to be detected is divided into N areas of equal size, each of which is provided with M low-temperature resistant cameras. The mth low-temperature-resistant camera in the nth area is marked as follows: n ∈ [ 1 , N ] , m ∈ [ 1 , M ] ; There is also an edge computing device in each area as an electronic device for deploying the first deep learning model and the second deep learning model. The trained first deep learning model and the second deep learning model are deployed in the edge computing device respectively to process the video data transmitted by M low-temperature resistant cameras in the area, upload the video and mark the area number.
[0059] In step S5, the first deep learning model and the second deep learning model deployed in the edge computing device are called by the BearCV program, and the following steps are adopted:
[0060] S51, the edge computing device reads the video data transmitted by the low-temperature resistant camera frame by frame in real time, and passes the image data read frame by frame to the first deep learning model, saves the pixel frame coordinates for the image objects with image confidence greater than 0.5, and calculates the risk factor ;
[0061] S52, performing scaling and noise reduction on the image objects whose confidence is greater than 0.15 and less than 0.5 to obtain the input image size required by the second deep learning model;
[0062] Step S53: Input the scaled and denoised image into the second deep learning model to obtain the image confidence of the target image. When the confidence is greater than 0.5, the pixel frame saved before scaling is used to calculate the risk factor. , and discard the rest;
[0063] S54: The risk factor obtained in step S51 and step S53 is When the risk factor is greater than the set risk factor threshold, the BearCV program saves the risk factor The corresponding picture object sends out an alarm signal to determine whether to issue an expulsion command.
[0064] When scaling and denoising the image object in step S52, the pixel frame coordinates are first saved, and then the image is captured with the pixel frame coordinates, and proportionally scaled to a picture with a height and width pixel value of 320×320 required by the second deep learning model, and the aspect ratio of the original image is retained. A Gaussian filter is used to remove high-frequency noise, and the background color is used for filling, and then the image confidence of the target is obtained by inputting it into the second deep learning model; the conversion formula for image scaling and denoising is as follows:
[0065] ; Wherein, H is the height of the image pixel input to the second deep learning model, and W is the width of the image pixel input to the second deep learning model; is the pixel width of the captured image, is the pixel height of the captured image; is the width of the image after scaling. is the height of the image after geometric scaling; Indicates that Gaussian filtering is performed on the image; Fill with background color .
[0066] The risk coefficients obtained in step S51 and step S53 , whose expression is:
[0067] ;in, is the image confidence of the first deep learning model, is the image confidence of the second deep learning model, , is the balance factor, is the pixel frame coordinate of the upper left corner of the target image, is the pixel frame coordinates at the bottom right of the target image, represents the pixel frame area, To measure the parameters, Is the risk factor.
[0068] The technical solutions for the remaining parts are the same as those in Examples 1 to 3, and will not be described again here to avoid cumbersome writing.
[0069] In this application, it is necessary to set up a detection area in areas where bears often appear, and set up corresponding low-temperature resistant cameras in the detection area. The low-temperature resistant cameras are mainly selected considering the climatic conditions in the northwest region.
[0070] The low-temperature camera transmits the captured video information to the edge computing device via wired or wireless transmission. The edge computing device receives the video information and reads it frame by frame in the BearCV program. The video information read frame by frame forms image data, which is sent to the first deep learning model and the second deep learning model respectively. The first deep learning model and the second deep learning model output the corresponding risk coefficient according to the input image data. , when the risk factor When the risk factor is greater than the set threshold (for example, 1), the BearCV program in the edge computing device sends a command to the expulsion system, which sends an expulsion signal and saves the risk factor at the same time. When the image data is greater than the risk factor threshold, the corresponding video data is output and saved.
[0071] Finally, although this specification is described according to implementation methods, not every implementation method contains only one independent technical solution. This narrative method of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment can also be appropriately combined to form other implementation methods that can be understood by those skilled in the art.
Claims
1. A method for identifying bears in Northwest China based on convolutional neural networks, characterized in that: The method comprises the following steps, S1. Collect training data images of bears in the northwest region and generalize the data to produce the first and second sample data sets; S2. Based on step S1, train and debug the first deep learning model using the first type of sample data set; S3, based on step S1, training and debugging a second deep learning model with a second type of sample data set; S4, deploying the first deep learning model and the second deep learning model formed in step S2 and step S3 in the electronic device in the area to be detected; S5, importing the real-time shot picture, automatically identifying it through the first deep learning model and the second deep learning model and outputting the identification result, and determining whether to issue an expulsion instruction; The first type of sample data set described in step S1 refers to the collected training data pictures containing multiple bear target objects in the northwest region; the second type of sample data set described in step S1 refers to the collected training data pictures containing a single bear target object in the northwest region; the first type of sample data set and the second type of sample data set are used as training set, verification set and test set respectively, wherein the training set accounts for 70% of the first type of sample data set and the second type of sample data set, and the verification set and the test set each account for 15% of the first type of sample data set and the second type of sample data set; The step S2 further comprises: S21. Construct a YOLOv8n model consisting of a convolutional neural network as the first deep learning model; S22, sending the pictures in the first type of sample data set to the YOLOv8n model, taking the confidence of whether it is a bear as the output, taking minimizing the loss function value of the first deep learning model as the training goal, and using the back propagation algorithm and the gradient descent algorithm to iteratively train the model; when the loss function value of the first deep learning model is less than or equal to the preset first target loss function and tends to be stable, stop training; S23, adjusting the learning rate and loU threshold according to the accuracy of the YOLOv8n model and sending it to step S22 again to repeat the training until a deep learning model for bear recognition is obtained; The step S3 comprises: S31. Construct a ResNet model consisting of a convolutional neural network as the second deep learning model; S32. Adjust the images in the second sample data set to a height and width pixel value of 320×320, and input the adjusted images into the ResNet model. Take the predicted value of whether it is a bear as the output, select the cross entropy loss function and the stochastic gradient descent optimizer, use the Sigmod attenuation algorithm, and the learning rate decreases with the increase of training iterations. The calculation formula is as follows: ;in, The learning rate used for each round of optimization; is the initial learning rate; is the number of global iterations, is the current iteration number; , ; S33, continue to train the ResNet model until convergence, adjust the ResNet model parameters according to the accuracy of the ResNet model, and repeat step S32 until a second deep learning model with enhanced robustness is obtained; In step S5, the first deep learning model and the second deep learning model deployed in the edge computing device are called by the BearCV program, and the following steps are adopted: S51, the edge computing device reads the video data transmitted by the low-temperature resistant camera frame by frame in real time, and passes the image data read frame by frame to the first deep learning model, saves the pixel frame coordinates for the image objects with image confidence greater than 0.5, and calculates the risk factor ; S52, performing scaling and noise reduction on the image objects whose confidence is greater than 0.15 and less than 0.5 to obtain the input image size required by the second deep learning model; Step S53: Input the scaled and denoised image into the second deep learning model to obtain the image confidence of the target image. When the confidence is greater than 0.5, the pixel frame saved before scaling is used to calculate the risk factor. , and discard the rest.
2. The method for identifying bears in the northwest region based on a convolutional neural network according to claim 1, characterized in that: The training data images collected in step S1 include full-body, half-body, face-without-face image data of bears; the generalized data processing in step S1 includes inversion, random proportion masking, increasing or decreasing brightness, increasing or decreasing contrast, and manually marking pixel frames involving bears in the training data images through the roboflow platform, and the roboflow platform generates an image file including image category and pixel position.
3. The method for identifying bears in Northwest China based on convolutional neural network according to claim 2, characterized in that: In step S4, the area to be detected is divided into N areas of equal size, and each area of equal size is provided with M low-temperature resistant cameras. The mth low-temperature-resistant camera in the nth area is marked as follows: , ; There is also an edge computing device in each area as an electronic device for deploying the first deep learning model and the second deep learning model. The trained first deep learning model and the second deep learning model are deployed in the edge computing device respectively to process the video data transmitted by M low-temperature resistant cameras in the area, upload the video and mark the area number.
4. The method for identifying bears in the northwest region based on a convolutional neural network according to claim 3, characterized in that: When scaling and denoising the image object in step S52, the pixel frame coordinates are first saved, and then the image is captured with the pixel frame coordinates, and proportionally scaled to a picture with a height and width pixel value of 320×320 required by the second deep learning model, and the aspect ratio of the original image is retained. A Gaussian filter is used to remove high-frequency noise, and the background color is used for filling, and then the image confidence of the target is obtained by inputting it into the second deep learning model; the conversion formula for image scaling and denoising is as follows: ; Where H is the height of the image pixel input to the second deep learning model, and W is the width of the image pixel input to the second deep learning model; is the pixel width of the captured image, is the pixel height of the captured image; is the width of the image after scaling. is the height of the image after geometric scaling; Indicates that Gaussian filtering is performed on the image; Fill with background color .
5. The method for identifying bears in the northwest region based on a convolutional neural network according to claim 4, characterized in that: The risk factor obtained in step S53 , whose expression is: ;in is the image confidence of the first deep learning model, is the image confidence of the second deep learning model, , is the balance factor, is the pixel frame coordinate of the upper left corner of the target image, is the pixel frame coordinates at the bottom right of the target image, represents the pixel frame area, To measure the parameters, Is the risk factor.
