Wild animal infrared image recognition method and device based on improved-yolov7 and storage medium
By constructing the CBMA-E-ELAN module and the Improved-YOLOv7 model that optimizes target candidate boxes using K-means clustering, the problems of low identification efficiency and insufficient accuracy in infrared camera monitoring are solved, and efficient and reliable identification of infrared images of wild animals is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGXI FORESTRY RES INST
- Filing Date
- 2026-02-13
- Publication Date
- 2026-06-12
AI Technical Summary
Existing infrared camera monitoring technology suffers from low efficiency in manual processing and large identification errors in wildlife identification and classification. It also has poor adaptability to general image recognition tools and is difficult to meet the identification needs in complex field scenarios, resulting in insufficient reliability and accuracy of identification results.
A CBMA-E-ELAN module was constructed to replace the backbone network of the YOLOv7 basic model. K-means clustering was combined to optimize the target candidate boxes. The Improved-YOLOv7 model was trained using a dedicated infrared image dataset to improve feature extraction capabilities and candidate box adaptability.
It improves the accuracy and reliability of infrared image recognition of wild animals, reduces false detections and missed detections, and meets the requirements of field monitoring for data processing efficiency and recognition accuracy.
Smart Images

Figure CN122200732A_ABST
Abstract
Description
Technical Field
[0001] This invention mainly relates to the field of computer vision processing technology, specifically to a method, device, and storage medium for wildlife infrared image recognition based on Improved-YOLOv7. Background Technology
[0002] In wildlife conservation and field monitoring, infrared cameras, with their non-invasive and all-weather operation advantages, have become a core tool for acquiring wildlife image data and are widely used in nature reserves, field ecological monitoring areas, and other scenarios. However, images captured by infrared cameras in complex field environments often suffer from low contrast, blurred details, and background noise interference. Furthermore, wildlife targets are easily affected by complex scenarios such as fog, nighttime, obstruction, and overlapping of multiple targets, posing a significant challenge to the efficient processing of image data. Currently, wildlife identification and classification based on these infrared images still mainly rely on manual screening of valid images, species differentiation, and recording of relevant information. In some scenarios, general image recognition tools are used to assist in processing. However, manual methods require a significant investment of manpower and time, especially when dealing with the massive amounts of data generated by large-scale infrared camera monitoring networks. The processing efficiency is extremely low, and identification errors are easily caused by factors such as differences in staff experience and visual fatigue. General image recognition tools are not optimized for the characteristics of infrared images and the diversity of wildlife morphology, making it difficult to adapt to the identification needs in complex field scenarios. They often result in false positives and false negatives, and the reliability and accuracy of the identification results are insufficient. This fails to meet the actual requirements of data processing efficiency and identification accuracy for large-scale wildlife monitoring in the wild, severely restricting the application value of infrared camera monitoring technology in wildlife conservation and ecological research. Summary of the Invention
[0003] The technical problem to be solved by the present invention is to provide a method, device and storage medium for wildlife infrared image recognition based on Improved-YOLOv7, which addresses the shortcomings of the prior art.
[0004] The technical solution of this invention to solve the above-mentioned technical problems is as follows: A method for identifying wild animals using infrared images based on Improved-YOLOv7, comprising the following steps: Collect a dataset of infrared camera images containing wild animals, and label all wild animal infrared camera images in the dataset with species. Then divide the labeled infrared camera image dataset into a training set and a validation set. Construct a CBMA-E-ELAN module, replace the E-ELAN module in the backbone network of the YOLOv7 basic model with the CBMA-E-ELAN module, and optimize the target candidate boxes of the YOLOv7 basic model to obtain the Improved-YOLOv7 wildlife recognition model. The Improved-YOLOv7 wildlife recognition model is trained using the training set to obtain the trained Improved-YOLOv7 wildlife recognition model. The validation set is input into the trained Improved-YOLOv7 wildlife recognition model, which outputs wildlife classification results.
[0005] Another technical solution of the present invention to solve the above-mentioned technical problems is as follows: A wildlife infrared image recognition device, comprising: The image dataset construction module is used to collect infrared camera image datasets containing wild animals, and to label all wild animal infrared camera images in the infrared camera image datasets by species. The labeled infrared camera image datasets are then divided into training sets and validation sets. The model improvement building module is used to build the CBMA-E-ELAN module, replace the E-ELAN module of the backbone network in the YOLOv7 basic model with the CBMA-E-ELAN module, and optimize the target candidate boxes of the YOLOv7 basic model to obtain the Improved-YOLOv7 wildlife recognition model. The model training module is used to train the Improved-YOLOv7 wildlife recognition model using the training set, so as to obtain the trained Improved-YOLOv7 wildlife recognition model. The image recognition output module is used to input the validation set into the trained Improved-YOLOv7 wildlife recognition model and output the wildlife classification results.
[0006] Another technical solution of the present invention to solve the above-mentioned technical problems is as follows: a wildlife infrared image recognition device based on Improved-YOLOv7, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the wildlife infrared image recognition method based on Improved-YOLOv7 as described above.
[0007] Another technical solution of the present invention to solve the above-mentioned technical problems is as follows: a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the wildlife infrared image recognition method based on Improved-YOLOv7 as described above.
[0008] The beneficial effects of this invention are: by collecting a dedicated infrared image dataset and completing standardized species labeling, dividing the training set and validation set, it provides the model with a high-quality data foundation that fits the characteristics of infrared images of wild animals, avoids the adaptation deviation between general datasets and actual recognition scenarios, and improves the targeting of model learning. The CBMA-E-ELAN module was constructed to replace the original E-ELAN module, which enhances the ability to extract morphological differences in wild animals. K-means clustering was combined to optimize the target candidate boxes, making them suitable for the actual morphology of wild animals. This dual improvement solves the problems of insufficient feature extraction and poor candidate box adaptability of the original YOLOv7 model, and enhances the model's ability to recognize infrared images. By using a dedicated training set, the improved model fully learns the infrared image features of wild animals, and then validates the output classification results using a validation set. This ensures that the model has stable recognition performance, reduces false positives and false negatives caused by poor data quality and insufficient model adaptability, and improves the accuracy and reliability of wild animal classification results. Attached Figure Description
[0009] Figure 1 A flowchart of a method for identifying wild animals using infrared images provided in an embodiment of the present invention; Figure 2 Feature processing link diagram of the CBMA-E-ELAN module provided in this embodiment of the invention Figure 3 This is an overall architecture diagram of the Improved-YOLOv7 wildlife recognition model provided in an embodiment of the present invention; Figure 4 A functional block diagram of the wildlife infrared image recognition device provided in an embodiment of the present invention. Detailed Implementation
[0010] The principles and features of the present invention are described below with reference to the accompanying drawings. The examples given are only for explaining the present invention and are not intended to limit the scope of the present invention.
[0011] Example 1: As Figure 1 As shown, this embodiment of the invention provides a method for identifying wild animals using infrared images based on Improved-YOLOv7, including the following steps: S1. Collect a dataset of infrared camera images containing wild animals, and label all wild animal infrared camera images in the dataset with species. Divide the labeled infrared camera image dataset into a training set and a validation set. S2. Construct the CBMA-E-ELAN module, replace the E-ELAN module of the backbone network in the YOLOv7 basic model with the CBMA-E-ELAN module, and optimize the target candidate box of the YOLOv7 basic model to obtain the Improved-YOLOv7 wildlife recognition model. S3. Train the Improved-YOLOv7 wildlife recognition model using the training set to obtain the trained Improved-YOLOv7 wildlife recognition model; S4. Input the validation set into the trained Improved-YOLOv7 wildlife recognition model and output the wildlife classification results.
[0012] In the above embodiments, an infrared camera image dataset containing wild animals is collected and species are labeled. The dataset is divided into training and validation sets, providing standardized and high-quality dedicated dataset support for the training and validation of the improved model.
[0013] A CBMA-E-ELAN module was constructed to replace the E-ELAN module in the backbone network of the YOLOv7 basic model. The target candidate boxes of the YOLOv7 basic model were also optimized to obtain the Improved-YOLOv7 wildlife recognition model. To address the issues of insufficient feature extraction capability and poor candidate box adaptability of the YOLOv7 basic model in wildlife infrared image recognition, targeted improvements were made to both the backbone network and the candidate boxes. This ensured that the core modules of the improved model were adapted to the visual features and target morphological characteristics of wildlife infrared images, thus forming a dedicated wildlife infrared image recognition model.
[0014] The Improved-YOLOv7 wildlife recognition model was trained using a training set to obtain the trained Improved-YOLOv7 wildlife recognition model. The improved model then completed autonomous learning and parameter iteration of wildlife infrared image features on a dedicated training set, enabling the model to memorize the infrared image feature patterns, morphological differences, and target boundary features of different wildlife. This transformed the improved module structure into actual recognition capabilities, realizing the transformation of the model from "structural improvement" to "capability." Through training and validation on labeled datasets, the reliability of the model's recognition results was ensured, achieving effective classification and recognition of wildlife infrared images.
[0015] Preferably, an infrared camera image dataset containing wild animals is collected, and all wild animal infrared camera images in the dataset are labeled with their species. The labeled infrared camera image dataset is then divided into a training set and a validation set. Specifically: The data collected in this embodiment comes from wildlife images captured by infrared-triggered cameras deployed in various nature reserves in a certain province. A total of 38,629 images and 3,547 videos were collected. The videos were segmented into frames using OpenCV, and invalid images were removed, resulting in 27,002 images. Animal experts categorized the images, and LabelImg software was used to label the 27,002 images of wildlife in complex environments, forming the wildlife infrared camera image recognition dataset InfraredAnimal81. This dataset includes 81 animal species, such as the spotted dove, Tibetan macaque, and mandarin duck. Because the dataset contains males, females, and offspring, there are significant differences in morphological characteristics, such as silver pheasant, white-browed partridge, mandarin duck, black-necked long-tailed pheasant, golden pheasant, and red junglefowl. Researchers combined geometric morphology and deep learning to define the animal dataset as having 88 categories. During the dataset construction process, the images were divided into training and validation sets in an 8:2 ratio. The dataset observes and records various characteristics of animals, such as image texture and color, shape, geometric morphology, and potential influencing factors. The wildlife images in the dataset contain a range of complex scenes, including (A) a single target, (B) multiple targets (of the same species), (C) multiple targets (of different species), (D) different sexes of the same species, (E) fog, (F) nighttime, (G) complex background, (H) blur, and (I) occlusion.
[0016] Preferably, species labeling is performed on all wildlife infrared camera images in the infrared camera image dataset, including: Using image annotation tools and based on the morphological differences of wild animals, all images containing wild animals in the infrared camera image dataset are labeled with their species, and a unique wild animal category label is determined for each wild animal infrared camera image, thus completing the species labeling of the infrared camera image dataset.
[0017] In the above embodiments, image annotation tools are used to annotate infrared images containing wild animals based on differences in their morphological characteristics, so that the annotation results of the dataset are consistent with the actual morphological characteristics of wild animals and the accuracy of the annotation is improved.
[0018] By assigning a unique wildlife category label to each wildlife infrared camera image, the standardization of dataset annotation is achieved, avoiding label confusion and improving the usability of the dataset.
[0019] By fully annotating all categories of the infrared camera image dataset, a completely labeled dataset is obtained, providing a foundation for feature learning without missing data for subsequent model training.
[0020] Preferably, a CBMA-E-ELAN module is constructed, replacing the E-ELAN module of the backbone network in the YOLOv7 basic model, including: Based on the E-ELAN module of the backbone network in the YOLOv7 basic model, a CBMA dual attention mechanism module is introduced. This CBMA dual attention mechanism module replaces the last BConv in the E-ELAN module, thus constructing the CBMA-E-ELAN module. The E-ELAN module receives infrared images of wildlife, extracts basic feature data from them, and transmits the extracted basic feature data to the CBMA dual attention mechanism module. The CBMA dual attention mechanism module includes a CAM channel attention module and a SAM spatial attention module, and processes the basic feature data sequentially according to a preset data processing procedure. This preset data processing procedure is as follows: First, the CAM channel attention module receives the basic feature data and performs channel-dimensional filtering on the basic feature data to select channel feature data related to the morphological differences of the labeled wild animals. The channel feature data is then deredundant, and the target channel feature data obtained after redundancy processing is transmitted to the SAM spatial attention module. The SAM spatial attention module then refines the target channel feature data at the pixel level to obtain pixel-level detail features corresponding to the morphological differences of wild animals.
[0021] The following is through Figure 2 The overall structure of the CBMA-E-ELAN module is introduced.
[0022] 1. Initial Feature Extraction Stage (Left Side BConv) After the infrared images of wild animals are transmitted through the model input layer (640×640 size, consistent with the experimental parameters), they are first processed by multiple rounds of BConv modules; The consecutive "BConv" in the diagram represent standard convolutions with different functionalities: The first round of BConv (k=1, s=1): point convolution kernel operation, keeping the image width and height unchanged, to achieve preliminary adjustment of the channel dimension and filter background noise in the infrared image; Subsequent BConv(k=3,s=1): 3×3 convolution kernel operation to further extract shallow features of the image (such as wildlife outlines and textures), while the length and width remain unchanged; This provides high-quality basic feature data for subsequent core improvement modules (CBMA-E-ELAN), avoiding noise interference from the original infrared images that could affect the feature refinement effect.
[0023] 2. Core Feature Refinement Stage (CBMA-E-ELAN Module) The basic feature data after initial BConv processing is directly input into the CBMA-E-ELAN module; First, the basic features are extracted via multi-path extraction using the original E-ELAN structure (preserving group convolution and gradient path control capabilities). Replace the last BConv in the original E-ELAN with a CBMA dual attention module, and then perform "CAM channel filtering → redundancy removal → SAM pixel thinning" in sequence: CAM Channel Attention Module: Filters channel features related to morphological differences in wild animals (such as channels for morphological differences between males and females, and between adults and juveniles), and removes redundant channels; SAM Spatial Attention Module: Refines the filtered channel features at the pixel level to capture subtle morphological details of wild animals in infrared images (such as feather texture and limb outline). Achieving "precise screening + detail enhancement" of basic features, and solving the problem of insufficient capture of subtle features in infrared images by the original E-ELAN module of YOLOv7, is the core of this invention to improve recognition accuracy.
[0024] 3. Feature enhancement and fusion stage (BConv+cat on the right) Process: The refined features output by the CBMA-E-ELAN module are first further enhanced by the BConv module through multiple rounds (adjusting channel dimensions and optimizing feature expression), and then spliced and fused with feature maps of other levels (such as the shallow features output by the initial BConv) through the "cat" operation; Here, BConv primarily uses "k=3, s=1" to ensure that the feature width and height remain unchanged, and only optimizes the feature quality; The "cat" operation combines shallow features (rich in location information, suitable for determining the location of wild animals in infrared images) with deep, refined features (rich in semantic information, suitable for category recognition) to form a comprehensive feature with both "location and recognition" advantages. It compensates for the information deficiencies of single-level features, providing comprehensive and accurate feature support for target bounding box regression and category classification in subsequent detection heads.
[0025] Specifically, the CAM channel attention module first receives the basic feature data and performs channel-dimensional filtering on the basic feature data. The CAM channel attention module achieves feature filtering through channel weight calculation, and its channel attention weight calculation formula is as follows: , in, Here is the channel attention weight matrix. The basic feature data is the input. It is the Sigmoid activation function. This is a global average pooling operation. This is a global max pooling operation. For feature splicing operations; The attention weight of each channel is calculated using the channel attention weight calculation formula. The basic feature data is then weighted and filtered to select the channel feature data that is related to the differences in the morphological features of the labeled wild animals. The channel feature data is then deredundant and the target channel feature data obtained after the redundancy processing is transmitted to the SAM spatial attention module. The SAM spatial attention module refines the target channel feature data at the pixel level. This pixel feature refinement is achieved through spatial weight calculation, and the formula for calculating the spatial attention weight is as follows: , in, Here is the spatial attention weight matrix. For 7×7 convolution operations, , The results are the transposed results of global average pooling and global max pooling of the feature data along the channel dimension. The attention weight of each pixel position is calculated by the spatial attention weight calculation formula. The target channel feature data is then weighted and refined to obtain pixel-level detail features corresponding to the differences in morphological features of wild animals.
[0026] In the above embodiments, based on the E-ELAN module of the backbone network in the YOLOv7 basic model, a CBMA dual attention mechanism module is introduced. The CBMA dual attention mechanism module replaces the last BConv in the E-ELAN module, thereby constructing the CBMA-E-ELAN module. This retains the original basic feature extraction capabilities of the E-ELAN module, such as group convolution and gradient path control, and avoids the loss of basic capabilities due to module reconstruction. By replacing the last BConv and introducing the CBMA dual attention mechanism, a feature refinement and enhancement stage is added after basic feature extraction. This compensates for the E-ELAN module's deficiency in capturing subtle features in infrared images, and achieves the fusion of feature processing capabilities of "basic extraction + fine enhancement".
[0027] The E-ELAN module receives infrared images of wildlife, extracts basic feature data from them, and transmits the extracted feature data to the CBMA dual attention mechanism module. This enables efficient reception and basic feature extraction of wildlife infrared images, quickly capturing shallow basic features such as contours and textures in the images, providing a data foundation for subsequent fine feature processing. The directional feature data transmission achieves seamless connection between modules, avoiding loss and redundancy of feature data during transmission and ensuring the continuity of the feature processing flow.
[0028] The CAM channel attention module receives basic feature data and performs channel-dimensional filtering on the basic feature data. It filters out channel feature data that is related to the differences in the morphological characteristics of the labeled wild animals. Based on the distribution characteristics of infrared image features in different channels, the CAM channel attention mechanism selectively filters the feature data in the channel dimension, focuses on the key channel information related to the differences in the morphological characteristics of wild animals, and removes invalid data from irrelevant channels such as background and noise. This ensures that subsequent feature processing is only for the core effective channels, improving the targeting and efficiency of feature processing.
[0029] The CAM channel attention module performs redundancy removal on the filtered channel feature data and transmits the target channel feature data obtained after redundancy removal to the SAM spatial attention module. This removes duplicate and similar redundant information from the channel feature data, compresses the amount of feature data, reduces the computational cost of subsequent feature processing, and improves the running efficiency of feature processing. At the same time, the target channel feature data after redundancy removal is more representative and can accurately reflect the differences in morphological characteristics of wild animals, providing a high-quality channel feature foundation for fine processing at the pixel level.
[0030] The SAM spatial attention module refines the target channel feature data at the pixel level. To address the issues of blurred pixel-level details and low contrast in infrared images of wild animals, the SAM spatial attention mechanism focuses and enhances the target channel feature data at the pixel level, accurately capturing the spatial correlation features between pixels, improving the pixel distinction between wild animals and the background, and compensating for the inherent defects of infrared images in terms of pixel detail.
[0031] The SAM spatial attention module obtains pixel-level detail features corresponding to the differences in morphological characteristics of wild animals, and accurately extracts pixel-level details corresponding to the differences in morphological characteristics of wild animals such as male and female, adults and cubs, so as to achieve accurate differentiation of the features of wild animals with different forms; at the same time, the highly recognizable pixel-level detail features can provide core basis for the model's subsequent target recognition and classification, and greatly improve the model's recognition accuracy of wild animals with subtle morphological differences.
[0032] Preferably, the target candidate boxes of the YOLOv7 base model are optimized to obtain the Improved-YOLOv7 wildlife recognition model, including: The K-means clustering algorithm is used to replace the Autoachor candidate box algorithm in the YOLOv7 base model, specifically: Using the labeled wildlife infrared camera image dataset as clustering samples, clustering calculations are performed on the target bounding boxes corresponding to all images containing wildlife in the dataset. Multiple candidate box aspect ratios that match the wildlife target morphology in the dataset are obtained through clustering calculations. These candidate box aspect ratios are then used as new target candidate box parameters for the YOLOv7 base model, replacing the original candidate box parameters. Combined with the improved CBMA-E-ELAN backbone network module, the optimized YOLOv7 base model is integrated and debugged to ensure that the candidate box parameters match the feature extraction logic of the improved backbone network. This achieves accurate matching between the target candidate boxes and the wildlife infrared image features, ultimately resulting in the Improved-YOLOv7 wildlife recognition model.
[0033] Specifically, anchor boxes play a crucial role in object detection by matching potential target regions of various shapes and sizes. Anchors tailored to the dataset can efficiently locate and identify targets, significantly improving detection efficiency, recall, and accuracy. This work employs the K-means clustering algorithm to optimize anchor boxes, obtaining anchor values that fit the InfraredAnimal81 dataset. Compared to the Autoachor calculation method of the YOLOv7 base model, the K-means clustering algorithm yields anchors with higher similarity and a better fit to the dataset. In this embodiment, the aspect ratios of the nine bounding boxes are recalculated using the K-means clustering algorithm: (24,37), (33,76), (46,46), (56,118), (67,70), (114,97), (90,150), (159,173), and (271,296), improving target localization efficiency and accuracy.
[0034] In the above embodiments, the K-means clustering algorithm is used to replace the Autoachor candidate box algorithm in the YOLOv7 base model. The general Autoachor candidate box algorithm in the YOLOv7 base model is replaced by the K-means clustering algorithm, which is trained on a general dataset and has poor adaptability to the target morphology of wildlife infrared images. The K-means clustering algorithm is an unsupervised clustering algorithm that can realize personalized candidate box calculation based on the proprietary dataset of this patent, thus solving the mismatch between the general algorithm and the specific recognition scenario.
[0035] Using the labeled wildlife infrared camera image dataset as clustering samples, clustering calculations are performed on the target bounding boxes corresponding to all images containing wildlife in the dataset. Using the labeled dedicated dataset as clustering samples ensures that the sample data for clustering calculations closely matches the wildlife infrared image recognition scenario. Clustering calculations on target bounding boxes can accurately capture the length and width distribution patterns of wildlife target bounding boxes in the dataset, providing a sample basis that fits the actual scenario for subsequent candidate box parameter calculations.
[0036] Clustering calculations yield multiple candidate bounding box aspect ratios that match the morphology of wild animal targets in the wild animal infrared camera image dataset. The aspect ratios of the candidate bounding boxes obtained through clustering calculations are derived from the actual bounding box features of wild animal targets within the dataset. This approach can accurately match the morphological characteristics of wild animals of different species and sizes in the dataset, thus solving the problem of bounding box selection deviation caused by the mismatch between the aspect ratio of the general candidate bounding boxes and the morphology of wild animal targets.
[0037] The aspect ratio of the candidate boxes obtained from clustering is used as the new target candidate box parameters of the YOLOv7 base model, replacing the original candidate box parameters in the YOLOv7 base model. Personalized candidate box parameters that fit the target morphology of wildlife infrared images are used to replace the original general candidate box parameters in the model, making the target candidate box parameters of the model strongly adapted to the recognition scene. The updated parameters enable the model to output candidate boxes that fit the actual morphology of wildlife in the early stage of target detection, laying a precise box selection foundation for subsequent target localization and recognition.
[0038] By integrating and debugging the improved CBMA-E-ELAN backbone network module with the optimized candidate boxes, the improved backbone network module and the optimized candidate box parameters are integrated and debugged in a coordinated manner to avoid compatibility issues caused by independent improvements to modules and parameters. Through debugging, the target localization logic of the candidate boxes and the feature extraction logic of the backbone network are highly matched to achieve collaborative work of "feature extraction-target localization" and improve the overall operational coordination and processing efficiency of the model.
[0039] Ensuring that the candidate box parameters match the feature extraction logic of the improved backbone network enables precise adaptation between the target candidate boxes and the features of wildlife infrared images. This allows the candidate boxes to be accurately located based on the wildlife infrared image features extracted by the backbone network, avoiding the problem of "feature matching but box selection deviation" caused by the disconnect between candidate box location and feature extraction. Achieving precise adaptation between candidate boxes and wildlife infrared image features can significantly improve the model's box selection accuracy for wildlife targets and reduce problems such as missed boxes, incorrect boxes, and incomplete box selection.
[0040] After integration and debugging, the improved-YOLOv7 wildlife recognition model was finally obtained. The model backbone network and target candidate boxes were improved and integrated in a coordinated manner, so that the two core links of feature extraction and target localization can be adapted to the wildlife infrared image recognition scene. The resulting Improved-YOLOv7 wildlife recognition model is a dedicated recognition model with a complete structure, matching parameters, and high collaborative efficiency, possessing wildlife infrared image recognition capabilities far exceeding those of the basic model.
[0041] Preferably, multiple candidate bounding box aspect ratios that match the morphology of wild animal targets in the wild animal infrared camera image dataset are obtained through clustering calculation. These candidate bounding box aspect ratios are then used as new target candidate box parameters in the YOLOv7 base model, replacing the original candidate box parameters in the YOLOv7 base model. This includes: The K-means clustering algorithm was used, with the labeled wildlife infrared camera image dataset as the clustering sample. Clustering calculations were performed on the bounding boxes corresponding to all images containing wildlife in the dataset. During the clustering process, the Euclidean distance formula was used to calculate the similarity between the bounding boxes to achieve the clustering grouping of the bounding boxes. The Euclidean distance formula is as follows: , in, Represents two target bounding boxes and The similarity distance between them , These are the target bounding boxes. Length and width, , These are the target bounding boxes. Length and width; Clustering was used to calculate the aspect ratios of multiple candidate bounding boxes that matched the morphology of wild animal targets in the wild animal infrared camera image dataset. Specifically: For each group of target bounding boxes after clustering, the mean of the length and width of all target bounding boxes in each group is calculated. The mean of the length and width is used as the representative of the target bounding box to obtain the aspect ratio corresponding to each group of bounding boxes. The aspect ratio is adapted to the wild animal target morphology of the corresponding group to obtain multiple candidate box aspect ratios. The aspect ratios of the candidate boxes obtained by clustering are used as new target candidate box parameters of the YOLOv7 base model and replace the original candidate box parameters in the YOLOv7 base model.
[0042] In the above embodiments, the K-means clustering algorithm is used, with the labeled wildlife infrared camera image dataset as the clustering sample. Clustering calculation is performed on the target bounding boxes corresponding to all images containing wildlife in the dataset. Based on the unsupervised clustering characteristics of the K-means clustering algorithm, no manual classification criteria are required. It can automatically achieve clustering based on the length and width features of the target bounding boxes, improving the objectivity and scientificity of the clustering calculation. Using a dedicated dataset as the sample ensures that the clustering results closely match the target bounding box features of the wildlife infrared images, avoiding clustering bias caused by general samples.
[0043] The clustering calculation process uses the Euclidean distance formula to calculate the similarity between target bounding boxes, thereby achieving the clustering and grouping of bounding boxes. The Euclidean distance formula quantifies the similarity between target bounding boxes into specific values, providing a clear mathematical basis for clustering and grouping, and avoiding subjective judgment errors in the clustering process. Based on the numerical similarity, accurate clustering of bounding boxes is achieved, which can group wild animal target bounding boxes with similar length and width features into one group, ensuring that each group of bounding boxes has uniform morphological and dimensional features.
[0044] For each group of target bounding boxes after clustering, the mean length and width of all target bounding boxes in each group are calculated. The mean length and width of the group represent the core features of the bounding boxes in that group. This can eliminate the length and width deviations of individual bounding boxes in the group caused by annotation errors and image blurring, and obtain more representative and stable bounding box feature parameters, thereby improving the reliability of candidate box parameters.
[0045] Using the average length and width as the representative of the current group of target bounding boxes, the aspect ratio of each group of bounding boxes is obtained. The mean within the group is transformed into the aspect ratio of the candidate boxes that can be directly recognized by the model, realizing the effective transformation of clustering results into model parameters. Each group of bounding boxes corresponds to a unique aspect ratio, which allows the model to match exclusive candidate boxes for wild animal targets of different shapes and sizes, improving the adaptability of candidate boxes to wild animal targets of different sizes.
[0046] The aspect ratio is matched with the morphology of the corresponding group of wild animals to obtain multiple candidate box aspect ratios. Each aspect ratio is highly consistent with the actual morphological size of the corresponding group of wild animals, which can accurately match wild animal targets of different species and sizes. The multiple candidate box aspect ratios form a complete personalized candidate box parameter system, covering the morphological and size characteristics of various wild animals in the dataset, and solving the problem of insufficient adaptability of single candidate box parameters in general models.
[0047] The aspect ratio of the candidate boxes obtained from clustering is used as the new target candidate box parameters of the YOLOv7 base model, replacing the original candidate box parameters in the YOLOv7 base model. Personalized candidate box parameters obtained from clustering based on a dedicated dataset are used to replace the original general candidate box parameters in the model, making the target candidate box parameters of the model strongly correlated with the target morphological features of wildlife infrared images. After the replacement, the model can call the corresponding candidate boxes according to the actual shape and size of the wildlife, which greatly improves the accuracy of target localization and reduces localization errors caused by mismatched candidate boxes.
[0048] The following is through Figure 3 The overall architecture of the wildlife infrared image recognition model is introduced.
[0049] Core architecture components (from bottom to top / input to output): 1. Input Layer Input data: Infrared images of wild animals with dimensions of 640×640×3 (3 are RGB channels, adapted to the digital processing requirements of infrared images). Function: Receives raw infrared image data, providing the input basis for subsequent feature extraction, which perfectly matches the experimental setting of "the input image size is fixed at 640×640".
[0050] 2. Backbone layer Core modules: CBMA-E-ELAN module (replacing the original E-ELAN module in YOLOv7), BConv (standard convolutional layer), MPConv (downsampling convolutional layer); Structural logic: After the raw infrared image undergoes multiple rounds of BConv convolutional layers to initially extract shallow features, it is fed into the core improvement module—the CBMA-E-ELAN module. After the CBMA-E-ELAN module completes the "basic feature extraction + channel-spatial dual attention refinement", the feature map size is reduced and the feature dimension is increased through the MPConv downsampling convolutional layer; The hierarchical structure of “BConv→CBMA-E-ELAN→MPConv” is repeated multiple times to gradually extract the infrared image features of wild animals (such as outlines, textures, morphological details, etc.) from shallow to deep layers.
[0051] 3. Feature Fusion Layer (Catconv) Function: The "cat (feature concatenation)" operation is used to fuse feature maps of different levels and scales (e.g., 80×80×N, 40×40×N, 20×20×N, where N is the number of feature channels). Function: It integrates shallow features (rich in localization information) and deep features (rich in semantic information) to provide more comprehensive feature support for subsequent target detection, and solves the dual needs of "accurate localization + accurate recognition" for wildlife targets in infrared images.
[0052] 4. Detect the head layer. Core modules: SPPCSPC (Spatial Pyramid Pooling Module), REP Conv (Reparameterized Convolutional Layer); Function: The SPC module performs multi-scale pooling on the fused feature maps to enhance the model's adaptability to wild animal targets of different sizes (such as the size difference between cubs and adults). REP Conv improves feature extraction efficiency and model inference speed through reparameterization optimization, while further refining features to provide accurate feature basis for target classification and bounding box regression.
[0053] 5. Output Layer Output: Wildlife category classification results + target bounding box coordinates.
[0054] Example 2: As Figure 4 As shown, this embodiment of the invention also provides a wildlife infrared image recognition device, comprising: The image dataset construction module is used to collect infrared camera image datasets containing wild animals, and to label all wild animal infrared camera images in the infrared camera image datasets by species. The labeled infrared camera image datasets are then divided into training sets and validation sets. The model improvement building module is used to build the CBMA-E-ELAN module, replace the E-ELAN module of the backbone network in the YOLOv7 basic model with the CBMA-E-ELAN module, and optimize the target candidate boxes of the YOLOv7 basic model to obtain the Improved-YOLOv7 wildlife recognition model. The model training module is used to train the Improved-YOLOv7 wildlife recognition model using the training set, so as to obtain the trained Improved-YOLOv7 wildlife recognition model. The image recognition output module is used to input the validation set into the trained Improved-YOLOv7 wildlife recognition model and output the wildlife classification results.
[0055] Preferably, a CBMA-E-ELAN module is constructed, replacing the E-ELAN module of the backbone network in the YOLOv7 basic model, including: Based on the E-ELAN module of the backbone network in the YOLOv7 basic model, a CBMA dual attention mechanism module is introduced. This CBMA dual attention mechanism module replaces the last BConv in the E-ELAN module, thus constructing the CBMA-E-ELAN module. The E-ELAN module receives infrared images of wildlife, extracts basic feature data from them, and transmits the extracted basic feature data to the CBMA dual attention mechanism module. The CBMA dual attention mechanism module includes a CAM channel attention module and a SAM spatial attention module, and processes the basic feature data sequentially according to a preset data processing procedure. This preset data processing procedure is as follows: First, the CAM channel attention module receives the basic feature data and performs channel-dimensional filtering on the basic feature data to select channel feature data related to the morphological differences of the labeled wild animals. The channel feature data is then deredundant, and the target channel feature data obtained after redundancy processing is transmitted to the SAM spatial attention module. The SAM spatial attention module then refines the target channel feature data at the pixel level to obtain pixel-level detail features corresponding to the morphological differences of wild animals.
[0056] Preferably, the target candidate boxes of the YOLOv7 base model are optimized to obtain the Improved-YOLOv7 wildlife recognition model, including: The K-means clustering algorithm is used to replace the Autoachor candidate box algorithm in the YOLOv7 base model, specifically: Using the labeled wildlife infrared camera image dataset as clustering samples, clustering calculations are performed on the target bounding boxes corresponding to all images containing wildlife in the dataset. Multiple candidate box aspect ratios that match the wildlife target morphology in the dataset are obtained through clustering calculations. These candidate box aspect ratios are then used as new target candidate box parameters for the YOLOv7 base model, replacing the original candidate box parameters. Combined with the improved CBMA-E-ELAN backbone network module, the optimized YOLOv7 base model is integrated and debugged to ensure that the candidate box parameters match the feature extraction logic of the improved backbone network. This achieves accurate matching between the target candidate boxes and the wildlife infrared image features, ultimately resulting in the Improved-YOLOv7 wildlife recognition model.
[0057] This invention provides a wildlife infrared image recognition device based on Improved-YOLOv7, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the wildlife infrared image recognition method based on Improved-YOLOv7 as described above.
[0058] This invention provides a computer-readable storage medium storing a computer program, characterized in that, when the computer program is executed by a processor, it implements the improved-YOLOv7-based method for identifying wild animal infrared images as described above.
[0059] The accuracy of the Improved-YOLOv7 wildlife identification model in the examples is evaluated through the following experiments.
[0060] The experimental hardware and software environment was set up, the model evaluation metrics were determined, and various experimental schemes were designed. The model was trained, validated, and tested based on a self-made dataset to ensure the fairness and effectiveness of the experiment.
[0061] 1. Experimental environment setup: Software framework: Model training is based on the PyTorch 1.13.0 deep learning framework.
[0062] Hardware specifications: It features an i9-13900K CPU, an NVIDIA RTX 4090 GPU, and 64GB of RAM.
[0063] 2. Evaluation Metrics Determination: Mean Precision (AP) and Mean Recall (AR) are selected as the core evaluation metrics, where AP reflects the prediction error rate and AR reflects the prediction false negative rate. Precision and Recall are also calculated as basic metrics, using the following formulas: Among them, TP is the number of correctly identified samples, FP is the number of incorrectly identified samples, FN is the number of missed samples, and AP50, AP75, APM, APL and ARM, ARL and other sub-indicators are further subdivided to comprehensively evaluate the model performance; 3. Setting basic experimental parameters: All detection algorithms used in the experiment employed pre-trained models from the Microsoft COCO dataset for transfer learning to reduce training costs and improve efficiency. The core parameters for model training were uniformly set as follows: 50 iterations, an initial learning rate of 0.001, an SGD optimizer with a momentum of 0.9, a weight decay of 0.0005, a fixed input image size of 640×640, and a batch size of 8. All parameters remained constant throughout the experiment to ensure fairness.
[0064] This experiment consists of three sub-experiments: ablation experiment, quantitative analysis experiment, and qualitative analysis experiment. These three sets of experiments complement each other to comprehensively verify the effectiveness of the improved scheme of this patent. The specific design is as follows: 1) Ablation experiment: Objective: To verify the individual and synergistic effects of the two core improvement schemes proposed in this patent (CBMA-E-ELAN module replacement and target candidate box K-means clustering optimization), and to clarify the contribution of each improvement point to the model recognition performance.
[0065] Experimental design: Four control models were set up, with all other experimental parameters remaining the same as the baseline settings, only the model improvement method was changed: 1. Control group 1: Original YOLOv7 model (no improvements, using the Autoachor candidate box algorithm, with the backbone network being the original E-ELAN module). 2. Experimental Group 1: Only the backbone network was replaced (the original E-ELAN module was replaced with the CBMA-E-ELAN module, and the candidate boxes were still generated using the Autoachor algorithm). 3. Experimental Group 2: Only candidate boxes were optimized (K-means clustering algorithm was used to optimize candidate box parameters, while the backbone network remained the original E-ELAN module). 4. Experimental Group 3: The Improved-YOLOv7 model of this invention (simultaneously replacing the backbone network and optimizing the candidate boxes, i.e., the two improvements work synergistically).
[0066] Experimental procedure: The four models were trained 50 times on the training set and their performance was tested on the validation set. The core evaluation metrics (AP, AR) and basic evaluation metrics (precision, recall) of each model were recorded, and the effects of each improvement scheme were compared and analyzed.
[0067] 2) Quantitative analysis experiment Objective: To verify the superior positioning accuracy, recognition accuracy, and overall performance of the Improved-YOLOv7 model of this invention compared with existing mainstream YOLO series models in the infrared image recognition of wild animals.
[0068] Experimental Design: Four mainstream YOLO models were selected as comparison models to compare their performance with the patented Improved-YOLOv7 model. All models used the same experimental environment, dataset, and basic parameters to ensure fairness in the experiment. Comparison models: YOLOv3, YOLOv5, YOLOv9, YOLOv10 (all using their respective default structures, based on COCO pre-trained model transfer learning, with 50 training iterations). Experimental procedure: After training all models on the training set, they were input into the validation set for recognition testing. The core evaluation metrics (AP, AR) and sub-metrics (AP50, AP75, APM, APL, ARM, ARL) and basic evaluation metrics (precision, recall) of each group of models were statistically analyzed to form a quantitative comparison table, clarifying the performance advantages of the model of this invention.
[0069] 3) Qualitative analysis experiment Objective: To verify the robustness of the Improved-YOLOv7 model in complex scenarios and to solve the problems of false detection, missed detection, and multiple detection in existing comparison models for wildlife infrared image recognition.
[0070] Experimental Design: Representative complex scene images from the validation set were selected, covering five typical scene types. The recognition results of the proposed model were then visually compared with those of all comparison models. Typical scenarios: single target clear scene, multiple target overlapping scene, foggy blurry scene, low brightness scene at night, wild animal partially occluded scene; Experimental Procedure: Infrared images of various scenes were input into all experimental models to obtain the recognition results of each model (target selection position, category labeling). The selection accuracy and category recognition accuracy of each model were compared and analyzed intuitively. The focus was on verifying whether the patented model could effectively reduce false detections, missed detections, and multiple detections in complex scenes and improve recognition robustness.
[0071] 4) Experimental Results and Analysis Ablation Experiment Results and Analysis: Experimental Results: Experimental Group 3 (two improvements working together) showed significantly better performance in all evaluation metrics than Control Group 1 and other experimental groups. Specifically, compared to Control Group 1, AP improved by 8%-12%, AR improved by 7%-10%, and precision and recall improved by more than 6%. Experimental Groups 1 and 2 showed better performance than Control Group 1, but worse performance than Experimental Group 3. Among them, Experimental Group 1 (only replacing the backbone network) showed a higher AP improvement (5%-7%) than Experimental Group 2 (only optimizing candidate boxes) (3%-5%).
[0072] Analysis Conclusions: 1. The two improvement schemes proposed in this invention—CBMA-E-ELAN module replacement and K-means clustering optimization of target candidate boxes—can both effectively improve the model's recognition performance and have a positive effect when used alone; 2. When the two improvement schemes work together, they can achieve bidirectional optimization of "feature extraction + target localization," with a better improvement effect than individual improvements, verifying the rationality and synergy of the improvement schemes in this patent; 3. The CBMA-E-ELAN module contributes more to the model's recognition accuracy, mainly because this module can effectively capture subtle features corresponding to morphological differences in wild animals, making it suitable for infrared image recognition scenarios.
[0073] 5) Quantitative analysis results and analysis Experimental results: The improved-YOLOv7 model of this invention outperforms the comparative models of YOLOv3, YOLOv5, YOLOv9, and YOLOv10 on all evaluation metrics. The core advantages are as follows: 1. Core evaluation metrics: AP is improved by 3%-5% compared to the best comparison model (YOLOv10), AR is improved by 2%-4%, and AP50 (average precision at IoU=0.5) is improved by the most significant amount, reaching 4%-6%, indicating that the target recognition accuracy and recall rate of the model of this invention are both better. 2. Sub-indicator performance: The improvement in APM (medium-sized wild animals) and APL (large-sized wild animals) is greater than that in AP50, indicating that the patented model has a good recognition effect on wild animals of different sizes and has stronger adaptability; ARM and ARL are better than the comparison model, indicating that the model has a lower false negative rate. 3. Basic evaluation indicators: The precision rate reaches over 92% and the recall rate reaches over 90%, both higher than all the comparison models, indicating that the recognition accuracy of this patented model is higher and the probability of false recognition and false negatives is lower.
[0074] Analysis Conclusion: The Improved-YOLOv7 model of this invention, through targeted improvements, solves the problems of inaccurate feature extraction and poor candidate box adaptability of existing mainstream YOLO models in wildlife infrared image recognition. It has significant advantages in both positioning accuracy and recognition accuracy, and is more suitable for wildlife infrared image recognition scenarios.
[0075] 6) Qualitative analysis results and analysis Experimental results: In various complex scenarios, the recognition performance of the improved-YOLOv7 model of this invention is superior to the comparison model, specifically as follows: 1. Single target clear scene: All models can accurately identify, but the bounding box selection accuracy of this patent model is higher, the category labeling is more accurate, and there is no biased bounding box selection or incorrect labeling. 2. Multi-target overlapping scenarios: Compared with other models, which suffer from varying degrees of missed detection and overlapping bounding boxes, this patented model can accurately distinguish each overlapping target, achieving accurate bounding box selection and category recognition, with a missed detection rate of less than 5%. 3. Complex scenes such as foggy days and nights: Compared with the model, which suffers from false detection (misidentifying the background as wild animals) and false negative (failing to identify wild animals due to blurry images), the model of this invention can effectively filter background noise and capture the core features of wild animals, with both the false detection rate and the false negative rate being less than 3%. 4. Occlusion scenarios: Compared with the model, the recognition accuracy of wild animals with more than 30% occlusion drops significantly. This patented model can capture subtle morphological features that are not occluded through the CBMA-E-ELAN module, and the recognition accuracy is still maintained above 85%, with stronger anti-occlusion ability.
[0076] Analysis conclusion: The improved-YOLOv7 model of this invention has good robustness in complex scenarios, can effectively solve the problems of false detection, false negative detection, and false positive detection of existing comparison models, and is suitable for the actual identification scenarios of wildlife infrared images (complex outdoor environments), and has high practical application value.
[0077] 7) Conclusions from multiple experiments Verification through ablation experiments, quantitative analysis experiments, and qualitative analysis experiments, combined with the results of multiple sets of control experiments, shows that the wildlife infrared camera image recognition method based on Improved-YOLOv7 proposed in this invention, through dual improvements of CBMA-E-ELAN module replacement and K-means clustering optimization of target candidate boxes, can effectively improve the model's feature extraction capability, target localization accuracy, and recognition robustness. Compared with the original YOLOv7 model and existing mainstream YOLO series models, it has better recognition performance and stronger adaptability, and can effectively achieve accurate recognition of wildlife infrared images. It solves the problems of low recognition accuracy and poor robustness in complex scenes in existing technologies, and can be widely applied in practical scenarios of wildlife infrared image recognition.
[0078] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.
[0079] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the above-described apparatus and unit can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0080] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.
[0081] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of the embodiments of the present invention, depending on actual needs.
[0082] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0083] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for wildlife infrared image recognition based on Improved-YOLOv7, characterized in that, Includes the following steps: Collect a dataset of infrared camera images containing wild animals, and label all wild animal infrared camera images in the dataset with species. Then divide the labeled infrared camera image dataset into a training set and a validation set. Construct a CBMA-E-ELAN module, replace the E-ELAN module in the backbone network of the YOLOv7 basic model with the CBMA-E-ELAN module, and optimize the target candidate boxes in the YOLOv7 basic model to obtain the Improved-YOLOv7 wildlife recognition model. The Improved-YOLOv7 wildlife recognition model is trained using the training set to obtain the trained Improved-YOLOv7 wildlife recognition model. The validation set is input into the trained Improved-YOLOv7 wildlife recognition model, which outputs wildlife classification results.
2. The method for identifying wild animals using infrared images according to claim 1, characterized in that, The infrared camera images of all wild animals in the aforementioned infrared camera image dataset are labeled with their species, including: Using image annotation tools and based on the morphological differences of wild animals, all images containing wild animals in the infrared camera image dataset are labeled with their species, and a unique wild animal category label is determined for each wild animal infrared camera image, thus completing the species labeling of the infrared camera image dataset.
3. The method for identifying wild animals using infrared images according to claim 1, characterized in that, Constructing a CBMA-E-ELAN module, replacing the E-ELAN module in the backbone network of the YOLOv7 basic model, includes: Based on the E-ELAN module of the backbone network in the YOLOv7 basic model, a CBMA dual attention mechanism module is introduced. This CBMA dual attention mechanism module replaces the last BConv in the E-ELAN module, thus constructing the CBMA-E-ELAN module. The E-ELAN module receives infrared images of wildlife, extracts basic feature data from them, and transmits the extracted basic feature data to the CBMA dual attention mechanism module. The CBMA dual attention mechanism module includes a CAM channel attention module and a SAM spatial attention module, and processes the basic feature data sequentially according to a preset data processing procedure. This preset data processing procedure is as follows: First, the CAM channel attention module receives the basic feature data and performs channel-dimensional filtering on the basic feature data to select channel feature data related to the morphological differences of the labeled wild animals. The channel feature data is then deredundant, and the target channel feature data obtained after redundancy processing is transmitted to the SAM spatial attention module. The SAM spatial attention module then refines the target channel feature data at the pixel level to obtain pixel-level detail features corresponding to the morphological differences of wild animals.
4. The method for identifying wild animals using infrared images according to claim 1, characterized in that, The target candidate boxes of the YOLOv7 base model are optimized to obtain the Improved-YOLOv7 wildlife recognition model, which includes: The K-means clustering algorithm is used to replace the Autoachor candidate box algorithm in the YOLOv7 base model, specifically: Using the labeled wildlife infrared camera image dataset as clustering samples, clustering calculations are performed on the target bounding boxes corresponding to all images containing wildlife in the wildlife infrared camera image dataset. Through clustering calculations, multiple candidate box aspect ratios that are adapted to the wildlife target morphology in the wildlife infrared camera image dataset are obtained. The aspect ratios of the candidate boxes obtained by clustering are used as new target candidate box parameters of the YOLOv7 base model and replace the original candidate box parameters in the YOLOv7 base model, finally obtaining the Improved-YOLOv7 wildlife recognition model.
5. The method for identifying wild animals using infrared images according to claim 4, characterized in that, Clustering was used to calculate the aspect ratios of multiple candidate bounding boxes that matched the morphology of wild animals in the wildlife infrared camera image dataset. These candidate bounding box aspect ratios were then used as new target candidate box parameters in the YOLOv7 base model, replacing the original candidate box parameters in the YOLOv7 base model. The K-means clustering algorithm was used, with the labeled wildlife infrared camera image dataset as the clustering sample. Clustering calculations were performed on the bounding boxes corresponding to all images containing wildlife in the dataset. During the clustering process, the Euclidean distance formula was used to calculate the similarity between the bounding boxes to achieve the clustering grouping of the bounding boxes. The Euclidean distance formula is as follows: , in, Represents two target bounding boxes and The similarity distance between them , These are the target bounding boxes. Length and width, , These are the target bounding boxes. Length and width; Clustering was used to calculate the aspect ratios of multiple candidate bounding boxes that matched the morphology of wild animal targets in the wild animal infrared camera image dataset. Specifically: For each group of target bounding boxes after clustering, the mean of the length and width of all target bounding boxes in each group is calculated. The mean of the length and width is used as the representative of the target bounding box to obtain the aspect ratio corresponding to each group of bounding boxes. The aspect ratio is adapted to the wild animal target morphology of the corresponding group to obtain multiple candidate box aspect ratios. The aspect ratios of the candidate boxes obtained by clustering are used as new target candidate box parameters of the YOLOv7 base model and replace the original candidate box parameters in the YOLOv7 base model.
6. A wildlife infrared image recognition device, characterized in that, include: The image dataset construction module is used to collect infrared camera image datasets containing wild animals, and to label all wild animal infrared camera images in the infrared camera image datasets by species. The labeled infrared camera image datasets are then divided into training sets and validation sets. The model improvement building module is used to build the CBMA-E-ELAN module, replace the E-ELAN module of the backbone network in the YOLOv7 basic model with the CBMA-E-ELAN module, and optimize the target candidate boxes of the YOLOv7 basic model to obtain the Improved-YOLOv7 wildlife recognition model. The model training module is used to train the Improved-YOLOv7 wildlife recognition model using the training set, so as to obtain the trained Improved-YOLOv7 wildlife recognition model. The image recognition output module is used to input the validation set into the trained Improved-YOLOv7 wildlife recognition model and output the wildlife classification results.
7. The wildlife infrared image recognition device according to claim 6, characterized in that, Constructing a CBMA-E-ELAN module, replacing the E-ELAN module in the backbone network of the YOLOv7 basic model, includes: Based on the E-ELAN module of the backbone network in the YOLOv7 basic model, a CBMA dual attention mechanism module is introduced. This CBMA dual attention mechanism module replaces the last BConv in the E-ELAN module, thus constructing the CBMA-E-ELAN module. The E-ELAN module receives infrared images of wildlife, extracts basic feature data from them, and transmits the extracted basic feature data to the CBMA dual attention mechanism module. The CBMA dual attention mechanism module includes a CAM channel attention module and a SAM spatial attention module, and processes the basic feature data sequentially according to a preset data processing procedure. This preset data processing procedure is as follows: First, the CAM channel attention module receives the basic feature data and performs channel-dimensional filtering on the basic feature data to select channel feature data related to the morphological differences of the labeled wild animals. The channel feature data is then deredundant, and the target channel feature data obtained after redundancy processing is transmitted to the SAM spatial attention module. The SAM spatial attention module then refines the target channel feature data at the pixel level to obtain pixel-level detail features corresponding to the morphological differences of wild animals.
8. The wildlife infrared image recognition device according to claim 6, characterized in that, The target candidate boxes of the YOLOv7 base model are optimized to obtain the Improved-YOLOv7 wildlife recognition model, which includes: The K-means clustering algorithm is used to replace the Autoachor candidate box algorithm in the YOLOv7 base model, specifically: Using the labeled wildlife infrared camera image dataset as clustering samples, clustering calculations are performed on the target bounding boxes corresponding to all images containing wildlife in the wildlife infrared camera image dataset. Through clustering calculations, multiple candidate box aspect ratios that are adapted to the wildlife target morphology in the wildlife infrared camera image dataset are obtained. The aspect ratios of the candidate boxes obtained by clustering are used as new target candidate box parameters of the YOLOv7 base model and replace the original candidate box parameters in the YOLOv7 base model, finally obtaining the Improved-YOLOv7 wildlife recognition model.
9. A wildlife infrared image recognition device based on Improved-YOLOv7, characterized in that, The method includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the wildlife infrared image recognition method based on Improved-YOLOv7 as described in any one of claims 1 to 6.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the wildlife infrared image recognition method based on Improved-YOLOv7 as described in any one of claims 1 to 6.