Target detection method, device, storage medium and terminal

By using the center range radius to determine the loss value in the target detection model, the target detection model is optimized, so that the model can return to the center position of the object more accurately, solving the problems of insufficient model robustness and generalization ability in the existing technology, and improving Detection effect.

CN114022658BActive Publication Date: 2024-09-20ZHEJIANG SMART VIDEO SECURITY INNOVATION CENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111089757.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-17
Publication Date
2024-09-20
Estimated Expiration
2041-09-17

AI Technical Summary

Technical Problem

Due to the inaccuracy of object position labels in the training phase of existing target detection models, the model output center point coordinates will suffer losses even if they are close to the real center point, reducing the robustness and generalization ability of the model.

Method used

By using the center range radius to determine the position loss value when constructing the loss function, the target detection model is optimized so that the target center position is improved from regressing a single pixel to a small range around the center pixel.

Benefits of technology

It improves the robustness and generalization ability of the model, avoids overfitting, and improves the accuracy of target detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114022658B
    Figure CN114022658B
Patent Text Reader

Abstract

The present invention discloses a target detection method, device, storage medium and terminal, the method comprising: obtaining a target image to be detected; inputting the target image to be detected into a pre-trained target detection model; wherein the loss function of the pre-trained target detection model is constructed based on a position loss value, the position loss value is determined based on a center range radius, and the center range radius is determined based on the width and height of the target object's label; outputting the position of each object in the target image and multiple category probability values; determining the final category of each object based on multiple category probability values. Therefore, since the present application determines the loss value of the model through the center range radius, the optimization of the target center position is improved from regressing a single pixel to regressing to a small range around the center pixel, thereby improving the robustness and generalization ability of the model for target detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer vision technology, and in particular to a target detection method, device, storage medium and terminal. Background Art

[0002] Object detection is an important research direction in computer vision and digital image processing, and is widely used in many fields such as robot navigation, intelligent video surveillance, industrial inspection, aerospace, etc. The goal of object detection is to find objects of interest in an image, which includes two subtasks: object localization and object classification, that is, determining the category and location of an object at the same time.

[0003] In the prior art, the target detection model trained by using neural networks combined with a large amount of image data has become the mainstream model training method in the industry. Neural network-based algorithms can basically be divided into two categories: two-stage algorithms represented by Faster R-CNN and one-stage algorithms represented by YOLO, SSD, etc. In the application stage, the traditional target detection algorithm outputs the center point position (x', y') of the target and the width w' and height h' of the minimum circumscribed rectangle containing the target. In the training stage, when the center point position (x', y') output by the model is inconsistent with the center point position (x, y) in the true label, the model will incur losses. Even if the output center point is close to the true center point, the model will incur losses and optimize the losses. Since the location label of the object is often not absolutely accurate, the center position of the object should be defined by a small range near the center coordinate point, rather than a single pixel point. Therefore, when the center point coordinates output by the model are within the true center range, the model should not incur losses. If losses are still incurred at this time, the robustness and generalization ability of the detection model may be reduced. Summary of the invention

[0004] The embodiments of the present application provide a target detection method, device, storage medium and terminal. In order to have a basic understanding of some aspects of the disclosed embodiments, a simple summary is given below. This summary is not a general review, nor is it intended to identify key / important components or describe the scope of protection of these embodiments. Its only purpose is to present some concepts in a simple form as a preface to the detailed description that follows.

[0005] In a first aspect, an embodiment of the present application provides a target detection method, the method comprising:

[0006] Acquire the target image to be detected;

[0007] Inputting the target image to be detected into a pre-trained target detection model; wherein the loss function of the pre-trained target detection model is constructed based on a position loss value, the position loss value is determined based on a center range radius, and the center range radius is determined based on a width and a height in a label of the target object;

[0008] Output the location of each object in the target image and multiple category probability values;

[0009] The final category of each object is determined based on multiple category probability values.

[0010] Optionally, follow these steps to generate a pre-trained object detection model, including:

[0011] Collect images containing multiple objects, and generate model training samples after constructing object labels for each object in the images;

[0012] Create an object detection model;

[0013] Obtain the nth image from the model training sample and input it into the target detection model, and output the category information and location information of each candidate region in the image;

[0014] Obtain the position label and category label marked on the object contained in the nth image;

