Training methods, devices, electronic equipment and media for object detection models
By replacing the original anchor box information with adaptive anchor box information in the small object detection model, the number of anchor boxes is reduced, thus solving the problem of the long training time of the existing small object detection method, and achieving a faster training process and more High model performance.
Patent Information
- Application Number
- CN202210325006.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-29
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2042-03-29
AI Technical Summary
The existing network model of small object detection methods is complex and the training time is too long.
By obtaining multiple sets of training sample data, the adaptive anchor box information is determined based on the target anchor box information, and the original anchor box information of the pre-established initialization model is replaced to obtain an adaptive anchor box model, with less than the number of anchor boxes. Original model, reducing the use of anchor boxes during training.
Based on multiple sets of training sample data, the adaptive anchor box model is trained, which significantly reduces the training time and improves the performance of the model.
Smart Images

Figure CN114821034B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of machine vision technology, and in particular to a training method, device, electronic device and medium for a target detection model. Background Art
[0002] With the development of machine vision technology, small target detection has been widely used in various fields, such as the detection of tiny targets such as ground vehicles and pedestrians by drones, and the detection of ground targets by satellite images.
[0003] However, the inventors of this application discovered that the above technology has at least the following technical problems during the process of implementing the technical solution of the invention in this embodiment:
[0004] The network models of current small target detection methods are complex and the training time is too long. Summary of the invention
[0005] Embodiments of the present invention provide a method, device, electronic device, and medium for training a target detection model to reduce the training time of the target detection model.
[0006] In a first aspect, an embodiment of the present invention provides a method for training a target detection model, comprising:
[0007] Acquire multiple sets of training sample data, wherein the training sample data includes sample images and target anchor frame information corresponding to the sample images;
[0008] Determine adaptive anchor frame information based on the target anchor frame information;
[0009] Replacing original anchor frame information of a pre-established initialization model with the adaptive anchor frame information to obtain an adaptive anchor frame model, wherein the number of anchor frames corresponding to the adaptive anchor frame information is less than the number of anchor frames corresponding to the original anchor frame information;
[0010] Based on the multiple groups of training sample data, the adaptive anchor box model is trained to obtain a small target detection model.
[0011] In a second aspect, an embodiment of the present invention further provides a training device for a target detection model, comprising:
[0012] A training sample acquisition module, used to acquire multiple sets of training sample data, wherein the training sample data includes sample images and target anchor frame information corresponding to the sample images;
[0013] An adaptive anchor box information determination module, used to determine the adaptive anchor box information based on the target anchor box information;
[0014] An information replacement module, configured to replace original anchor frame information of a pre-established initialization model with the adaptive anchor frame information to obtain an adaptive anchor frame model, wherein the number of anchor frames corresponding to the adaptive anchor frame information is less than the number of anchor frames corresponding to the original anchor frame information;
[0015] The model training module is used to train the adaptive anchor box model based on the multiple groups of training sample data to obtain a small target detection model.
[0016] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:
[0017] one or more processors;
[0018] a storage device for storing one or more programs,
[0019] When the one or more programs are executed by the one or more processors, the one or more processors implement the training method of the target detection model provided by any embodiment of the present invention.
[0020] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the training method of the target detection model provided by any embodiment of the present invention.
[0021] The technical solution of the embodiment of the present invention obtains multiple groups of training sample data, wherein the training sample data includes sample images and target anchor frame information corresponding to the sample images; further, adaptive anchor frame information is determined according to the target anchor frame information in the training sample data, and the adaptive anchor frame information is used to replace the original anchor frame information of the pre-established initialization model to obtain an adaptive anchor frame model, wherein the number of anchor frames corresponding to the adaptive anchor frame information is less than the number of anchor frames corresponding to the original anchor frame information, so as to reduce the use of anchor frames during the training process, thereby reducing the training time when the adaptive anchor frame model is trained according to the multiple groups of training sample data. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the following briefly introduces the drawings required to describe the embodiments. Obviously, the drawings introduced are only drawings of a part of the embodiments to be described in the present invention, rather than all the drawings. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0023] Figure 1 A schematic diagram of a flow chart of a method for training a target detection model provided in the first embodiment of the present invention;
[0024] Figure 2 A schematic diagram of a flow chart of a method for training a target detection model provided in the second embodiment of the present invention;
[0025] Figure 3 A schematic diagram of the structure of a training device for a target detection model provided in Embodiment 3 of the present invention;
[0026] Figure 4 This is a schematic diagram of the structure of an electronic device provided in Embodiment 4 of the present invention. DETAILED DESCRIPTION
[0027] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0028] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0029] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0030] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0031] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0032] Embodiment 1
[0033] Figure 1The present invention provides a flowchart of a method for training a target detection model provided in the first embodiment of the present invention. The present embodiment is applicable to the case of automatic detection of small targets in an image. The method can be executed by a training device for the target detection model. The device can be implemented by software and / or hardware and can be configured in a terminal and / or server to implement the method for training the target detection model in the embodiment of the present invention.
[0034] like Figure 1 As shown, the method of this embodiment may specifically include:
[0035] S110, obtaining multiple groups of training sample data, wherein the training sample data includes sample images and target anchor frame information corresponding to the sample images.
[0036] The training sample data may be a pre-made small target training data set, for example, a training data set of tiny targets such as a human body or a vehicle at a distance. In some embodiments, the training sample data may also be a mixed training data set of small targets and large targets, which is not limited here. The training sample data may include a sample image and target anchor frame information corresponding to the sample image. The training sample data may include multiple sample images, each sample image having target anchor frame information corresponding thereto. The target anchor frame information refers to the label information of the sample image, that is, the correct anchor frame coordinate information.
[0037] Specifically, the training sample data can be retrieved from a preset storage path, and the storage paths of the sample images in the training sample data and the target anchor frame information corresponding to the sample images can be different, thereby achieving separate acquisition of the sample images and the corresponding target anchor frame information.
[0038] S120. Determine adaptive anchor frame information based on the target anchor frame information.
[0039] Among them, the adaptive anchor frame information can be used to predetermine the approximate area of the detection target in the sample image, and the adaptive anchor frame information is a preset parameter of the network model to be trained.
[0040] Specifically, each target anchor frame information may be clustered to obtain initial anchor frame information; further, the initial anchor frame information may be scaled based on a preset scaling factor to obtain adaptive anchor frame information of multiple different scaling ratios, so as to improve the accuracy of the adaptive anchor frame information.
[0041] Based on the above embodiment, clustering each target anchor frame information to obtain initial anchor frame information includes: clustering aspect ratios corresponding to each target anchor frame information to obtain initial anchor frame information.
[0042] Exemplarily, the aspect ratio corresponding to the target anchor frame information refers to the ratio of the length to the width of the target anchor frame. A preset number of aspect ratios are randomly selected from the aspect ratios corresponding to each target anchor frame information as the initialized cluster center; the intersection-and-union ratio of the aspect ratio corresponding to each target anchor frame information to the cluster center is determined, and the aspect ratios corresponding to each target anchor frame information are clustered according to the intersection-and-union ratio to obtain clustering results; the mean of multiple aspect ratios in each clustering result is calculated to obtain the aspect ratio center value, and the initial anchor frame information is generated based on the aspect ratio center value.
[0043] S130. Replace original anchor frame information of a pre-established initialization model with the adaptive anchor frame information to obtain an adaptive anchor frame model, wherein the number of anchor frames corresponding to the adaptive anchor frame information is less than the number of anchor frames corresponding to the original anchor frame information.
[0044] Among them, the original anchor frame information refers to the preset parameters of the pre-established initialization model, which corresponds to a large number of anchor frames, which will consume a lot of time in the training stage. In this embodiment, the original anchor frame information of the pre-established initialization model is replaced by the adaptive anchor frame information to obtain an adaptive anchor frame model containing adaptive anchor frame information, thereby reducing the number of anchor frames in the pre-set parameters and thus reducing the training time. The adaptive anchor frame model may also include a backbone network, a neck network and a head network, wherein the backbone network is used for target anchor frame content classification, the neck network is used for multi-scale fusion of feature maps, and the head network is used for calculating losses.
[0045] For example, the original anchor box information sets 9 anchor boxes by default, and the number of anchor boxes of the adaptive anchor box of the present application is 3, which reduces the number of anchor boxes by three times, thereby reducing the fitting time during training by three times, greatly accelerating the speed of training and prediction and improving model performance.
[0046] S140: Based on the multiple groups of training sample data, the adaptive anchor frame model is trained to obtain a small target detection model.
[0047] Specifically, multiple groups of training sample data are input into the adaptive anchor box model in batches to obtain predicted anchor box information. Furthermore, a loss function is determined based on the predicted anchor box information and the target anchor box information corresponding to the sample image. The parameters of the adaptive anchor box model are adjusted based on the loss function until the adaptive anchor box model meets the convergence conditions, thereby obtaining a trained small target detection model.
[0048] The technical solution of the embodiment of the present invention obtains multiple groups of training sample data, wherein the training sample data includes sample images and target anchor frame information corresponding to the sample images; further, adaptive anchor frame information is determined according to the target anchor frame information in the training sample data, and the adaptive anchor frame information is used to replace the original anchor frame information of the pre-established initialization model to obtain an adaptive anchor frame model, wherein the number of anchor frames corresponding to the adaptive anchor frame information is less than the number of anchor frames corresponding to the original anchor frame information, so as to reduce the use of anchor frames during the training process, thereby reducing the training time when the adaptive anchor frame model is trained according to the multiple groups of training sample data.
[0049] Embodiment 2
[0050] Figure 2 A flowchart of the training method of the target detection model provided in Example 2 of the present invention. This embodiment is based on any optional technical scheme in the embodiments of the present invention. Optionally, the adaptive anchor box model is trained based on the multiple groups of training sample data to obtain a small target detection model, including: inputting the multiple groups of training sample data into the adaptive anchor box model in batches to obtain predicted anchor box information; determining a loss function based on the predicted anchor box information and the target anchor box information corresponding to the sample image, and adjusting the parameters of the adaptive anchor box model based on the loss function until the adaptive anchor box model meets the convergence conditions.
[0051] like Figure 2 As shown, the method of this embodiment may specifically include:
[0052] S210 . Acquire multiple groups of training sample data, wherein the training sample data includes sample images and target anchor frame information corresponding to the sample images.
[0053] S220. Determine adaptive anchor frame information based on the target anchor frame information.
[0054] S230. Replace the original anchor frame information of the pre-established initialization model with the adaptive anchor frame information to obtain an adaptive anchor frame model, wherein the number of anchor frames corresponding to the adaptive anchor frame information is less than the number of anchor frames corresponding to the original anchor frame information.
[0055] S240 , inputting multiple groups of training sample data into the adaptive anchor box model in batches to obtain predicted anchor box information.
[0056] S250, determining a loss function based on the predicted anchor box information and the target anchor box information corresponding to the sample image, and adjusting parameters of the adaptive anchor box model based on the loss function until the adaptive anchor box model meets a convergence condition.
[0057] In this embodiment, sample images in multiple sets of training sample data are used as model inputs and input into the adaptive anchor box model in batches to obtain predicted anchor box information corresponding to the sample images. Furthermore, a loss function can be determined based on the predicted anchor box information corresponding to the sample image phenomenon and the target anchor box information corresponding to the sample image, and the adaptive anchor box model is trained according to the loss function until a trained small target detection model is obtained.
[0058] On the basis of the above embodiments, before determining the loss function based on the predicted anchor box information and the target anchor box information corresponding to the sample image, the method also includes: determining the ratio of each of the sample images to the target anchor box area corresponding to the sample image; determining an adjustment parameter based on a threshold range corresponding to the ratio; accordingly, determining the loss function based on the predicted anchor box and the target anchor box corresponding to the sample image includes: determining the loss function based on the predicted anchor box information, the target anchor box information corresponding to the sample image and the adjustment parameter.
[0059] In some embodiments, the number of large and small targets in the test set is easily unbalanced. Usually, small targets are in a relatively small number. When calculating the loss function, small targets will be ignored, and the model will focus more on fitting the large target frame to accurately locate it. In order to solve the above problems, the present application introduces an adjustment parameter. It should be noted that the adjustment parameter represents the degree of importance attached to the detection target in the sample image, that is, the larger the value of the adjustment parameter, the higher the importance attached to the detection target, which can be used for the calculation of the loss function. When the adaptive anchor frame model is trained according to the loss function containing the adjustment parameter, the importance of each sample image is adjusted in real time according to the adjustment parameter to increase the attention to the sample image containing the small target, so that the model is more biased towards the positioning accuracy of the small target when the parameters are updated.
[0060] Specifically, the corresponding area ratio may be determined according to the overall area of each sample image and the area of the target anchor frame area corresponding to the sample image, and the corresponding threshold range may be determined according to the area ratio to determine the adjustment parameter. The threshold range may be divided according to the size of the target to obtain multiple threshold ranges.
[0061] On the basis of the above embodiments, before determining the ratio of each of the sample images to the target anchor frame area corresponding to the sample image, the method also includes: scaling each of the sample images to obtain sample images of the same size, and adaptively scaling the target anchor frame information corresponding to the sample images; accordingly, determining the ratio of each of the sample images to the target anchor frame area corresponding to the sample image includes: determining the ratio based on the sample images of the same size and the target anchor frame areas corresponding to the sample images of the same size.
[0062] It is understandable that by scaling the sample images to obtain sample images of the same size, such as 640*640, and the number of pixels in the sample images is the same, the ratio can be determined directly based on the number of pixels without determining the area, thus reducing the ratio calculation process.
[0063] Specifically, the ratio can be determined based on the number of pixels of each sample image of the same size and the number of pixels of the target anchor frame area corresponding to the sample images of the same size. In other words, the number of pixels of the target anchor frame area corresponding to the sample images of the same size is divided by the number of pixels of the sample image to obtain the ratio. If the ratio is less than the first point count threshold, the adjustment parameter is the first parameter value; if the ratio is greater than the second point count threshold, the adjustment parameter is the second parameter value; if the ratio is greater than the first point count threshold and less than the second point count threshold, the adjustment parameter is the third parameter value, wherein the third parameter value is between the first parameter value and the second parameter value. The first point count threshold and the second point count threshold can be set according to the boundary of dividing large and small targets.
[0064] For example, S can be used to represent the number of pixels in the sample image after scaling, p can represent the number of pixels in the target anchor box area, and the first point number threshold can be S / 2 10 , the second point threshold can be S / 2 8 ; The formula of the ratio is as follows:
[0065]
[0066] Among them, α represents the ratio, p≤S / 2 10 Sample image representing an invalid target, S / 2 10 ≤p≤S / 2 8 represents a small target sample image, p>S / 2 8 Represents a sample image of a large target. Its final loss function can be expressed as:
[0067]
[0068] Among them, GIOU (Generalized Intersection over Union) is a distance metric in target detection and can be used to calculate the loss function.
[0069] The technical solution of the embodiment of the present invention can update the adjustment parameters corresponding to the ratio in real time according to the number of pixels in the target anchor frame area, that is, adjust the loss function in real time to increase the importance of small targets, thereby improving the detection accuracy of the small target detection model.
[0070] Embodiment 3
[0071] Figure 3This is a schematic diagram of the structure of the target detection model training device provided in the third embodiment of the present invention. The target detection model training device provided in this embodiment can be implemented by software and / or hardware, and can be configured in a terminal and / or a server to implement the target detection model training method in the embodiment of the present invention. The device may specifically include:
[0072] The training sample acquisition module 310 is used to acquire multiple sets of training sample data, wherein the training sample data includes sample images and target anchor frame information corresponding to the sample images;
[0073] An adaptive anchor box information determination module 320, configured to determine adaptive anchor box information based on the target anchor box information;
[0074] An information replacement module 330 is used to replace the original anchor frame information of the pre-established initialization model with the adaptive anchor frame information to obtain an adaptive anchor frame model, wherein the number of anchor frames corresponding to the adaptive anchor frame information is less than the number of anchor frames corresponding to the original anchor frame information;
[0075] The model training module 340 is used to train the adaptive anchor box model based on the multiple groups of training sample data to obtain a small object detection model.
[0076] The technical solution of the embodiment of the present invention obtains multiple groups of training sample data, wherein the training sample data includes sample images and target anchor frame information corresponding to the sample images; further, adaptive anchor frame information is determined according to the target anchor frame information in the training sample data, and the adaptive anchor frame information is used to replace the original anchor frame information of the pre-established initialization model to obtain an adaptive anchor frame model, wherein the number of anchor frames corresponding to the adaptive anchor frame information is less than the number of anchor frames corresponding to the original anchor frame information, so as to reduce the use of anchor frames during the training process, thereby reducing the training time when the adaptive anchor frame model is trained according to the multiple groups of training sample data.
[0077] Based on any optional technical solution in the embodiments of the present invention, optionally, the adaptive anchor frame information determination module 320 includes:
[0078] An anchor frame information clustering unit, used to cluster the target anchor frame information to obtain initial anchor frame information;
[0079] The anchor frame information scaling unit is used to scale the initial anchor frame information based on a preset scaling factor to obtain adaptive anchor frame information of multiple different scaling ratios.
[0080] On the basis of any optional technical solution in the embodiments of the present invention, optionally, the anchor frame information clustering unit is specifically used for:
[0081] The aspect ratios corresponding to the target anchor frame information are clustered to obtain initial anchor frame information.
[0082] Based on any optional technical solution in the embodiments of the present invention, optionally, the model training module 340 includes:
[0083] A predicted anchor box information determination unit, used to input multiple groups of training sample data into the adaptive anchor box model in batches to obtain predicted anchor box information;
[0084] A loss function determination unit is used to determine a loss function based on the predicted anchor box information and the target anchor box information corresponding to the sample image, and adjust the parameters of the adaptive anchor box model based on the loss function until the adaptive anchor box model meets the convergence condition.
[0085] Based on any optional technical solution in the embodiments of the present invention, optionally, the device further includes:
[0086] A ratio determination unit, used to determine the ratio of each of the sample images to the target anchor frame area corresponding to the sample image;
[0087] an adjustment parameter determining unit, configured to determine an adjustment parameter based on a threshold range corresponding to the ratio;
[0088] Accordingly, the loss function determination unit is also used for:
[0089] A loss function is determined based on the predicted anchor box information, the target anchor box information corresponding to the sample image, and the adjustment parameter.
[0090] Based on any optional technical solution in the embodiments of the present invention, optionally, the device is further used for:
[0091] Scaling the size of each of the sample images to obtain sample images of the same size, and adaptively scaling the target anchor frame information corresponding to the sample images;
[0092] Accordingly, the ratio determination unit further includes:
[0093] The ratio determination subunit is used to determine the ratio based on the sample images of the same size and the target anchor frame area corresponding to the sample images of the same size.
[0094] Based on any optional technical solution in the embodiments of the present invention, optionally, the ratio determination subunit is specifically used for:
[0095] The ratio is determined based on the number of pixels of each sample image of the same size and the number of pixels of the target anchor frame area corresponding to the sample image of the same size.
[0096] Based on any optional technical solution in the embodiments of the present invention, optionally, the adjustment parameter determination unit is specifically used to:
[0097] If the ratio is less than the first point threshold, the adjustment parameter is the first parameter value;
[0098] If the ratio is greater than a second point threshold, the adjustment parameter is a second parameter value;
[0099] If the ratio is greater than a first point threshold and less than a second point threshold, the adjustment parameter is a third parameter value, wherein the third parameter value is between the first parameter value and the second parameter value.
[0100] The above-mentioned device can execute the training method of the target detection model provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects for executing the training method of the target detection model.
[0101] Embodiment 4
[0102] Figure 4 This is a schematic diagram of the structure of an electronic device provided in Embodiment 4 of the present invention. Figure 4 A block diagram of an exemplary electronic device 12 suitable for use in implementing embodiments of the present invention is shown. Figure 4 The electronic device 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0103] like Figure 4 As shown, the electronic device 12 is in the form of a general purpose computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that connects various system components (including the system memory 28 and the processing unit 16).
[0104] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. By way of example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.
[0105] The electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0106] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 4 not shown, usually called a "hard drive"). Although Figure 4 Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The system memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the embodiments of the present invention.
[0107] A program / utility 36 having a set (at least one) of program modules 26 may be stored, for example, in system memory 28, such program modules 26 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. Program modules 26 generally perform the functions and / or methods of the embodiments described herein.
[0108] The electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), may communicate with one or more devices that enable a user to interact with the electronic device 12, and / or may communicate with any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed via an input / output (I / O) interface 22. Furthermore, the electronic device 12 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 20. Figure 4 As shown, the network adapter 20 communicates with other modules of the electronic device 12 via the bus 18. It should be understood that although Figure 4 Not shown, other hardware and / or software modules may be used in conjunction with the electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0109] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, such as implementing a method for training a target detection model provided in an embodiment of the present invention.
[0110] Embodiment 5
[0111] Embodiment 5 of the present invention further provides a storage medium containing computer executable instructions, wherein the computer executable instructions are used to execute a method for training a target detection model when executed by a computer processor, the method comprising:
[0112] Acquire multiple sets of training sample data, wherein the training sample data includes sample images and target anchor frame information corresponding to the sample images;
[0113] Determine adaptive anchor frame information based on the target anchor frame information;
[0114] Replacing original anchor frame information of a pre-established initialization model with the adaptive anchor frame information to obtain an adaptive anchor frame model, wherein the number of anchor frames corresponding to the adaptive anchor frame information is less than the number of anchor frames corresponding to the original anchor frame information;
[0115] Based on the multiple groups of training sample data, the adaptive anchor box model is trained to obtain a small target detection model.
[0116] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.
[0117] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0118] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0119] Computer program code for performing the operation of embodiments of the present invention may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0120] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A method for training a target detection model, characterized in that: include: Acquire multiple sets of training sample data, wherein the training sample data includes sample images and target anchor frame information corresponding to the sample images; Determine adaptive anchor frame information based on the target anchor frame information; Replacing original anchor frame information of a pre-established initialization model with the adaptive anchor frame information to obtain an adaptive anchor frame model, wherein the number of anchor frames corresponding to the adaptive anchor frame information is less than the number of anchor frames corresponding to the original anchor frame information; Based on the multiple groups of training sample data, the adaptive anchor frame model is trained to obtain a small target detection model; The step of training the adaptive anchor frame model based on the multiple sets of training sample data to obtain a small target detection model includes: Inputting multiple groups of training sample data into the adaptive anchor frame model in batches to obtain predicted anchor frame information; Determining a loss function based on the predicted anchor box information and the target anchor box information corresponding to the sample image, and adjusting parameters of the adaptive anchor box model based on the loss function until the adaptive anchor box model meets a convergence condition; Wherein, before determining the loss function based on the predicted anchor frame information and the target anchor frame information corresponding to the sample image, the method further includes: Determine the ratio of each of the sample images to the target anchor frame area corresponding to the sample image; determining an adjustment parameter based on a threshold range corresponding to the ratio; Accordingly, the loss function is determined based on the predicted anchor frame and the target anchor frame corresponding to the sample image, including: A loss function is determined based on the predicted anchor box information, the target anchor box information corresponding to the sample image, and the adjustment parameter.
2. The method according to claim 1, characterized in that The determining the adaptive anchor frame information based on the target anchor frame information includes: Clustering the target anchor frame information to obtain initial anchor frame information; The initial anchor frame information is scaled based on a preset scaling factor to obtain a plurality of adaptive anchor frame information with different scaling ratios.
3. The method according to claim 2, characterized in that The clustering of the target anchor frame information to obtain initial anchor frame information includes: The aspect ratios corresponding to the target anchor frame information are clustered to obtain initial anchor frame information.
4. The method according to claim 1, characterized in that Before determining the ratio of each of the sample images to the target anchor frame area corresponding to the sample image, the method further includes: Scaling the size of each of the sample images to obtain sample images of the same size, and adaptively scaling the target anchor frame information corresponding to the sample images; Correspondingly, determining the ratio of each of the sample images to the target anchor frame area corresponding to the sample image includes: A ratio is determined based on the sample images of the same size and the target anchor frame areas corresponding to the sample images of the same size.
5. The method according to claim 4, characterized in that The determining the ratio based on the sample images of the same size and the target anchor frame area corresponding to the sample images of the same size includes: The ratio is determined based on the number of pixels of each sample image of the same size and the number of pixels of the target anchor frame area corresponding to the sample image of the same size.
6. The method according to claim 1, characterized in that The determining the adjustment parameter based on the threshold range corresponding to the ratio includes: If the ratio is less than the first point threshold, the adjustment parameter is the first parameter value; If the ratio is greater than a second point threshold, the adjustment parameter is a second parameter value; If the ratio is greater than a first point threshold and less than a second point threshold, the adjustment parameter is a third parameter value, wherein the third parameter value is between the first parameter value and the second parameter value.
7. A training device for a target detection model, characterized in that: include: A training sample acquisition module, used to acquire multiple sets of training sample data, wherein the training sample data includes sample images and target anchor frame information corresponding to the sample images; An adaptive anchor box information determination module, used to determine the adaptive anchor box information based on the target anchor box information; An information replacement module, configured to replace original anchor frame information of a pre-established initialization model with the adaptive anchor frame information to obtain an adaptive anchor frame model, wherein the number of anchor frames corresponding to the adaptive anchor frame information is less than the number of anchor frames corresponding to the original anchor frame information; A model training module, used to train the adaptive anchor frame model based on the multiple sets of training sample data to obtain a small target detection model; Wherein, the model training module includes: A predicted anchor box information determination unit, used to input multiple groups of training sample data into the adaptive anchor box model in batches to obtain predicted anchor box information; The loss function determining unit is used to determine a loss function based on the predicted anchor box information and the target anchor box information corresponding to the sample image, and adjust the parameters of the adaptive anchor box model based on the loss function until the adaptive anchor box model meets the convergence condition; Wherein, the device further comprises: a ratio determination unit, configured to determine a ratio of each of the sample images to a target anchor frame area corresponding to the sample image before determining a loss function based on the predicted anchor frame information and the target anchor frame information corresponding to the sample image; an adjustment parameter determining unit, configured to determine an adjustment parameter based on a threshold range corresponding to the ratio; The loss function determination unit is further used to determine the loss function based on the predicted anchor frame information, the target anchor frame information corresponding to the sample image and the adjustment parameter.
8. An electronic device, characterized in that: The electronic device comprises: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the training method of the target detection model as described in any one of claims 1-6.
9. A storage medium containing computer executable instructions, characterized in that: The computer executable instructions, when executed by a computer processor, are used to execute the training method of the target detection model as described in any one of claims 1-6.
Citation Information
Patent Citations
Model training method and device, target detection method and device, equipment and storage medium
CN113569968A
Model training method and device, target detection method and device, equipment and storage medium
CN113657482A