Target detection method and device, model training method and device, equipment, medium and product
By using a diverse training sample image set in the object detection model and adjusting the parameters of the detection model, the problem of poor detection effect of small animals in the prior art is solved, and higher detection accuracy and adaptability are achieved.
Patent Information
- Application Number
- CN202411472756.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-21
- Publication Date
- 2025-02-07
AI Technical Summary
In the prior art, artificial intelligence algorithms have poor detection effects when detecting smaller animals, resulting in insufficient image detection accuracy.
By using a diverse set of training sample images in the object detection model, including target objects of different sizes, scenes and types, adjusting the parameters of the detection model to enable it to identify and detect target objects of different scales.
The target detection model's ability to detect targets of various scales is improved, the model's adaptability and generalization ability is enhanced, and higher detection accuracy is ensured.
Smart Images

Figure CN119399668A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of visual target detection, and in particular to a target detection method, model training method, device, equipment, medium and product. Background Art
[0002] Visual object detection technology is used in many fields. For example, in the field of agricultural production, there is a problem of animal intrusion causing crop damage and thus affecting economic benefits. Therefore, timely detection of animal intrusion by detecting animals is crucial to ensuring crop yield or quality.
[0003] In the existing technology, for animal intrusion detection, physical sensors, cameras, etc. are generally used to collect images, and then the images are detected through artificial intelligence algorithms. For example, YOLO (You Only Look Once) or other detection models are used to simultaneously predict multiple bounding boxes and category probabilities through a single neural network forward propagation.
[0004] However, current AI algorithms are only suitable for detecting large animals, but are less effective for detecting smaller animals, resulting in insufficient image detection accuracy. Summary of the invention
[0005] The present application provides a target detection method, model training method, device, equipment, medium and product to solve the technical problem of insufficient image detection accuracy in the prior art.
[0006] In a first aspect, the present application provides a target detection method, comprising:
[0007] Obtain the video to be detected in the preset area, where the preset area is the monitored area to be detected;
[0008] When a moving object is detected in the video to be detected, the image to be detected corresponding to the video to be detected is input into the target detection model to obtain a target detection result. The target detection model is obtained by training a preset detection model based on a training sample image set. The detection model is used to identify training sample images of different scales to adjust parameters. At least one of the size, scene and type of the target object in each training sample image in the training sample image set is different. The target detection result characterizes whether the moving object contains the detection object and the bounding box of the detection object.
[0009] Optionally, before detecting that there is a moving object in the video to be detected, the method further includes:
[0010] Obtaining time-series frame images of the video to be detected;
[0011] Comparing two consecutive frames in the time-series frame image to obtain a difference map, the difference map represents the change area between the two consecutive frames in the time-series frame image;
[0012] Based on the difference map, determine whether there is a moving object.
[0013] Optionally, before inputting the image to be detected corresponding to the video to be detected into the target detection model to obtain the target detection result, the method further includes:
[0014] Get weather information for a preset area;
[0015] According to the weather information of the preset area, the target parameters of the target detection model are adjusted to obtain the adjusted target detection model.
[0016] In a second aspect, the present application provides a model training method, comprising:
[0017] Determine a training sample image set, wherein at least one of the size, scene and type of the target object in each training sample image in the training sample image set is different;
[0018] The training sample image set is input into the preset detection model to obtain the initial target parameters of the detection model. The detection model is used to identify the training sample images of different scales to adjust the parameters;
[0019] Obtaining a first detection result corresponding to the training sample image according to the initial target parameters of the detection model, wherein the first detection result is a predicted category and a predicted bounding box of the target object determined based on the initial target parameters of the detection model;
[0020] According to the first detection result and the sample label corresponding to the pre-acquired training sample image, the initial target parameters of the detection model are adjusted to obtain the target detection model, and the sample label is the real category and real bounding box of the target object in each training sample image in the training sample image set.
[0021] Optionally, the training sample image set is input into a preset detection model to obtain initial target parameters of the detection model, including:
[0022] Adjusting each training sample image in the training sample image set to obtain training sample images of different sizes;
[0023] Label the training sample images of different sizes and determine the size of the bounding box of the target object;
[0024] Cluster the size of the bounding box of the target object and determine the size of the cluster center;
[0025] The size of the cluster center is used as the size of the anchor point of the preset detection model, and the preset detection model is trained according to the size of the anchor point of the preset detection model and training sample images of different sizes to obtain the initial parameters of the detection model;
[0026] The initial parameters of the detection model are adjusted to obtain the initial target parameters of the detection model.
[0027] Optionally, the initial parameters of the detection model are adjusted to obtain initial target parameters of the detection model, including:
[0028] The detection model is trained using actual data sets of the target application scenario, and the initial parameters of the detection model are adjusted to obtain the initial target parameters of the detection model. The detection model uses a feature layer whose correlation with the output layer is less than a preset threshold for feature extraction.
[0029] Optionally, obtaining a first detection result corresponding to the training sample image according to the initial target parameter of the detection model includes:
[0030] According to the initial target parameters of the detection model, the training sample image is downsampled to obtain feature map data;
[0031] The feature map data is divided into first data and second data, and the first data is sequentially subjected to deep convolution processing and point-by-point convolution processing, and input into two fully connected layers for feature fusion to obtain a high-level feature vector, and the second data is directly transferred to obtain the original feature vector;
[0032] The high-level feature vector and the original feature vector are subjected to feature fusion to obtain a first detection result corresponding to the training sample image.
[0033] Optionally, determining a training sample image set includes:
[0034] Acquire an initial image set, each initial image in the initial image set containing at least one object;
[0035] Data enhancement processing is performed on each initial image in the initial image set to obtain a training sample image set.
[0036] In a third aspect, the present application provides a target detection device, comprising:
[0037] An acquisition module is used to acquire a video to be detected in a preset area, where the preset area is the monitored area to be detected;
[0038] The first obtaining module is used to input the image to be detected corresponding to the video to be detected into the target detection model to obtain the target detection result when a moving object is detected in the video to be detected. The target detection model is obtained by training a preset detection model based on a training sample image set. The detection model is used to identify training sample images of different scales to adjust parameters. At least one of the size, scene and type of the target object in each training sample image in the training sample image set is different. The target detection result represents whether the moving object contains the detection object and the bounding box of the detection object.
[0039] Optionally, before detecting that there is a moving object in the video to be detected, the acquisition module is further used to:
[0040] Obtaining time-series frame images of the video to be detected;
[0041] Comparing two consecutive frames in the time-series frame image to obtain a difference map, the difference map represents the change area between the two consecutive frames in the time-series frame image;
[0042] Based on the difference map, determine whether there is a moving object.
[0043] Optionally, before inputting the image to be detected corresponding to the video to be detected into the target detection model to obtain the target detection result, the first obtaining module is further used to:
[0044] Get weather information for a preset area;
[0045] According to the weather information of the preset area, the target parameters of the target detection model are adjusted to obtain the adjusted target detection model.
[0046] In a fourth aspect, the present application provides a model training device, comprising:
[0047] A determination module, used to determine a training sample image set, wherein at least one of the size, scene and type of the target object in each training sample image in the training sample image set is different;
[0048] The second obtaining module is used to input the training sample image set into a preset detection model to obtain the initial target parameters of the detection model. The detection model is used to identify the training sample images of different scales to adjust the parameters;
[0049] A third obtaining module is used to obtain a first detection result corresponding to the training sample image according to the initial target parameters of the detection model, where the first detection result is a predicted category and a predicted bounding box of the target object determined based on the initial target parameters of the detection model;
[0050] The fourth obtaining module is used to adjust the initial target parameters of the detection model according to the sample labels corresponding to the first detection results and the pre-acquired training sample images to obtain the target detection model, wherein the sample labels are the true categories and true bounding boxes of the target objects in each training sample image in the training sample image set.
[0051] Optionally, the second obtaining module is specifically used for:
[0052] Adjusting each training sample image in the training sample image set to obtain training sample images of different sizes;
[0053] Label the training sample images of different sizes and determine the size of the bounding box of the target object;
[0054] Cluster the size of the bounding box of the target object and determine the size of the cluster center;
[0055] The size of the cluster center is used as the size of the anchor point of the preset detection model, and the preset detection model is trained according to the size of the anchor point of the preset detection model and training sample images of different sizes to obtain the initial parameters of the detection model;
[0056] The initial parameters of the detection model are adjusted to obtain the initial target parameters of the detection model.
[0057] Optionally, the second obtaining module is specifically used for:
[0058] The detection model is trained using actual data sets of the target application scenario, and the initial parameters of the detection model are adjusted to obtain the initial target parameters of the detection model. The detection model uses a feature layer whose correlation with the output layer is less than a preset threshold for feature extraction.
[0059] Optionally, the third obtaining module is specifically used for:
[0060] According to the initial target parameters of the detection model, the training sample image is downsampled to obtain feature map data;
[0061] The feature map data is divided into first data and second data, and the first data is sequentially subjected to deep convolution processing and point-by-point convolution processing, and input into two fully connected layers for feature fusion to obtain a high-level feature vector, and the second data is directly transferred to obtain the original feature vector;
[0062] The high-level feature vector and the original feature vector are subjected to feature fusion to obtain a first detection result corresponding to the training sample image.
[0063] Optionally, a module is determined, specifically for:
[0064] Acquire an initial image set, each initial image in the initial image set containing at least one object;
[0065] Data enhancement processing is performed on each initial image in the initial image set to obtain a training sample image set.
[0066] In a fifth aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;
[0067] Memory stores computer-executable instructions;
[0068] The processor executes the computer-executable instructions stored in the memory to implement the methods of the first aspect, the second aspect, and various possible implementations of the first aspect and the second aspect.
[0069] In a sixth aspect, the present application provides a computer-readable storage medium, comprising computer-executable instructions. When a processor executes the computer-executable instructions, it executes methods such as the first aspect, the second aspect, and various possible implementation methods of the first aspect and the second aspect mentioned above.
[0070] In a seventh aspect, the present application provides a program product, including a computer program, which is executed by a processor to implement methods such as the first aspect, the second aspect, and various possible implementation methods of the first aspect and the second aspect.
[0071] The target detection method, model training method, device, equipment, medium and product provided by the present application, when detecting the presence of a moving object in the video to be detected, input the image to be detected corresponding to the video to be detected into the target detection model to obtain the target detection result, so that the target detection model only performs detection when necessary, saving computing resources; by setting the size, scene and category of the target object in each training sample image in the training sample image set to be different, the target detection model can learn a wider range of features, which helps to improve the generalization ability of the model and enable it to perform better when facing target detection tasks under different conditions and environments; at the same time, the detection model recognizes and adjusts parameters of training sample images of different scales, so that the target detection model can detect small targets and large targets in the same image at the same time, thereby improving the detection ability of targets of various scales, so as to improve the adaptability of the target detection model; and then using the target detection model to detect the image to be identified to obtain the target detection result, ensuring that the target detection model can more accurately predict the category and bounding box of the detection object, and the obtained target detection result has a high accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0073] Figure 1 Schematic diagram of the model training method provided in the embodiment of the present application Figure 1 ;
[0074] Figure 2 Schematic diagram of the model training method provided in the embodiment of the present application Figure 2 ;
[0075] Figure 3 Schematic diagram of the model training method provided in the embodiment of the present application Figure 3 ;
[0076] Figure 4 A schematic diagram of a local structure of a detection model provided in an embodiment of the present application;
[0077] Figure 5 A schematic diagram of a target detection method provided in an embodiment of the present application;
[0078] Figure 6 A schematic diagram of the architecture of the target detection method provided in the embodiment of the present application;
[0079] Figure 7 A schematic diagram of the structure of a model training device provided in an embodiment of the present application;
[0080] Figure 8 A schematic diagram of the structure of a target detection device provided in an embodiment of the present application;
[0081] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0082] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0083] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0084] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0085] In the prior art, researchers in this field have proposed a variety of animal intrusion detection methods, covering physical sensors, cameras, and artificial intelligence algorithms to detect images. For example, a deep learning model is used to identify and locate multiple objects in an image, and the detection results are returned, thereby achieving the detection effect of detecting multiple categories or multiple animals in the image at the same time. However, these methods all rely on existing detection models based on artificial intelligence algorithms, which are more effective when detecting large animals, but for smaller animals, due to their unclear features, the detection effect may not meet expectations. At the same time, the actual detection scene is complex and changeable, and animals may block each other or blend with the background, resulting in false positives or missed positives.
[0086] In the process of solving the above technical problems, the inventors' technical ideas are as follows: in the prior art, the deep learning model only recognizes images of the same size and performs consistent calculations in each layer of the network, resulting in limited features learned by the model and poor detection accuracy for objects of different scales. If the detection model can detect training sample images of different scales, the model can learn how to process target objects of different sizes to improve the model's detection ability for target objects of various scales. Furthermore, in the multi-scale detection process, the complexity of the input data increases, which will lead to an increase in processing time cost. Therefore, if the parameters of the detection model are adjusted based on the multi-scale data, the model processing time can be improved and computing resources can be saved. In addition, the prior art ignores the influence of interference factors such as the environment in actual scenes. Therefore, if target objects of different sizes, types and at least one different scene are added to the training sample image set, a target detection model is obtained based on diversified training sample images, and the target detection model is used for recognition and prediction, which can more efficiently and flexibly cope with detection tasks in different scenes.
[0087] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0088] Before describing the target detection method, the target detection model involved in the embodiment of the present application is first introduced: Figure 1 Schematic diagram of the model training method provided in the embodiment of the present application Figure 1 .like Figure 1 As shown, the method may include the following steps:
[0089] S101, determining a training sample image set;
[0090] Among them, at least one of the size, the scene and the type of the target object in each training sample image in the training sample image set is different.
[0091] The execution subject of the embodiment of the present application is an electronic device, which can be a terminal device, such as a laptop, a desktop computer, a tablet computer, etc., or a server. In practical applications, whether the electronic device is a terminal device or a server can be determined according to actual conditions, and no specific limitation is imposed on this.
[0092] It should be noted that the training sample image set includes public standard data sets, such as COCO, PASCAL VOC, etc., as well as some images that are prone to false detection. The target objects in these images have at least one difference in size, scene and type, so that the target objects in the data set are diverse. For example, the target objects can be objects of different sizes, appearing in indoor or outdoor scenes, or different types of objects (such as vehicles, animals, people, etc.).
[0093] In this embodiment, the target object may refer to an animal, and the scene in which the target object is located may be a traffic artery, an industrial plant, a tourist attraction, a farmland, or other scenes where animals may appear.
[0094] It can be understood that by setting at least one target object of different size, scene and type in the training sample image set, it helps to improve the generalization ability of the model, enabling it to accurately detect target objects under different conditions, thereby reducing the false detection rate of the model.
[0095] S102, inputting the training sample image set into a preset detection model to obtain initial target parameters of the detection model;
[0096] Among them, the detection model is used to identify training sample images of different scales to adjust parameters.
[0097] In this embodiment, the detection model may refer to a YOLOv5 model, which extracts local features such as edges, textures, and shapes by sliding the convolution kernel of the convolutional layer in the convolutional neural network on the input image. Through multi-layer convolution operations, the network can learn higher-level feature representations to identify the target object.
[0098] In some embodiments, the detection model may also be other types of deep learning models, such as Faster R-CNN, Single Shot MultiBox Detector (SSD for short), etc.
[0099] It should be noted that the process of the detection model identifying training sample images of different scales to adjust parameters can be achieved through multi-scale dynamic training and network migration training.
[0100] Specifically, in the multi-scale dynamic training process, by setting the sizes of multiple training sample images and randomly selecting training sample images of these sizes during training, the detection model is trained to recognize training sample images of different scales.
[0101] Furthermore, the multi-scale anchor selection method based on the K-medoids algorithm can be combined to select data points in the training sample image set as cluster centers, and each data point is assigned to the nearest cluster center to form K clusters. For each cluster, a new cluster center is selected to minimize the total distance within the cluster, and the assignment and update steps are repeated until the cluster center no longer changes or the preset number of iterations is reached. Repeat the above process on training sample images of different scales to obtain anchor size sets at different scales. Thus, the anchor size obtained by clustering is updated to the configuration file of the training network, and the model is retrained using the updated anchor configuration, thereby improving the performance of the detection model.
[0102] During the network transfer training process, some layers of the detection model, such as the low-level feature layer close to the input layer, are frozen to retain the learned common features. Only the high-level feature layer close to the output layer is trained, and the model is fine-tuned using the training sample image set. During the fine-tuning process, a smaller learning rate is used to prevent excessive updates to the weights. Thus, the performance of the fine-tuned model is evaluated on the validation set, and hyperparameters are adjusted and further optimized based on the results to obtain the initial target parameters of the detection model.
[0103] It is understandable that by identifying training sample images of different scales to adjust parameters, the model's feature learning ability at different scales can be improved, network performance can be optimized, and training difficulty can be reduced.
[0104] S103, obtaining a first detection result corresponding to the training sample image according to the initial target parameters of the detection model;
[0105] The first detection result is a predicted category and a predicted bounding box of the target object determined based on the initial target parameters of the detection model.
[0106] In this embodiment, based on the initial target parameters of the detection model, the detection model calculates the prediction results of each training sample image through forward propagation, including the predicted category and bounding box, and the generated first detection result generally includes the predicted category probability and predicted bounding box coordinates of each target object.
[0107] It should be noted that the first detection result may not be accurate, but the detection result can be used to understand the initial state of the model and provide a reference for subsequent improvements.
[0108] S104, adjusting the initial target parameters of the detection model according to the first detection result and the sample label corresponding to the pre-acquired training sample image to obtain a target detection model;
[0109] The sample labels are the true categories and true bounding boxes of the target objects in each training sample image in the training sample image set. These sample labels have been pre-annotated, and the annotation information is the sample label, including the category and bounding box of the target object, indicating the position and size of the target object in the image.
[0110] Adjusting the initial target parameters of the detection model may refer to calculating the error between the first detection result (prediction result) and the sample label (true result) using a loss function, wherein the loss function may be a classification loss (such as a cross entropy loss) and a regression loss (such as an L2 loss or an IoU loss), and then calculating the gradient through a back propagation algorithm to update the model parameters to minimize the error, and then repeating the error calculation and parameter updating process, for example, gradually optimizing the model parameters through multiple iterations. At the same time, during the training process, a validation set is also required to evaluate the model performance to prevent overfitting, thereby obtaining a target detection model.
[0111] It can be understood that by continuously adjusting the initial target parameters of the detection model (such as learning rate, batch size, etc.) to gradually approach the optimal solution, the stability and efficiency of the training process can be ensured until the prediction accuracy of the model reaches a satisfactory level, thereby obtaining the final target detection model.
[0112] In one achievable manner, S101 may be specifically implemented through the following steps:
[0113] First, an initial image set is obtained, each initial image in the initial image set contains at least one object; then, data enhancement processing is performed on each initial image in the initial image set to obtain a training sample image set.
[0114] Among them, enhancement processing can refer to combining conventional data enhancement methods such as image flipping, rotation, cropping, translation, affine transformation, and hue adjustment with complex data enhancement techniques such as image stitching, random erasing, random hiding, and regularization processing to enhance the initial image, thereby increasing the diversity and complexity of the training sample image set. Among them, image stitching can be done through Mosaic, by stitching four different images into a new image, random erasing can be done through RandomErase, randomly selecting a rectangular area in the image and filling it with random noise or average value, random hiding can be done through Hide and Seek, dividing the image into multiple grids and randomly selecting some grids for occlusion, and regularization processing can be done through DropBlock, randomly selecting a block on the feature map and setting its value to zero.
[0115] It is understandable that increasing the diversity of the training sample image set through data augmentation technology can not only help the model better adapt to different input data, improve its performance in practical applications, enhance the robustness of the model, effectively avoid overfitting, but also significantly improve the feature expression ability, thereby further improving the accuracy of target detection.
[0116] The model training method provided in the embodiment of the present application can improve the detection accuracy of the detection model for target detection tasks under different conditions and environments by incorporating at least one target object of different size, scene, and category into each training sample image in the training sample image set; by identifying and adjusting parameters of training sample images of different scales, the detection capability of the detection model for targets of various scales can be improved; by obtaining a first detection result corresponding to the training sample image based on the initial target parameters of the detection model, and adjusting the initial target parameters of the detection model by comparing the first detection result with the sample label corresponding to the training sample image, the detection performance can be gradually optimized and the robustness of the detection model can be enhanced.
[0117] Based on the above embodiments, Figure 2 Schematic diagram of the model training method provided in the embodiment of the present application Figure 2 .like Figure 2 As shown, in this embodiment Figure 1 Based on the embodiment, S102 is described in detail, which specifically includes the following steps:
[0118] S201 , adjusting each training sample image in a training sample image set to obtain training sample images of different sizes.
[0119] It should be noted that multi-scale dynamic training includes three elements: multi-scale training data, multi-scale image parameter settings, and multi-scale anchor point selection based on the K-medoids algorithm. Through their combined effect, a dynamic training mechanism is formed to improve the performance of the detection model in detecting objects of different scales.
[0120] Specifically, multi-scale training data means setting data of many different scales in the training sample image set, multi-scale image parameter setting means setting multiple input image sizes during the training process and randomly selecting inputs, and K-medoids algorithm means retraining the model by updating the anchor configuration.
[0121] In this embodiment, adjusting each training sample image in the training sample image set may refer to scaling the training sample images to simulate different observation conditions and viewing angles, so that the model can learn the characteristics of the target object at different scales, thereby improving the robustness and generalization ability of the model.
[0122] S202: Mark training sample images of different sizes to determine the size of the bounding box of the target object.
[0123] The size of the bounding box of the target object is the width and height of the bounding box, which are used as features.
[0124] S203: Cluster the sizes of the bounding boxes of the target objects to determine the sizes of the cluster centers.
[0125] In this embodiment, clustering is performed based on the K-medoids algorithm. The sizes of the bounding boxes of K target objects are randomly selected as initial cluster centers, i.e., medoids. Then, the Euclidean distance between each data point and the initial cluster center is calculated, thereby assigning each data point to the cluster to which the initial cluster center closest to it belongs. For each cluster, the total distance between all objects in the cluster and other objects is calculated, and the object with the smallest total distance is selected as the new cluster center. According to the clustering result, the width and height of each cluster center are determined.
[0126] In some embodiments, the K-means algorithm may also be used to cluster the data to achieve the same effect.
[0127] S204: Using the size of the cluster center as the size of the anchor point of the preset detection model, and training the preset detection model according to the size of the anchor point of the preset detection model and training sample images of different sizes to obtain initial parameters of the detection model.
[0128] Among them, training the preset detection model according to the size of the anchor points of the preset detection model and training sample images of different sizes can refer to updating the sizes of the anchor points obtained by clustering processing into the configuration file of the training network, and training the detection model in combination with training sample images of different sizes, so as to obtain the initial parameters of the detection model.
[0129] It can be understood that training the detection model by using training sample images of different scales and selecting actual data points as cluster centers instead of the mean increases data diversity, reduces the impact of outliers on cluster centers, and helps improve the performance of the model in detecting objects of different scales.
[0130] S205: Adjust the initial parameters of the detection model to obtain initial target parameters of the detection model.
[0131] In this embodiment, the initial parameters of the detection model can be adjusted based on a pre-training process, such as network transfer learning, including initial network training and transfer network training, so as to adjust the initial parameters of the detection model to enhance the adaptability of the detection model to new tasks, improve the generalization ability and flexibility of the model to adapt to different detection task requirements,
[0132] In one achievable manner, S205 may be specifically implemented through the following steps:
[0133] The detection model is trained using actual data sets of the target application scenario, and the initial parameters of the detection model are adjusted to obtain the initial target parameters of the detection model. The detection model uses a feature layer whose correlation with the output layer is less than a preset threshold for feature extraction.
[0134] Among them, the preset threshold can refer to the distance set according to the needs of the detection task. The initial parameters of the detection model obtained by pre-training using big data are first used as the initial parameters, and then the detection model is trained using the actual data set of the target application scenario, so as to fine-tune the initial parameters and obtain the initial target parameters of the detection model.
[0135] In this embodiment, in the process of training the detection model using the actual data set of the target application scenario, the low-level feature layer close to the input layer in the detection model is frozen, and only the high-level feature layer close to the output layer is trained to meet the specific needs of the target task. Then, the model is fine-tuned using the actual data set of the target application scenario. During the fine-tuning process, a smaller learning rate is usually used to prevent excessive updates to the pre-trained weights.
[0136] It is understandable that different input sizes will affect the performance and accuracy of the model. For example, a larger input size can usually capture more detailed information, but it will also increase the computational cost. Through network transfer training, the detection model is trained with the actual data set of the target application scenario, and the feature layer in the detection model whose correlation with the output layer is less than the preset threshold is used to extract features from the actual data set of the target application scenario, which can reduce training time and computing resources.
[0137] The model training method provided in the embodiment of the present application adjusts each training sample image to obtain training sample images of different sizes, and clusters them according to the size of the bounding box of the target object, and then uses the size of the cluster center as the size of the anchor point of the preset detection model, and combines the two to train the preset detection model to determine the initial parameters of the detection model, which can enhance the feature learning ability of the detection model for images of different sizes, and trains the detection model through the actual data set of the target application scenario, adjusts the initial parameters of the detection model, and obtains the initial target parameters of the detection model, so that the detection model can have better performance even on a smaller set of training sample images, thereby reducing computing resources, further improving the training efficiency and performance of the network, and making it better adapt to complex and changeable data environments.
[0138] Based on the above embodiments, Figure 3 Schematic diagram of the model training method provided in the embodiment of the present application Figure 3 .like Figure 3 As shown, in this embodiment Figure 1 Based on the embodiment, S103 is described in detail, which specifically includes the following steps:
[0139] S301. Downsample the training sample image according to the initial target parameters of the detection model to obtain feature map data.
[0140] Here, downsampling may refer to reducing the size of a training sample image, and the original training sample image is converted into a feature map, which retains important features of the image. In this embodiment, downsampling is performed by a strided convolution with a step size of 2.
[0141] It can be understood that downsampling can reduce computational complexity, making subsequent processing more efficient, while retaining key information of the image and facilitating feature extraction.
[0142] S302, dividing the feature map data into first data and second data, performing deep convolution processing and point-by-point convolution processing on the first data in sequence, and inputting them into two fully connected layers for feature fusion to obtain a high-level feature vector, and directly transferring the second data to obtain the original feature vector.
[0143] In this embodiment, deep convolution may refer to convolution processing of the first data through multiple convolution layers, which can capture high-level features of the image, that is, complex spatial features. Point-by-point convolution, that is, 1x1 convolution, is used to reduce the dimension of the feature map while retaining important information. The convolution-processed features are then input into two fully connected layers for feature fusion, converting the spatial features into one-dimensional vectors to obtain high-level feature vectors.
[0144] Directly transferring the second data may mean directly transferring the second data without undergoing convolution processing, thereby retaining the original features and obtaining the original feature vector.
[0145] It is understandable that the combination of deep convolution and point-by-point convolution can effectively extract and compress features, and multiplying different features through the fully connected layer can enhance the model's expressiveness. Retaining the original feature vector helps provide more information sources in subsequent feature fusion and improves detection accuracy.
[0146] S303: Perform feature fusion on the high-level feature vector and the original feature vector to obtain a first detection result corresponding to the training sample image.
[0147] Among them, feature fusion can be performed through weighted summation, splicing, etc., and the fused features are used to generate the first detection result that is finally output by the detection model.
[0148] It is understandable that by fusing features at different levels, the model can understand the image content more comprehensively and improve the accuracy and robustness of detection. At the same time, this multi-level feature fusion strategy can effectively combine low-level details and high-level semantic information, making the model suitable for complex image detection tasks.
[0149] It should be noted that the structure of the YOLOv5 model in the embodiment of the present application includes four main parts: input, Backbone, Atrous-Separable-Squeeze-Excitation Block (ASSE block for short) and Head, wherein Backbone is mainly used to extract features and output multi-scale feature maps. ASSE block is used to replace the conventional convolution layer of the Neck part in the original YOLOv5 model to fuse features. Head is mainly used to generate the final detection results, including the bounding box position and category probability.
[0150] like Figure 4 FIG. 1 is a schematic diagram of a partial structure of a detection model provided in an embodiment of the present application. In particular:
[0151] Atconv (Attention Convolution) is a convolution operation combined with an attention mechanism. In deep learning, the attention mechanism is used to dynamically focus on different parts of the input data, such as the target area or key features, thereby improving the network's ability to locate the target object.
[0152] Specifically, the attention mechanism adjusts the weights of different feature channels and highlights important feature information, which can help the model better deal with noise, environmental interference and occlusion problems, thereby improving the robustness and overall performance of the model.
[0153] Dwconv (Depthwise Convolution) is part of the depthwise separable convolution, which is mainly used to reduce the amount of calculation and the number of parameters. Depthwise convolution applies convolution operations separately on each input channel instead of applying one convolution kernel on all channels.
[0154] Pwconv (Pointwise Convolution) is another part of the depthwise convolution, which is located after the depthwise convolution. Pointwise convolution uses a 1x1 convolution kernel to mix the input channels to change the number of channels. By combining Dwconv and Pwconv, the computational complexity of the model can be effectively reduced.
[0155] FC (Fully Connected) is a fully connected layer, in which each input node is connected to each output node to integrate features and perform classification.
[0156] Scale represents a scaling operation, which is used to adjust the size of the feature map so that the output feature map has the same size.
[0157] It is understandable that by adjusting the structure of the detection model and using strided convolution to fuse the high-level feature vector and the original feature vector, the network can capture broader contextual information while reducing the risk of overfitting. At the same time, the depth-wise separable convolution that combines deep convolution with point-by-point convolution is used to replace the traditional pooling layer for feature compression, which can not only reduce the computational cost, but also retain more feature details, thereby improving the detection accuracy and adaptability to complex scenes.
[0158] The model training method provided in the embodiment of the present application downsamples the training sample image to obtain feature map data and optimizes the network structure, so as to group the feature map data to obtain high-level feature vectors and original feature vectors, and fuse features at different levels, thereby improving the detection model's attention to key information and enhancing the feature representation capability, so that the detection model can maintain a high detection accuracy in various complex detection environments.
[0159] Based on the above target detection model, the target detection method is described in detail in the embodiment of the present application: Figure 5 The following is a flow chart of the target detection method provided in the embodiment of the present application. Figure 5 As shown, the method comprises the following steps:
[0160] S401, obtaining a video to be detected in a preset area;
[0161] Among them, the preset area is the monitored area to be detected, and the area can be various application scenarios of the monitoring video.
[0162] S402: When a moving object is detected in the video to be detected, the image to be detected corresponding to the video to be detected is input into the target detection model to obtain a target detection result;
[0163] Among them, the target detection model is obtained by training a preset detection model based on a training sample image set. The detection model is used to identify training sample images of different scales to adjust parameters. At least one of the size, scene and type of the target object in each training sample image in the training sample image set is different. The target detection result represents whether the moving object contains the detection object and the bounding box of the detection object.
[0164] In this embodiment, the difference comparison of consecutive frames in the video stream is performed through the inter-frame difference method to accurately detect dynamic objects in the video. If a moving object is detected, the subsequent animal intrusion detection process will be triggered; if no moving object is detected, the subsequent processing steps will not be executed.
[0165] In some embodiments, moving objects may also be detected by background subtraction to achieve the same effect.
[0166] It can be understood that when a moving object is detected in the video to be detected, the image to be detected corresponding to the video to be detected is input into the target detection model to obtain the target detection result, so that the detection model can dynamically respond to environmental changes and perform target detection only when necessary, saving computing resources.
[0167] In one achievable manner, before detecting that there is a moving object in the video to be detected, the method further includes the following steps:
[0168] First, the time-series frame image of the video to be detected is obtained; then, two consecutive frames in the time-series frame image are compared to obtain a difference map, which represents the change area between the two consecutive frames in the time-series frame image; finally, based on the difference map, it is determined whether there is a moving object.
[0169] In this embodiment, comparing two consecutive frames in the time-series frame image may refer to performing pixel-level difference comparison on the two consecutive frames, such as calculating the brightness or color difference of each pixel between the two frames, and generating a difference map based on the calculated difference. Determining whether there is a moving object based on the difference map may refer to performing threshold processing on the difference map, filtering out minor changes, and retaining only significant moving areas, thereby reducing the impact of noise and highlighting the real moving object, and then analyzing the difference map after threshold processing to identify the existence and position of the moving object.
[0170] It can be understood that the process of determining whether there is a moving object through the inter-frame difference method is simpler, has lower algorithm complexity, consumes less resources, and has a faster processing speed. It can effectively reduce the consumption of computing resources and improve the processing speed, thereby ensuring the efficient operation of the entire detection process.
[0171] In one achievable manner, before inputting the image to be detected corresponding to the video to be detected into the target detection model to obtain the target detection result, the method further includes the following steps:
[0172] First, weather information of a preset area is obtained; then, according to the weather information of the preset area, target parameters of the target detection model are adjusted to obtain an adjusted target detection model.
[0173] Among them, weather information can refer to the weather conditions in the actual detection environment, such as sunny or rainy days, etc., and can be achieved by installing sensors such as temperature, humidity, light intensity and wind speed in preset areas to monitor environmental changes in real time, and by integrating weather forecast services on the Internet or real-time environmental monitoring equipment data to obtain weather information.
[0174] In this embodiment, the target detection model outputs a confidence score for the detection result of the target object, which is usually between 0 and 1. A higher confidence score indicates that the target detection model is more confident in the detection result. When the confidence score is low, the target parameters of the target detection model need to be adjusted to improve the performance of the model.
[0175] As an example, in severe weather conditions such as rain and snow, the confidence threshold in the target parameter of the target detection model is appropriately lowered to reduce false positives; at night or in low light conditions, the threshold can be increased to reduce missed positives; under normal weather conditions, the default threshold is restored.
[0176] In some embodiments, the target detection model can also be set to automatically adjust the threshold according to time, such as season, day or night, to prevent the influence of environmental factors such as lighting and visibility.
[0177] It can be understood that by adjusting the target parameters of the target detection model according to the weather information of the preset area, the adjusted target detection model can adapt to the complex and changeable detection environment, improve the detection accuracy, and prevent false detection and missed detection.
[0178] The target detection method provided in the embodiment of the present application constructs a training set through diversified training sample images, and enables the detection model to detect and adjust parameters for training sample images of different scales to improve its adaptability and accuracy. In addition, by pre-detecting whether there are moving objects in the video to be detected and then determining whether to perform target detection, computing resources can be saved. In addition, by adjusting the target parameters of the target detection model according to weather information, the adjusted target detection model can adapt to complex natural environments such as different weather and visibility, and always maintain a high-precision detection effect.
[0179] Figure 6 The following is a schematic diagram of the architecture of the target detection method provided in the embodiment of the present application. Figure 6 As shown, the method includes:
[0180] Collect video images: Obtain real-time video streams of specific areas through installed surveillance cameras for continuous and real-time observation to meet the user's personalized monitoring needs. Users can flexibly select and adjust the monitoring area according to their specific needs and concerns.
[0181] Video image cloud: The collected video data is transmitted to the server provided by the video cloud service provider. During this process, the video data will go through pre-processing steps such as file compression and encoding conversion to ensure the efficiency of video transmission and storage.
[0182] It should be noted that the subsequent artificial intelligence detection and related algorithm processing are all completed on the cloud server. The cloud computing-based AI detection technology can make full use of the elastic resources of cloud service providers and dynamically adjust computing resources according to detection needs, so that the system can efficiently process large amounts of data and complex analysis tasks without being limited by hardware. At the same time, the cloud computing platform provides powerful data processing capabilities, including data storage, processing and analysis.
[0183] Video image preprocessing: including but not limited to video stream decoding, contrast enhancement, lens segmentation, brightness adjustment and video stream storage, etc., so as to improve the video quality, provide a clear and stable video source for subsequent processing and analysis, and ensure the accuracy and effectiveness of subsequent operations. Then, using inter-frame difference technology, identify whether the input video frame contains moving objects to determine whether to perform the following animal intrusion detection.
[0184] Animal intrusion detection: includes multi-migration network training and dynamic threshold adaptation adjustment. Multi-migration network training includes multi-scale dynamic training and network migration training. Model training is performed by performing data enhancement on the test data set and the training data set. Dynamic threshold adaptation adjustment includes the effects of weather factors, time factors, and visibility factors. By real-time monitoring of environmental changes and model training, the detection model can improve the detection accuracy of animal intrusions, adapt to detection needs in different environments, reduce false alarms and missed alarms, save computing resources, and improve user experience. At the same time, the network structure is optimized, and the ASSE block is designed to replace the conventional convolutional layer of the Neck part of the original YOLOv5 network, thereby improving the overall performance of the model.
[0185] Based on the above animal intrusion detection, a detection result is obtained.
[0186] Infestation analysis: including image display of results, counting of the number of infesting animals, identification of the types of infesting animals, and communication of the result images to users via SMS and phone alerts, ensuring that users can obtain more information while receiving the image detection results, providing users with a more comprehensive and in-depth animal infestation detection and response solution.
[0187] After the intrusion analysis is performed, it is sent to the user so that the user can obtain the image analysis result.
[0188] The target detection method provided in the embodiment of the present application captures the image data of the user's interest through a real-time camera, and uploads these video materials to the cloud server for a series of image preprocessing steps to prepare for artificial intelligence detection, through a hybrid network training mode that combines multi-scale training with transfer learning training, and optimizes the detection network structure, while introducing dynamic threshold adaptive adjustment to enhance the adaptability and accuracy of the system. In addition, by analyzing the intrusion event, not only does it provide a graphical detection output, but it can also perform statistical analysis on the types and numbers of interfering animals, and then according to user needs, timely send alarm information through telephone and text messages, etc., to ensure that users can quickly obtain the detection situation and take corresponding measures.
[0189] Figure 7 This is a schematic diagram of the structure of the model training device provided in the embodiment of the present application. Figure 7 As shown, the model training device 50 provided in the embodiment of the present application includes:
[0190] A determination module 501 is used to determine a training sample image set, wherein at least one of the size, scene and type of the target object in each training sample image in the training sample image set is different;
[0191] The second obtaining module 502 is used to input the training sample image set into a preset detection model to obtain the initial target parameters of the detection model, and the detection model is used to identify the training sample images of different scales to adjust the parameters;
[0192] A third obtaining module 503 is used to obtain a first detection result corresponding to the training sample image according to the initial target parameters of the detection model, where the first detection result is a predicted category and a predicted bounding box of the target object determined based on the initial target parameters of the detection model;
[0193] The fourth obtaining module 504 is used to adjust the initial target parameters of the detection model according to the first detection result and the sample label corresponding to the pre-acquired training sample image to obtain the target detection model, and the sample label is the real category and real bounding box of the target object in each training sample image in the training sample image set.
[0194] Optionally, the second obtaining module 502 is specifically configured to:
[0195] Adjusting each training sample image in the training sample image set to obtain training sample images of different sizes;
[0196] Label the training sample images of different sizes and determine the size of the bounding box of the target object;
[0197] Cluster the size of the bounding box of the target object and determine the size of the cluster center;
[0198] The size of the cluster center is used as the size of the anchor point of the preset detection model, and the preset detection model is trained according to the size of the anchor point of the preset detection model and training sample images of different sizes to obtain the initial parameters of the detection model;
[0199] The initial parameters of the detection model are adjusted to obtain the initial target parameters of the detection model.
[0200] Optionally, the second obtaining module 502 is specifically configured to:
[0201] The detection model is trained using actual data sets of the target application scenario, and the initial parameters of the detection model are adjusted to obtain the initial target parameters of the detection model. The detection model uses a feature layer whose correlation with the output layer is less than a preset threshold for feature extraction.
[0202] Optionally, the third obtaining module 503 is specifically used to:
[0203] According to the initial target parameters of the detection model, the training sample image is downsampled to obtain feature map data;
[0204] The feature map data is divided into first data and second data, and the first data is sequentially subjected to deep convolution processing and point-by-point convolution processing, and input into two fully connected layers for feature fusion to obtain a high-level feature vector, and the second data is directly transferred to obtain the original feature vector;
[0205] The high-level feature vector and the original feature vector are subjected to feature fusion to obtain a first detection result corresponding to the training sample image.
[0206] Optionally, the determination module 501 is specifically configured to:
[0207] Acquire an initial image set, each initial image in the initial image set containing at least one object;
[0208] Data enhancement processing is performed on each initial image in the initial image set to obtain a training sample image set.
[0209] The model training device provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effects are similar, and will not be described in detail in this embodiment.
[0210] Figure 8 This is a schematic diagram of the structure of the target detection device provided in the embodiment of the present application. Figure 8 As shown, the target detection device 60 provided in the embodiment of the present application includes:
[0211] An acquisition module 601 is used to acquire a video to be detected in a preset area, where the preset area is a monitored area to be detected;
[0212] The first obtaining module 602 is used to input the image to be detected corresponding to the video to be detected into the target detection model to obtain the target detection result when a moving object is detected in the video to be detected. The target detection model is obtained by training a preset detection model based on a training sample image set. The detection model is used to identify training sample images of different scales to adjust parameters. At least one of the size, scene and type of the target object in each training sample image in the training sample image set is different. The target detection result represents whether the moving object contains the detection object and the bounding box of the detection object.
[0213] Optionally, before detecting that there is a moving object in the video to be detected, the acquisition module 601 is further used to:
[0214] Obtaining time-series frame images of the video to be detected;
[0215] Comparing two consecutive frames in the time-series frame image to obtain a difference map, the difference map represents the change area between the two consecutive frames in the time-series frame image;
[0216] Based on the difference map, determine whether there is a moving object.
[0217] Optionally, before inputting the image to be detected corresponding to the video to be detected into the target detection model to obtain the target detection result, the first obtaining module 602 is further used to:
[0218] Get weather information for a preset area;
[0219] According to the weather information of the preset area, the target parameters of the target detection model are adjusted to obtain the adjusted target detection model.
[0220] The target detection device provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be described in detail here.
[0221] Fig. 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig. 9 As shown, the electronic device 70 provided in this embodiment includes: at least one processor 701 and a memory 702. Optionally, the electronic device 503 further includes a communication component 703. The processor 701, the memory 702 and the communication component 703 are connected via a bus 704.
[0222] In a specific implementation process, at least one processor 701 executes the computer-executable instructions stored in the memory 702, so that at least one processor 701 executes the above method.
[0223] The specific implementation process of the processor 701 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.
[0224] In the above embodiments, it should be understood that the processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the invention can be directly implemented as a hardware processor, or can be implemented by a combination of hardware and software modules in the processor.
[0225] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (NVM), such as at least one disk storage.
[0226] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of this application is not limited to only one bus or one type of bus.
[0227] The present application also provides a computer program product, including a computer program, which implements the above method when executed by a processor.
[0228] The present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the above method is implemented.
[0229] The above-mentioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0230] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.
[0231] The division of units is only a logical function division, and there may be other divisions in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.
[0232] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0233] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0234] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0235] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.
[0236] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0237] It should be understood that the above-mentioned device embodiments are only illustrative, and the device of the present application can also be implemented in other ways. For example, the division of units / modules in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.
[0238] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present application may be integrated into one unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The above-mentioned integrated unit / module may be implemented in the form of hardware or in the form of a software program module.
[0239] If the integrated unit / module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. Unless otherwise specified, the processor may be any appropriate hardware processor, such as a CPU, a GPU, an FPGA, a DSP, an ASIC, etc. Unless otherwise specified, the storage unit may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory (RRAM), a dynamic random access memory (DRAM), a static random access memory (SRAM), an enhanced dynamic random access memory (EDRAM), a high-bandwidth memory (HBM), a hybrid memory cube (HMC), etc.
[0240] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0241] In the above embodiments, the description of each embodiment has its own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0242] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0243] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A target detection method, characterized in that: include: Obtain a video to be detected in a preset area, where the preset area is a monitored area to be detected; When a moving object is detected in the video to be detected, the image to be detected corresponding to the video to be detected is input into the target detection model to obtain a target detection result. The target detection model is obtained by training a preset detection model based on a training sample image set. The detection model is used to identify training sample images of different scales to adjust parameters. At least one of the size, scene and type of the target object in each training sample image in the training sample image set is different. The target detection result represents whether the moving object contains the detection object and the bounding box of the detection object.
2. The method according to claim 1, characterized in that Before detecting that there is a moving object in the video to be detected, the method further includes: Acquire the time-series frame images of the video to be detected; Comparing two consecutive frames in the time sequence frame image to obtain a difference map, wherein the difference map represents a change region between the two consecutive frames in the time sequence frame image; According to the difference map, it is determined whether there is a moving object.
3. The method according to claim 1 or 2, characterized in that: Before inputting the image to be detected corresponding to the video to be detected into the target detection model to obtain the target detection result, the method further includes: Obtaining weather information of the preset area; According to the weather information of the preset area, the target parameters of the target detection model are adjusted to obtain an adjusted target detection model.
4. A model training method, characterized in that: include: Determine a training sample image set, wherein at least one of the size, scene and type of the target object in each training sample image in the training sample image set is different; Inputting the training sample image set into a preset detection model to obtain initial target parameters of the detection model, wherein the detection model is used to detect training sample images of different scales to adjust parameters; Obtaining, according to the initial target parameters of the detection model, a first detection result corresponding to the training sample image, wherein the first detection result is a predicted category and a predicted bounding box of the target object determined based on the initial target parameters of the detection model; According to the first detection result and the sample label corresponding to the pre-acquired training sample image, the initial target parameters of the detection model are adjusted to obtain a target detection model, wherein the sample label is the true category and true bounding box of the target object in each training sample image in the training sample image set.
5. The method according to claim 4, characterized in that The step of inputting the training sample image set into a preset detection model to obtain initial target parameters of the detection model includes: Adjusting each training sample image in the training sample image set to obtain training sample images of different sizes; Marking the training sample images of different sizes to determine the size of the bounding box of the target object; Clustering the sizes of the bounding boxes of the target objects to determine the sizes of the cluster centers; The size of the cluster center is used as the size of the anchor point of the preset detection model, and the preset detection model is trained according to the size of the anchor point of the preset detection model and the training sample images of different sizes to obtain the initial parameters of the detection model; The initial parameters of the detection model are adjusted to obtain the initial target parameters of the detection model.
6. The method according to claim 5, characterized in that The adjusting the initial parameters of the detection model to obtain the initial target parameters of the detection model includes: The detection model is trained using an actual data set of a target application scenario, and the initial parameters of the detection model are adjusted to obtain the initial target parameters of the detection model. The detection model uses a feature layer whose correlation with the output layer is less than a preset threshold for feature extraction.
7. The method according to claim 4, characterized in that The step of obtaining a first detection result corresponding to the training sample image according to the initial target parameter of the detection model includes: Downsampling the training sample image according to the initial target parameters of the detection model to obtain feature map data; The feature map data is divided into first data and second data, the first data is sequentially subjected to deep convolution processing and point-by-point convolution processing, and input into two fully connected layers for feature fusion to obtain a high-level feature vector, and the second data is directly transferred to obtain an original feature vector; Feature fusion is performed on the high-level feature vector and the original feature vector to obtain a first detection result corresponding to the training sample image.
8. The method according to claim 4, characterized in that The step of determining a training sample image set comprises: Acquire an initial image set, wherein each initial image in the initial image set contains at least one object; Data enhancement processing is performed on each initial image in the initial image set to obtain the training sample image set.
9. A target detection device, characterized in that: include: An acquisition module, used for acquiring a video to be detected in a preset area, where the preset area is a monitored area to be detected; The first obtaining module is used to input the image to be detected corresponding to the video to be detected into the target detection model to obtain the target detection result when a moving object is detected in the video to be detected. The target detection model is obtained by training a preset detection model based on a training sample image set. The detection model is used to identify training sample images of different scales to adjust parameters. At least one of the size, scene and type of the target object in each training sample image in the training sample image set is different. The target detection result represents whether the moving object contains the detection object and the bounding box of the detection object.
10. A model training device, characterized in that: include: A determination module, used to determine a training sample image set, wherein at least one of the size, scene and type of the target object in each training sample image in the training sample image set is different; The second obtaining module is used to input the training sample image set into a preset detection model to obtain the initial target parameters of the detection model, and the detection model is used to identify the training sample images of different scales to adjust the parameters; A third obtaining module is used to obtain a first detection result corresponding to the training sample image according to the initial target parameters of the detection model, wherein the first detection result is a predicted category and a predicted bounding box of the target object determined based on the initial target parameters of the detection model; The fourth obtaining module is used to adjust the initial target parameters of the detection model according to the first detection result and the sample label corresponding to the training sample image obtained in advance, so as to obtain the target detection model, wherein the sample label is the true category and true bounding box of the target object in each training sample image in the training sample image set.
11. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 8.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 8 when executed by a processor.
13. A computer program product, characterized in that The method comprises a computer program, which is used to implement the method according to any one of claims 1 to 8 when the computer program is executed by a processor.
Citation Information
Cited By
Target identification and behavior detection method and device
CN116403282A
Fire rescue training scene simulation method, device and system
CN119832786A
Tire bubble disease detection and management method and device
CN120953683A
Submarine pipeline real-time detection and positioning method and device and related products
CN122066709A