[0015] Generate the loss value of the target detection model based on the output position information, output category information, and the position label and category label marked on the object;

[0016] Optimize the target detection model based on the loss value of the model to generate a trained target detection model;

[0017] The trained object detection model is determined as the pre-trained object detection model.

[0018] Optionally, the target detection model includes a feature extraction module, a classification module and a regression module;

[0019] Obtain the nth image from the model training sample and input it into the target detection model, and output the category information and location information of each candidate region in the image, including:

[0020] Obtain the nth image from the model training sample and input it into the feature extraction module to obtain an image feature map;

[0021] Generate multiple candidate regions of different sizes and aspect ratios for each position in the image feature map;

[0022] After the classification module and regression module are used to classify and adjust the position of the candidate areas, the category information and position information of each candidate area in the image are output.

[0023] Optionally, a loss value of the target detection model is generated according to the output position information, the output category information, and the position label and category label marked on the object, including:

[0024] Get the width and height of the object in the object's location tag;

[0025] Calculate the center range radius of the object in the width and height directions respectively, and generate a first range radius and a second range radius;

[0026] Calculate the position loss value according to the first range radius, the second range radius, the position information and the position tag;

[0027] Calculate the classification loss value based on the category information and category label;

[0028] The position loss value and the classification loss value are summed to generate the loss value of the object detection model.

[0029] Optionally, when generating the loss value of the target detection model, the method also includes calculating the width and height loss values.

[0030] Optionally, optimize the target detection model based on the loss value of the model to generate a trained target detection model, including:

[0031] The parameters of the target detection model are derived according to the loss value of the model to generate a local gradient sequence;

[0032] The target detection model is iteratively optimized using the stochastic gradient descent algorithm and the local gradient sequence;

[0033] When the number of iterative optimizations is equal to the preset upper limit or the loss value of the model is less than the preset threshold, stop optimizing the model;

[0034] Generate a trained object detection model.

[0035] Optionally, when the number of iterative optimizations is equal to a preset upper limit or the loss value of the model is less than a preset threshold, the optimization of the model is stopped, including:

[0036] When the number of iterative optimization is less than the preset upper limit value or the loss value of the model is greater than or equal to the preset threshold, continue to execute the step of obtaining the n+1th image input into the target detection model from the model training samples; when n+1 is greater than the number of the model training samples, randomly arrange the order of the images in the model training samples, and reset n=1.

[0037] Optionally, the final category of each object is determined based on multiple category probability values, including:

[0038] Select the maximum probability value among multiple category probability values;

[0039] Identify the category corresponding to the selected maximum probability value;

[0040] The category corresponding to the maximum probability value is determined as the final category of each object.

[0041] In a second aspect, an embodiment of the present application provides a target detection device, the device comprising:

[0042] An image acquisition module, used to acquire a target image to be detected;

[0043] An image input module is used to input a target image to be detected into a pre-trained target detection model; wherein the loss function of the pre-trained target detection model is constructed based on a position loss value, the position loss value is determined based on a center range radius, and the center range radius is determined based on a width and a height of a label of the target object;

[0044] An output module, used to output the position of each object in the target image and multiple category probability values;

[0045] The final category determination module is used to determine the final category of each object according to multiple category probability values.

[0046] In a third aspect, an embodiment of the present application provides a computer storage medium, which stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the above-mentioned method steps.

[0047] In a fourth aspect, an embodiment of the present application provides a terminal, which may include: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the above-mentioned method steps.

[0048] The technical solution provided by the embodiments of the present application may have the following beneficial effects:

[0049] In an embodiment of the present application, the target detection device first obtains the target image to be detected, and then inputs the target image to be detected into a pre-trained target detection model, wherein the loss function of the pre-trained target detection model is constructed based on the position loss value, and the position loss value is determined based on the center range radius, and the center range radius is determined based on the width and height of the target object's label; secondly, the position of each object in the target image and multiple category probability values ​​are output, and finally the final category of each object is determined based on the multiple category probability values. Since the present application determines the loss value of the model by the center range radius, the optimization of the target center position is improved from regressing a single pixel to regressing to a small range around the center pixel, thereby improving the robustness and generalization ability of the model for target detection.

[0050] It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0052] Figure 1 It is a flowchart of a target detection method provided in an embodiment of the present application;

[0053] Figure 2 It is a flowchart of a method for training a target detection model provided in an embodiment of the present application;

[0054] Figure 3 is a structural schematic diagram of a target detection device provided in an embodiment of the present application;

[0055] Figure 4 It is a structural diagram of a terminal provided in an embodiment of the present application. DETAILED DESCRIPTION

[0056] The following description and the drawings sufficiently illustrate specific embodiments of the invention to enable those skilled in the art to practice them.

[0057] It should be clear that the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0058] When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are only examples of devices and methods consistent with some aspects of the present invention as detailed in the attached claims.

[0059] In the description of the present invention, it should be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances. In addition, in the description of the present invention, unless otherwise specified, "plurality" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previously associated objects are in an "or" relationship.

[0060] The present application provides a target detection method, device, storage medium and terminal to solve the problems existing in the above-mentioned related technical problems. In the technical solution provided by the present application, since the present application determines the loss value of the model by the center range radius, the optimization of the target center position is improved from regressing a single pixel to regressing to a small range around the center pixel, thereby improving the robustness and generalization ability of the model for target detection, and an exemplary embodiment is used for detailed description below.

[0061] The following will be combined with the attached Figure 1 -Attached Figure 2 , the target detection method provided in the embodiment of the present application is introduced in detail. The method can be implemented by a computer program and can be run on a target detection device based on the von Neumann system. The computer program can be integrated in an application or run as an independent tool application. Among them, the target detection device in the embodiment of the present application can be a user terminal, including but not limited to: a personal computer, a tablet computer, a handheld device, a vehicle-mounted device, a wearable device, a computing device or other processing devices connected to a wireless modem. In different networks, the user terminal can be called by different names, for example: user equipment, access terminal, user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication device, user agent or user device, cellular phone, cordless phone, personal digital assistant (PDA), 5G network or terminal equipment in future evolution network, etc.

[0062] See also Figure 1 , which is a flow chart of a target detection method provided in an embodiment of the present application. Figure 1 As shown, the method of the embodiment of the present application may include the following steps:

[0063] S101, obtaining a target image to be detected;

[0064] The target image to be detected is an image used to test the performance of a pre-trained target detection model or an image received when the pre-trained target detection model is applied to a detection scene.

[0065] Generally, when the target image to be detected is an image used to test the performance of a pre-trained target detection model, the target image to be detected can be obtained from a test sample, an image obtained from a user terminal, or an image downloaded from the cloud. When the target image to be detected is an image obtained when a pre-trained target detection model is applied to a detection application scenario, the image to be detected can be an image captured in real time by an image acquisition device.

[0066] In one possible implementation, after the target detection model is trained, when it is necessary to test the target detection performance of the trained target detection model, the user downloads any image carrying an object from a sample test set, a local gallery, or the cloud through a user terminal and identifies the image as a target image to be detected.

[0067] In another possible implementation, when the target detection model is trained and deployed in an actual application scenario, the object sensor or object monitoring algorithm detects that an object has entered the camera monitoring area, triggers the image acquisition camera's camera function to capture the target image entering the monitoring area, and finally determines the target image as the target image to be detected.

[0068] S102, inputting the target image to be detected into a pre-trained target detection model;

[0069] Among them, the loss function of the pre-trained object detection model is constructed based on the position loss value, which is determined based on the center range radius, and the center range radius is determined based on the width and height of the target object's label.

[0070] Generally, for most objects, especially those with larger sizes, the position of their center point should not be uniquely represented by a single pixel. Instead, a small area around the center pixel should be considered as the center position of the object.

[0071] For example, suppose an image contains an elephant with a size of 700*800. In the data annotation stage, the elephant is usually framed with a minimum bounding rectangle, and the center point (x, y) of the rectangle is used as the center point of the elephant. If the center point coordinates output by the model are (x+1, y), according to the loss function of the existing method, the output will produce a certain loss. However, from the intuitive feeling of the human eye, it is also feasible to use (x+1, y) as the center point of the elephant, that is, both (x, y) and (x+1, y) meet the requirements of the center point of the elephant, and there is no superiority or inferiority. Therefore, when the model outputs the predicted value of the center point of (x+1, y), no loss should be generated. If the model still generates losses at this time, it is easy for the model to determine that only the only central pixel point meets the conditions. In this case, the model is prone to overfitting, thereby affecting the robustness and generalization performance of the model.

[0072] Therefore, the present application determines the loss value of the model by the center range radius, so that the optimization of the target center position is improved from regressing a single pixel to regressing to a small range around the center pixel, thereby improving the robustness and generalization ability of the model for target detection.

[0073] In an embodiment of the present application, when generating a pre-trained target detection model, first, an image containing multiple objects is collected, and an object label is constructed for each object in the image to generate a model training sample, and then a target detection model is created. Then, the nth image is obtained from the model training sample and input into the target detection model, and the category information and position information of each candidate area in the output image are output, and then the position label and category label marked on the object contained in the nth image are obtained. Secondly, the loss value of the target detection model is generated according to the output position information, the output category information, and the position label and category label marked on the object, and the target detection model is optimized based on the loss value of the model to generate a trained target detection model, and finally the trained target detection model is determined as the pre-trained target detection model.

[0074] In a possible implementation, after the target image to be detected is acquired according to step S101, the target image is input into a pre-trained target detection model, and the model is processed according to the generated file after training.

[0075] S103, outputting the position of each object in the target image and multiple category probability values;

[0076] The probability value represents the category probability distribution of the category to which each object in the image belongs.

[0077] In one possible implementation, after processing based on step S102 using a pre-trained target detection model, the position coordinates of each object and the probability values ​​of multiple categories are obtained. Finally, the pre-trained target detection model outputs the position coordinates of each object and the probability values ​​of multiple categories. After output, the position of each object in the target image and the probability values ​​of multiple categories are obtained.

[0078] S104: determining the final category of each object according to the multiple category probability values.

[0079] In one possible implementation, when determining the final category of each object based on multiple category probability values, first select the maximum probability value among the multiple category probability values, then identify the category corresponding to the selected maximum probability value, and finally determine the category corresponding to the maximum probability value as the final category of each object.

[0080] In an embodiment of the present application, the target detection device first obtains the target image to be detected, and then inputs the target image to be detected into a pre-trained target detection model, wherein the loss function of the pre-trained target detection model is constructed based on the position loss value, and the position loss value is determined based on the center range radius, and the center range radius is determined based on the width and height of the target object's label; secondly, the position of each object in the target image and multiple category probability values ​​are output, and finally the final category of each object is determined based on the multiple category probability values. Since the present application determines the loss value of the model by the center range radius, the optimization of the target center position is improved from regressing a single pixel to regressing to a small range around the center pixel, thereby improving the robustness and generalization ability of the model for target detection.

[0081] See also Figure 2 , which is a flow chart of a method for training a target detection model according to an embodiment of the present application. Figure 2 As shown, the training method of the target detection model includes the following steps:

[0082] S201, collecting images containing multiple objects, and generating model training samples after constructing object labels for each object in the image;

[0083] In an embodiment of the present application, the image data required for training is collected, and the target labels contained in the image are constructed. The labels include position labels and classification labels. Among them, the position label of the target includes the width w and height h of the target and the center point position (x, y); the category label of the target specifies the category to which the target belongs, represented by a unique hot vector. The category to which the target belongs is 1, and the rest are 0. For example, [0,1,0,0] means that the target belongs to the second category.

[0084] In a possible implementation, images containing a variety of target objects are first collected from the Internet or a local gallery, and the targets in the images are annotated with location labels and classification labels. After the annotation is completed, model training samples are generated.

[0085] S202, creating a target detection model;

[0086] Typically, the target detection model can adopt a one-stage target detection model based on an anchor frame, such as SSD, YOLO, etc., or a two-stage model based on an anchor frame, such as Faster R-CNN, etc.

[0087] It should be noted that the selection of the model can be determined according to the actual scenario and is not specifically limited here.

[0088] S203, obtaining the nth image from the model training sample and inputting it into the target detection model, and outputting the category information and position information of each candidate region in the image;

[0089] Typically, an object detection model includes a feature extraction module, a classification module, and a regression module.

[0090] In one possible implementation, when the target detection model processes the model training sample, it first obtains the nth image input feature extraction module from the model training sample to obtain the image feature map, and then generates multiple candidate regions of different sizes and aspect ratios for each position in the image feature map. Finally, the classification module and the regression module are used to classify and adjust the position of the candidate regions, and then the category information and position information of each candidate region in the image are output.

[0091] For example, the image data in the model training sample is input into the target detection model to obtain the output of the target detection model, including the location information t of each candidate target. i and category information p i .

[0092] S204, obtaining the position label and category label marked on the object contained in the nth image;

[0093] Usually, all images in the training samples are annotated with the location labels and category labels of the objects, so the location labels and category labels of the objects contained in the input n-th image can be obtained.

[0094] S205, generating a loss value of the target detection model according to the output position information, the output category information, and the position label and category label marked on the object;

[0095] In one possible implementation, when generating the loss value of the target detection model, the width and height of the object in the object's position label are first obtained, and then the central range radius of the object in the width and height directions are calculated to generate a first range radius and a second range radius. Then, the position loss value is calculated based on the first range radius, the second range radius, the position information, and the position label. Next, the classification loss value is calculated based on the category information and the category label. Finally, the position loss value and the classification loss value are summed to generate the loss value of the target detection model.

[0096] Specifically, when generating the radius range, the center range radius r of the target in the width and height directions is determined according to the width w and height h of the target. x and r y The center radius is defined by the following formula:

[0097] r x =w×r;

[0098] r y =h×r;

[0099] Where r is the ratio of the radius of the center range to the width and height of the target. It is a priori parameter, preferably 0.03. w and h are the width and height of the target respectively.

[0100] The loss function calculation formula of the constructed target detection model is:

[0101]

[0102] Where i represents the index number of the candidate region. i Represents the output category of the model for the candidate region, Indicates the true category corresponding to this area. i Represents the model’s output location information for this area, Indicates the real location information of the target corresponding to the area. i Indicates whether the candidate target is a positive sample, that is, whether the candidate region matches one or more real targets. When the candidate region is a positive sample, δ i =1, otherwise δ i =0,L cls represents the classification loss, which can be designed according to the task requirements. The cross entropy loss is preferred. reg Represents the loss of the difference between the predicted target and the true target position. α is the weight to balance the classification loss and position loss.

[0103] Furthermore, this patent proposes a new type of position loss L reg , the position loss value calculation formula is: L reg =max(|x`-x|-r x ,0)+max(|y`-y|-r y ,0)+λ(|w`-w|+|h`-h|.

[0104] Among them, x, and y, are the coordinates of the center point of the target predicted by the model, and x and y are the actual coordinates of the center point of the target. X and r y are the center point range of the target in width and height respectively. w` and h` are the width and height of the minimum bounding rectangle of the target predicted by the model, and w and h are the width and height of the actual minimum bounding rectangle of the target. λ is the weight for balancing the width and height loss and the center point loss, which is a priori value, preferably 0.8.

[0105] In a possible implementation, when generating the loss value of the target detection model, the width and height losses are also calculated.

[0106] S206, optimizing the target detection model based on the loss value of the model to generate a trained target detection model;

[0107] In one possible implementation, when optimizing the model, the parameters of the target detection model are first differentiated according to the loss value of the model to generate a local gradient sequence, and then the target detection model is iteratively optimized using the stochastic gradient descent algorithm and the local gradient sequence. When the number of iterative optimizations is equal to a preset upper limit value or the loss value of the model is less than a preset threshold, the optimization of the model is stopped, and finally a trained target detection model is generated.

[0108] Furthermore, when the number of iterative optimization optimizations is less than a preset upper limit or the loss value of the model is greater than or equal to a preset threshold, continue to execute the step of obtaining the n+1th image input into the target detection model from the model training samples. When n+1 is greater than the number of model training samples, the order of the images in the model training samples is randomly arranged and n=1 is reset.

[0109] S207, determining the trained target detection model as the pre-trained target detection model.

[0110] In an embodiment of the present application, the target detection device first obtains the target image to be detected, and then inputs the target image to be detected into a pre-trained target detection model, wherein the loss function of the pre-trained target detection model is constructed based on the position loss value, and the position loss value is determined based on the center range radius, and the center range radius is determined based on the width and height of the target object's label; secondly, the position of each object in the target image and multiple category probability values ​​are output, and finally the final category of each object is determined based on the multiple category probability values. Since the present application determines the loss value of the model by the center range radius, the optimization of the target center position is improved from regressing a single pixel to regressing to a small range around the center pixel, thereby improving the robustness and generalization ability of the model for target detection.

[0111] The following are embodiments of the device of the present invention, which can be used to implement the method embodiments of the present invention. For details not disclosed in the device embodiments of the present invention, please refer to the method embodiments of the present invention.

[0112] See also Figure 3 , which shows a schematic diagram of the structure of an object detection device provided by an exemplary embodiment of the present invention. The object detection device can be implemented as all or part of a terminal through software, hardware, or a combination of both. The device 1 includes an image acquisition module 10, an image input module 20, an output module 30, and a final category determination module 40.

[0113] An image acquisition module 10 is used to acquire a target image to be detected;

[0114] An image input module 20 is used to input the target image to be detected into a pre-trained target detection model; wherein the loss function of the pre-trained target detection model is constructed based on the position loss value, the position loss value is determined based on the center range radius, and the center range radius is determined based on the width and height of the target object label;

[0115] An output module 30, used to output the position of each object in the target image and multiple category probability values;

[0116] The final category determination module 40 is used to determine the final category of each object according to a plurality of category probability values.

[0117] It should be noted that when the target detection device provided in the above embodiment executes the target detection method, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the target detection device provided in the above embodiment and the target detection method embodiment belong to the same concept, and the implementation process thereof is detailed in the method embodiment, which will not be repeated here.

[0118] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0119] In an embodiment of the present application, the target detection device first obtains the target image to be detected, and then inputs the target image to be detected into a pre-trained target detection model, wherein the loss function of the pre-trained target detection model is constructed based on the position loss value, and the position loss value is determined based on the center range radius, and the center range radius is determined based on the width and height of the target object's label; secondly, the position of each object in the target image and multiple category probability values ​​are output, and finally the final category of each object is determined based on the multiple category probability values. Since the present application determines the loss value of the model by the center range radius, the optimization of the target center position is improved from regressing a single pixel to regressing to a small range around the center pixel, thereby improving the robustness and generalization ability of the model for target detection.

[0120] The present invention also provides a computer-readable medium having program instructions stored thereon, and when the program instructions are executed by a processor, the target detection methods provided by the above-mentioned various method embodiments are implemented.

[0121] The present invention also provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the target detection method of each of the above method embodiments.

[0122] See also Figure 4 , which is a schematic diagram of the structure of a terminal provided in an embodiment of the present application. Figure 4 As shown, the terminal 1000 may include: at least one processor 1001 , at least one network interface 1004 , a user interface 1003 , a memory 1005 , and at least one communication bus 1002 .

[0123] The communication bus 1002 is used to realize the connection and communication between these components.

[0124] The user interface 1003 may include a display screen (Display) and a camera (Camera), and the optional user interface 1003 may also include a standard wired interface and a wireless interface.

[0125] The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).

[0126] Among them, the processor 1001 may include one or more processing cores. The processor 1001 uses various interfaces and lines to connect various parts of the entire electronic device 1000, and executes various functions and processes data of the electronic device 1000 by running or executing instructions, programs, code sets or instruction sets stored in the memory 1005, and calling data stored in the memory 1005. Optionally, the processor 1001 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 1001 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 1001, and it can be implemented separately through a chip.

[0127] Among them, the memory 1005 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 1005 includes a non-transitory computer-readable storage medium. The memory 1005 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 1005 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 1005 may optionally be at least one storage device located away from the aforementioned processor 1001. As Figure 4 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a target detection application.

[0128] exist Figure 4 In the terminal 1000 shown, the user interface 1003 is mainly used to provide an input interface for the user and obtain data input by the user; and the processor 1001 can be used to call the target detection application stored in the memory 1005 and specifically perform the following operations:

[0129] Acquire the target image to be detected;

[0130] Inputting the target image to be detected into a pre-trained target detection model; wherein the loss function of the pre-trained target detection model is constructed based on a position loss value, the position loss value is determined based on a center range radius, and the center range radius is determined based on a width and a height in a label of the target object;

[0131] Output the location of each object in the target image and multiple category probability values;

[0132] The final category of each object is determined based on multiple category probability values.

[0133] In one embodiment, when generating a pre-trained object detection model, the processor 1001 specifically performs the following operations:

[0134] Collect images containing multiple objects, and generate model training samples after constructing object labels for each object in the images;

[0135] Create an object detection model;

[0136] Obtain the nth image from the model training sample and input it into the target detection model, and output the category information and location information of each candidate region in the image;

[0137] Obtain the position label and category label marked on the object contained in the nth image;

[0138] Generate the loss value of the target detection model based on the output position information, output category information, and the position label and category label marked on the object;

[0139] Optimize the target detection model based on the loss value of the model to generate a trained target detection model;

[0140] The trained object detection model is determined as the pre-trained object detection model.

[0141] In one embodiment, when the processor 1001 executes the process of obtaining the category information and location information of each candidate region in the output image from the model training sample in the target detection model of the nth image input, the processor 1001 specifically performs the following operations:

[0142] Obtain the nth image from the model training sample and input it into the feature extraction module to obtain an image feature map;

[0143] Generate multiple candidate regions of different sizes and aspect ratios for each position in the image feature map;

[0144] After the classification module and regression module are used to classify and adjust the position of the candidate areas, the category information and position information of each candidate area in the image are output.

[0145] In one embodiment, when the processor 1001 generates a loss value of the target detection model according to the output position information, the output category information, and the position label and category label marked on the object, the processor 1001 specifically performs the following operations:

[0146] Get the width and height of the object in the object's location tag;

[0147] Calculate the center range radius of the object in the width and height directions respectively, and generate a first range radius and a second range radius;

[0148] Calculate the position loss value according to the first range radius, the second range radius, the position information and the position tag;

[0149] Calculate the classification loss value based on the category information and category label;

[0150] The position loss value and the classification loss value are summed to generate the loss value of the object detection model.

[0151] In one embodiment, when the processor 1001 performs the model-based loss value optimization target detection model to generate a trained target detection model, the processor 1001 specifically performs the following operations:

[0152] The parameters of the target detection model are derived according to the loss value of the model to generate a local gradient sequence;

[0153] The target detection model is iteratively optimized using the stochastic gradient descent algorithm and the local gradient sequence;

[0154] When the number of iterative optimizations is equal to the preset upper limit or the loss value of the model is less than the preset threshold, stop optimizing the model;

[0155] Generate a trained object detection model.

[0156] In one embodiment, when the processor 1001 stops optimizing the model when the number of optimization times of iterative optimization is equal to a preset upper limit value or the loss value of the model is less than a preset threshold value, the following operations are specifically performed:

[0157] When the number of iterative optimization is less than the preset upper limit or the loss value of the model is greater than or equal to the preset threshold, continue to execute the step of obtaining the n+1th image input into the target detection model from the model training samples, and when n+1 is greater than the number of model training samples, randomly arrange the order of the images in the model training samples and reset n=1.

[0158] In one embodiment, when the processor 1001 determines the final category of each object according to the multiple category probability values, the processor 1001 specifically performs the following operations:

[0159] Select the maximum probability value among multiple category probability values;

[0160] Identify the category corresponding to the selected maximum probability value;

[0161] The category corresponding to the maximum probability value is determined as the final category of each object.

[0162] In an embodiment of the present application, the target detection device first obtains the target image to be detected, and then inputs the target image to be detected into a pre-trained target detection model, wherein the loss function of the pre-trained target detection model is constructed based on the position loss value, and the position loss value is determined based on the center range radius, and the center range radius is determined based on the width and height of the target object's label; secondly, the position of each object in the target image and multiple category probability values ​​are output, and finally the final category of each object is determined based on the multiple category probability values. Since the present application determines the loss value of the model by the center range radius, the optimization of the target center position is improved from regressing a single pixel to regressing to a small range around the center pixel, thereby improving the robustness and generalization ability of the model for target detection.

[0163] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the target detection program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only storage memory, or a random access memory, etc.

[0164] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.

Claims

1. A target detection method, characterized in that: The method comprises: Acquire the target image to be detected; Input the target image to be detected into a pre-trained target detection model; wherein the loss function of the pre-trained target detection model is constructed according to a position loss value, the position loss value is determined according to a center range radius, and the center range radius is determined according to a width and a height in a label of the target object; wherein the pre-trained target detection model is generated according to the following steps, including: Collect images containing multiple objects, and generate model training samples after constructing object labels for each object in the images; Create an object detection model; Obtaining the nth image from the model training sample and inputting it into the target detection model, and outputting the category information and location information of each candidate area in the image; Obtaining a position label and a category label marked on the object contained in the nth image; Generate a loss value of a target detection model according to the output position information, the output category information, and the position label and category label marked on the object; Optimizing the target detection model based on the loss value of the model to generate a trained target detection model; The trained target detection model is determined as a pre-trained target detection model; wherein, The generating a loss value of the target detection model according to the output position information, the output category information, and the position label and category label marked on the object includes: Obtain the width and height of the object in the location tag of the object; Calculating the center range radius of the object in two directions of width and height respectively, and generating a first range radius and a second range radius; Calculate a location loss value according to the first range radius, the second range radius, the location information, and the location tag; Calculate a classification loss value according to the category information and the category label; The position loss value and the classification loss value are summed to generate a loss value of the target detection model; Outputting the position of each object in the target image and multiple category probability values; The final category of each object is determined according to the multiple category probability values.

2. The method according to claim 1, characterized in that The target detection model includes a feature extraction module, a classification module and a regression module; The step of obtaining the nth image from the model training sample and inputting it into the target detection model, and outputting the category information and location information of each candidate region in the image, comprises: Obtaining the nth image from the model training sample and inputting it into the feature extraction module to obtain an image feature map; Generating a plurality of candidate regions of different sizes and aspect ratios for each position of the image feature map; After the classification module and the regression module are used to classify and adjust the positions of the candidate regions, the category information and the position information of each candidate region in the image are output.

3. The method according to claim 1, characterized in that The step of optimizing the target detection model based on the loss value of the model to generate a trained target detection model includes: Derivative the parameters of the target detection model according to the loss value of the model to generate a local gradient sequence; Iteratively optimizing the target detection model using a stochastic gradient descent algorithm and the local gradient sequence; When the optimization times of the iterative optimization are equal to a preset upper limit value or the loss value of the model is less than a preset threshold value, the optimization of the model is stopped; Generate a trained object detection model.

4. The method according to claim 3, characterized in that When the optimization times of the iterative optimization are equal to a preset upper limit value or the loss value of the model is less than a preset threshold value, stopping the optimization of the model comprises: When the number of optimization times of the iterative optimization is less than a preset upper limit value or the loss value of the model is greater than or equal to a preset threshold value, continue to execute the step of obtaining the n+1th image from the model training sample and inputting it into the target detection model; when n+1 is greater than the number of the model training samples, randomly arrange the order of the images in the model training samples, and reset n=1.

5. The method according to claim 1, characterized in that Determining the final category of each object according to the multiple category probability values ​​includes: Selecting the maximum probability value among the plurality of class probability values; Identify the category corresponding to the selected maximum probability value; The category corresponding to the maximum probability value is determined as the final category of each object.

6. The method according to claim 1, characterized in that When generating the loss value of the target detection model, it also includes calculating the width and height loss values.

7. A target detection device, characterized in that: The device comprises: An image acquisition module, used to acquire a target image to be detected; An image input module is used to input the target image to be detected into a pre-trained target detection model; wherein the loss function of the pre-trained target detection model is constructed according to a position loss value, the position loss value is determined according to a center range radius, and the center range radius is determined according to the width and height of the target object label; wherein the pre-trained target detection model is generated according to the following steps, including: Collect images containing multiple objects, and generate model training samples after constructing object labels for each object in the images; Create an object detection model; Obtaining the nth image from the model training sample and inputting it into the target detection model, and outputting the category information and location information of each candidate area in the image; Obtaining a position label and a category label marked on the object contained in the nth image; Generate a loss value of a target detection model according to the output position information, the output category information, and the position label and category label marked on the object; Optimizing the target detection model based on the loss value of the model to generate a trained target detection model; The trained target detection model is determined as a pre-trained target detection model; wherein, The generating a loss value of the target detection model according to the output position information, the output category information, and the position label and category label marked on the object includes: Obtain the width and height of the object in the location tag of the object; Calculating the center range radius of the object in two directions of width and height respectively, and generating a first range radius and a second range radius; Calculate a location loss value according to the first range radius, the second range radius, the location information, and the location tag; Calculate a classification loss value according to the category information and the category label; The position loss value and the classification loss value are summed to generate a loss value of the target detection model; An output module, used to output the position of each object in the target image and multiple category probability values; The final category determination module is used to determine the final category of each object according to the multiple category probability values.

8. A computer storage medium, characterized in that: The computer storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the method according to any one of claims 1 to 6.

9. A terminal, characterized in that: include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method according to any one of claims 1 to 6.