Training method, electronic device, and computer-readable storage medium
By transforming the size and position of the target object region to generate multiple images for training detection models, the problem of missed detection by the target re-detection model under changes in lighting, occlusion and shooting angle is solved, and higher detection accuracy is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG DAHUA TECH CO LTD
- Filing Date
- 2021-12-29
- Publication Date
- 2026-04-28
AI Technical Summary
Existing target re-detection models struggle to accurately identify whether the target object in the template image exists in the search image when faced with changes in lighting, occlusion, and shooting angle, leading to frequent missed detections.
The first target image is generated by extracting the target object region from the original image and performing size transformation processing. The second target image is generated by performing position and size transformation processing on the original image. The detection model is trained using these two images to adapt the model to the size changes of the target object.
It improves the adaptive capability of the detection model, enabling it to accurately detect target objects even when their size changes in the image to be identified, thus avoiding missed detections.
Smart Images

Figure CN114462492B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of deep learning technology, and in particular to a training method, electronic device, and computer-readable storage medium. Background Technology
[0002] In real-world scenarios, target areas in images are inevitably affected by factors such as lighting, occlusion, and shooting angle, resulting in significant differences between the detected objects in the search image and those in the template image. Consequently, the target re-detection model may fail to identify whether the detected objects in the template image exist in the search image, leading to missed detections. Summary of the Invention
[0003] This application provides a training method, an electronic device, and a computer-readable storage medium that can improve the adaptive capability of the trained detection model.
[0004] A first aspect of this application provides a training method, the method comprising: obtaining a target object region from an original image; performing a first transformation process on the size of the target object region based on a first preset size range to obtain a first target image, wherein the size of the first target image belongs to the first preset size range; performing a second transformation process on the original image to change the target object region in the original image, thereby obtaining a second target image; and training a detection model using the first target image and the second target image; wherein, after receiving the first target image and the second target image, the detection model detects whether a target object contained in the first target image exists in the second target image.
[0005] A second aspect of this application provides a detection method, the method comprising: inputting an image to be identified into a detection model; using the detection model, based on a first target image, determining whether a target object contained in the first target image exists in the image to be identified; wherein the detection model is trained by the above-described training method; and the first target image is obtained by performing the first transformation processing on a reference image containing the target object.
[0006] A third aspect of this application provides an electronic device, which includes a processor, a memory, and a communication circuit. The processor is coupled to the memory and the communication circuit, respectively. The memory stores program data, and the processor executes the program data in the memory to implement the steps in the above method.
[0007] A fourth aspect of this application provides a computer-readable storage medium storing a computer program that can be executed by a processor to implement the steps in the above-described method.
[0008] The beneficial effects are as follows: The training method of this application includes: obtaining the target object region from the original image; performing a first transformation process on the size of the target object region based on a first preset size range to obtain a first target image, the size of the first target image belonging to the first preset size range; performing a second transformation process on the original image to change the target object region in the original image, thereby obtaining a second target image; and training the detection model using the first target image and the second target image; wherein, after receiving the first target image and the second target image, the detection model detects whether the target object contained in the first target image exists in the second target image. The training method of this application makes the size of the target object in the first target image and the size of the target object in the second target image no longer the same, which can simulate the detection stage, where the target object in the image to be identified input to the detection model may change relative to the target object in the first target image. This allows the detection model to detect the target object in the image to be identified regardless of whether the size of the target object in the image to be identified changes relative to the size in the first target image, thereby improving the adaptive ability of the detection model and avoiding missed detections. Attached Figure Description
[0009] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Wherein:
[0010] Figure 1 This is a flowchart illustrating one implementation method of the training method of this application;
[0011] Figure 2 This is a schematic diagram of the detection model in this application;
[0012] Figure 3 yes Figure 2 A schematic diagram of the structure of the central region proposal module;
[0013] Figure 4 This is a schematic diagram of one embodiment of the detection method of this application;
[0014] Figure 5 This is a schematic diagram of the structure of one embodiment of the electronic device of this application;
[0015] Figure 6 This is a schematic diagram of another embodiment of the electronic device of this application;
[0016] Figure 7 This is a schematic diagram of another embodiment of the electronic device of this application;
[0017] Figure 8 This is a schematic diagram of one embodiment of the computer-readable storage medium of this application. Detailed Implementation
[0018] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0019] See Figure 1 , Figure 1 This is a flowchart illustrating one embodiment of the training method of this application, which includes:
[0020] S110: Obtain the target object region from the original image.
[0021] The original image includes the target object. First, the target object in the original image is identified, and then the region within the detection box of the target object is extracted to obtain the target object region.
[0022] In one application scenario, to improve the accuracy of the subsequent training process, the original image is preprocessed so that the target object region is located in a preset region at the center of the original image. For example, the center of the preset region coincides with the center of the original image, and the size of the preset region is 127×127.
[0023] S120: Based on the first preset size range, the size of the target object region is transformed to obtain a first target image, the size of the first target image belonging to the first preset size range.
[0024] After extracting the target object region, the size of the target object region is transformed so that the size of the obtained first target image belongs to the first preset size range. Step S120 can be understood as standardizing the target object region.
[0025] Understandably, the target object occupies the vast majority of the first target image.
[0026] S130: Perform a second transformation on the original image to change the target object region in the original image, thereby obtaining a second target image.
[0027] Step S120 involves extracting the target object region and then processing it to obtain the first target image; while step S130 involves processing the original image to change the target object region in the original image, and the processed original image is the second target image.
[0028] It is understandable that the proportion of the target object in the second target image is smaller than the proportion of the target object in the first target image.
[0029] After steps S120 and S130, the size of the target object in the first target image may no longer be the same as the size of the target object in the second target image.
[0030] S140: Train the detection model using the first target image and the second target image.
[0031] The detection model, after receiving the first target image and the second target image, detects whether the second target image contains the target object contained in the first target image.
[0032] The detection model is a target re-detection model. After receiving the first target image and the second target image, it determines whether the target object included in the first target image exists in the second target image, and then outputs the position and category confidence of the target object included in the first target image in the second target image.
[0033] The second target image can be understood as the image to be identified, and the purpose of the detection model is to detect whether the target object contained in the first target image exists in the image to be identified.
[0034] In existing technologies, when the size of the target object in the image to be identified changes relative to the size of the target object in the first target image, the detection model is prone to missing detections. However, in this embodiment, during the training of the detection model, the processing in steps S110 to S130 makes it possible that the size of the target object in the first target image is no longer the same as the size of the target object in the second target image. This can simulate the detection stage, where the target object in the image to be identified input to the detection model may change relative to the target object in the first target image. As a result, during the detection stage, regardless of whether the size of the target object in the image to be identified changes relative to the size in the first target image, the detection model can detect the target object in the image to be identified, thereby improving the adaptive ability of the detection model and avoiding missing detections.
[0035] In one application scenario, step S120 specifically includes: performing a first transformation process on the size of the target object region so that the obtained first target image is square, and the side length of the square belongs to a first preset size range.
[0036] Specifically, adjusting the target object region into a square-shaped first target image can improve the efficiency of the detection model when processing images. The side length of the first target image can be any value within a first preset size range.
[0037] It should be noted that in other embodiments, the first target image may also be rectangular, as long as the width and height of the first target image fall within the range of the first preset size.
[0038] In one application scenario, the first transformation process includes at least one of scaling the target object region and filling the area around the target object region. Specifically, scaling may be performed only on the target object region, filling may be performed only on the area around the target object region, or both scaling and filling may be performed. When both scaling and filling are performed, scaling or filling may be performed first.
[0039] For example, step S120 specifically includes:
[0040] (a1) Scale the target object area proportionally until the long side of the scaled target object area falls within the first preset size range.
[0041] Scaling the target object area proportionally can prevent the target object from being deformed.
[0042] When scaling the target object area, the longer side of the scaled target object area can be a preset value, such as 63. Of course, this application is not limited to this, as long as the longer side of the scaled target object area is within the first preset size range.
[0043] (b1) Fill the area around the scaled target object region to obtain the first target image.
[0044] In this process, image blocks with a pixel value of 127.5 can be used to fill the scaled target object area. However, this application is not limited to this; image blocks with pixel values of 0, 100, or 255 can also be used for filling.
[0045] When filling the periphery of the scaled target object region, the filling process can be performed on the short side of the scaled target object region, or on both the long and short sides of the scaled target object region at the same time, as long as the width and height of the obtained first target image are within the first preset range.
[0046] For example, in a specific instance, the target object area is first scaled proportionally so that the long side of the scaled target object area is a preset value, such as 63. Then, the short side of the scaled target object area is filled so that the first target image is a square and the side length of the square is the preset value.
[0047] The above describes the first transformation process for the size of the target object region. The following describes the second transformation process for the original image:
[0048] In one application scenario, step S130 includes: performing a second transformation process on the original image to change at least one of the size and position of the target object region in the original image.
[0049] Specifically, the purpose of performing the second transformation on the original image is to change at least one of the size and position of the target object region in the original image. This can be done by changing only the size or position of the target object region in the original image, or by changing both the size and position of the target object region in the original image simultaneously.
[0050] In one application scenario, step S130 specifically includes: performing a second transformation process on the original image to randomly change the width and height of the target object region in the original image, and making the scaling ratio of the width and height of the target object region fall within a second preset range.
[0051] Specifically, the width and height of the target object region are randomly changed to simulate the deformation of the target object, ensuring that the size of the target object in the first target image is different from the size of the target object in the second target image. Specifically, after randomly changing the width and height of the target object region, the width-to-height ratio of the target object region changes randomly.
[0052] Wherein, after randomly changing the width and height of the target object area, the ratio of the width of the target object area to the width before the change is within a second preset range, and the ratio of the height of the target object area to the height before the change is within a second preset range. This application does not impose specific limitations on the second preset range.
[0053] In one application scenario, the scaling ratio of the width and height of the target object region follows a uniform distribution U(1-s1, 1+s1), where the parameter s1 simulates the maximum deformation intensity, for example, 0.18.
[0054] In other application scenarios, the scaling ratio of the width and height of the target object area can also fall into different ranges, and no restrictions are imposed here.
[0055] In another application scenario, step S130 specifically includes: performing a second transformation process on the original image to randomly change the position of the target object region in the original image, and making the offset of the target object region within a preset offset range.
[0056] Specifically, the target object region is randomly translated, such that the offset of the target object region in the first direction (specifically, the number of pixels translated) falls within a corresponding first offset range, and the offset in the second direction falls within a corresponding second offset range. The first and second offset ranges can be equal or unequal. The first and second directions are perpendicular to each other. In one application scenario, the first and second offset ranges are equal, and the translation of the target object region in the first and second directions is any value within the interval (-s2, s2). Here, s2 is the maximum offset, which can be 64.
[0057] In other embodiments, when performing the second transformation process on the original image, the width and height of the target object region can be changed randomly first, and then the position of the target object region can be changed randomly; alternatively, the position of the target object region can be changed randomly first, and then the width and height of the target object region can be changed randomly.
[0058] In this embodiment, in order to enable the detection model to adapt to multi-scale transformations, a filling process is performed on the periphery of the second target image before step S140, so that step S140 is performed based on the second target image after the filling process.
[0059] In one application scenario, an image block with a pixel value of 127.5 is used to fill the perimeter of the second target image. In other application scenarios, the pixel values of the pixels in the filled image block can also be other values, such as 100 or 150.
[0060] After filling the second target image, the proportion of the target object in the second target image can be changed, thereby improving the adaptability of the detection model in different detection environments.
[0061] In one application scenario, in order to improve the efficiency of the detection model in image processing, when filling the perimeter of the second target image, the filled second target image is made into a square, and the side length of the square is a random value in a preset set, where the preset set can be {255±8n|n=-6,…,32}.
[0062] See Figure 2 The detection model in this embodiment includes a first feature extraction module 110, a second feature extraction module 120, a region proposal module 130, and a loss module 140.
[0063] The first feature extraction module 110 is used to extract features from the first target image to obtain a first feature map; the second feature extraction module 120 is used to extract features from the second target image to obtain a second feature map.
[0064] Combination Figure 3 The region proposal module 130 includes a downsampling unit 131, a cross-correlation unit 132, a classification head 133, and a regression head 134. The downsampling unit 131 downsamples the first feature map to obtain a third feature map. The cross-correlation unit 132 cross-corresponds the second and third feature maps. The classification head 133 outputs a classification feature map representing the category of the target object in the second target image based on the processing result of the cross-correlation unit 132. The regression head 134 outputs a location feature map representing the position of the target object in the second target image based on the processing result of the cross-correlation unit 132. The cross-correlation process performed by the cross-correlation unit 132 is prior art and will not be described in detail here.
[0065] The loss module 140 receives the classification feature map and location feature map output by the region proposal module 130 and calculates the loss function.
[0066] In this embodiment, the downsampling unit 131 is used to downsample the first feature map, which can reduce the amount of data in subsequent processing, improve processing efficiency, and is easy to implement and expand in engineering.
[0067] In one application scenario, the downsampling unit 131 is a pooling unit that performs pooling processing on the first feature map to reduce the amount of data processed subsequently.
[0068] In other application scenarios, the downsampling unit 131 can also perform convolution operations or a combination of convolution and pooling operations on the first feature map, as long as it can reduce the size of the first feature map.
[0069] In one application scenario, when the pooling unit performs pooling processing on the first feature map, the pooling window size is 7×7, and the first feature map is specifically subjected to max pooling processing.
[0070] In other application scenarios, the pooling window size can also be 5×5, etc., and specifically, the first feature map can be subjected to average pooling or min pooling, etc., without any restrictions.
[0071] In other embodiments, in addition to downsampling the first feature map, the downsampling unit 131 can also downsampling the second feature map simultaneously to further reduce the computational load.
[0072] Continue reading Figure 2The number of region proposal modules 130 is at least two. Figure 2 (Three modules are described below) The first feature extraction module 110 performs multi-layer feature extraction on the received first target image to obtain at least two first feature maps of the same size but different semantic levels; the second feature extraction module 120 performs multi-layer feature extraction on the received second target image to obtain at least two second feature maps of the same size but different semantic levels; the region proposal module 130 receives the first feature map and the second feature map of the same semantic level.
[0073] The first feature extraction module 110 and the second feature extraction module 120 are structurally identical and use a modified ResNet50 backbone. The ResNet50 backbone comprises five feature extraction units, designated as layer 0, layer 1, and so on. The feature maps output by the layer 0 feature extraction units in both modules 110 and 120 have the same semantic level, as do the feature maps output by the layer 1 feature extraction units, and so on.
[0074] In this embodiment, after modifying the ResNet50 backbone, the feature map sizes output by the feature extraction units of layers 2, 3, and 4 are made to be the same.
[0075] In one application scenario, when modifying the ResNet50 backbone, the stride of the second feature extraction unit is changed to 1, and the stride of the third and fourth feature extraction units is changed to 2. Furthermore, the convolutional layers in the third and fourth feature extraction units are changed to dilated convolutional layers, with dilation rates of 1 and 2 set to the same values. In other application scenarios, other methods can be used to modify the ResNet50 backbone, as long as it outputs at least two feature maps of the same size but different semantic levels.
[0076] In other words, in the first feature extraction module 110, the first feature maps output by the second, third and fourth layer feature extraction units have the same size but different semantic levels. In the second feature extraction module 120, the second feature maps output by the second, third and fourth layer feature extraction units have the same size but different semantic levels.
[0077] Simultaneously, the first and second feature maps at the same semantic level are fed into the same region proposal module 130 for cross-correlation processing. Corresponding to the aforementioned second, third, and fourth layer feature extraction units, there are three region proposal modules 130: one region proposal module 130 receives the first feature map output by the second layer feature extraction unit in the first feature extraction module 110 and the second feature map output by the second layer feature extraction unit in the second feature extraction module 120; one region proposal module 130 receives the first feature map output by the third layer feature extraction unit in the first feature extraction module 110 and the second feature map output by the third layer feature extraction unit in the second feature extraction module 120; and the third region proposal module 130 receives the first feature map output by the fourth layer feature extraction unit in the first feature extraction module 110 and the second feature map output by the fourth layer feature extraction unit in the second feature extraction module 120. The feature maps output by the three region proposal modules 130 are then fed into the loss module 140, which calculates the loss function based on the received feature maps.
[0078] In this embodiment, during the detection model training process in step S140, multiple training batches (also called batches) are used to train the detection model, wherein each training batch includes multiple first target images and second target images.
[0079] Among them, the sizes of multiple first target images in multiple training batches belong to a first preset size range.
[0080] During the training process, several epochs are set, such as 20 epochs. In each epoch, images from multiple training batches are successively fed into the detection model.
[0081] Specifically, during the training process, after all the first and second target images included in a batch are input into the detection model, the loss function is calculated based on the output of the detection model. Then, the parameters of the detection model are adjusted. Then, all the first and second target images included in the next batch are input into the detection model. The above process is repeated until all the first and second target images in all batches are traversed, thus ending one epoch, and then starting the next epoch.
[0082] The training process includes a warm-up phase and a retraining phase, which will be described using 20 epochs as an example:
[0083] The first 5 epochs are set as the warm-up phase, and the next 15 epochs are set as the retraining phase. In order to ensure the training speed and accuracy of the detection model, the learning rate of the detection model is gradually increased during the warm-up phase, and gradually decreased during the retraining phase.
[0084] In one application scenario, the initial learning rate is set to 0.001. After the warm-up phase, the learning rate is reduced to 0.005. Then, after the retraining phase, the learning rate is reduced to 0.0005. Specifically, the learning rate t of the detection model in each epoch is calculated using the following formula:
[0085]
[0086] Here, the 20 epochs are numbered from beginning to end according to the training process, starting from 0, where i is the number of the current epoch.
[0087] In multiple training batches, different second target images can come from different original images or from the same original image. When they come from the same original image, during the construction of the training batch, the original image is first copied to obtain multiple original images. Then, these multiple original images are subjected to a second transformation with different parameters to obtain multiple second target images. At this time, the size, position, etc. of the target object region in the multiple second target images are not completely the same.
[0088] Specifically, when training the detection model, the first target image input into the detection model is the same, but the second target image is different; or the first target image input into the detection model is different, but the second target image is the same; or both the first target image and the second target image input into the detection model are different.
[0089] Specifically, when training the detection model using multiple training batches, the size of the second target image in the same training batch is the same, while the size of the second target image in different training batches is different.
[0090] When filling the second target image, a value can be randomly selected from a preset set to set the size of the second target image in a batch. Then, in the next batch, a value can be randomly selected from the preset set to set the size of the second target image again.
[0091] See Figure 4 , Figure 4 This is a flowchart illustrating another embodiment of the detection method of this application. The detection method includes:
[0092] S210: Input the image to be identified into the detection model.
[0093] S220: Using a detection model, based on the first target image, determine whether the image to be identified contains the target object contained in the first target image.
[0094] The first target image is obtained by performing a first transformation process on a reference image containing the target object. The purpose of the detection method in this application is to detect whether the target object included in the reference image exists in the image to be identified. The process of performing the first transformation process on the reference image is described above and will not be repeated here.
[0095] The detection model is trained using any of the above training methods. For detailed training methods, please refer to the above content.
[0096] In one application scenario, in order to ensure the accuracy of detection, when the user inputs the image to be identified into the detection model, the target object is required to account for 10% to 30% of the image to be identified.
[0097] In one application scenario, the image to be identified and a reference image can be input into the detection model at the same time. The detection model then performs a first transformation on the reference image to obtain the first target image.
[0098] In another application scenario, a reference image is input into the detection model before the image to be identified. In this case, the detection model processes the reference image in advance to obtain a first target image, and then saves the first target image in the detection model. After receiving the image to be identified, the subsequent detection model determines whether there is a target object in the image to be identified.
[0099] In this embodiment, in order to improve the detection accuracy and avoid missed detections, multiple reference images are input to the detection model, and the pose of the target object is different in at least two of the multiple reference images. At this time, after receiving multiple reference images, the detection model performs a first transformation process on each reference image to obtain multiple first target images. It can be understood that the pose of the target object is different in at least two of the multiple first target images. Therefore, no matter how the pose of the target object in the image to be identified changes, the detection model can detect the target object in the image to be identified, thereby improving the accuracy of identification.
[0100] See Figure 5 , Figure 5This is a schematic diagram of one embodiment of the electronic device of this application. The electronic device 200 includes a processor 210, a memory 220, and a communication circuit 230. The processor 210 is coupled to the memory 220 and the communication circuit 230 respectively. The memory 220 stores program data. The processor 210 executes the program data in the memory 220 to implement the steps in any of the above embodiments. The detailed steps can be found in the above embodiments and will not be repeated here.
[0101] The electronic device 200 can be any device with algorithm processing capabilities, such as a computer or mobile phone, and there are no restrictions on it.
[0102] See Figure 6 , Figure 6 This is a schematic diagram of another embodiment of the electronic device of this application. The electronic device 300 includes an acquisition module 310, a first processing module 320, a second processing module 330, and a training module 340.
[0103] The acquisition module 310 is used to acquire the target object region from the original image;
[0104] The first processing module 320 is connected to the acquisition module 310 and is used to perform a first transformation process on the size of the target object region based on a first preset size range to obtain a first target image, wherein the size of the first target image belongs to the first preset size range.
[0105] The second processing module 330 is connected to the acquisition module 310 and is used to perform a second transformation processing on the original image to change the target object region in the original image, thereby obtaining a second target image.
[0106] The training module 340 is connected to both the first processing module 320 and the second processing module 330, and is used to train the detection model using the first target image and the second target image; wherein, after receiving the first target image and the second target image, the detection model detects whether the target object contained in the first target image exists in the second target image.
[0107] See Figure 7 , Figure 7 This is a schematic diagram of another embodiment of the electronic device of this application. The electronic device 400 includes an input module 410 and a detection module 420.
[0108] The input module 410 is used to input the image to be recognized into the detection model.
[0109] The detection module 420 is connected to the input module 410 and is used to determine, based on the first target image, whether there is a target object contained in the first target image in the image to be identified using the detection model; wherein, the detection model is trained by the above-described training method; the first target image is obtained by performing the first transformation process on a reference image containing the target object.
[0110] When the electronic device 400 is in operation, it performs the steps of the detection method in any of the above embodiments. For detailed steps, please refer to the above embodiments, which will not be repeated here.
[0111] Among them, electronic device 400 can be any device with algorithm processing capabilities, such as a computer or mobile phone, without any restrictions.
[0112] See Figure 8 , Figure 8 This is a schematic diagram of one embodiment of the computer-readable storage medium of this application. The computer-readable storage medium 500 stores a computer program 510, which can be executed by a processor to implement the steps in any of the above methods.
[0113] Specifically, the computer-readable storage medium 500 can be a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, or a device that can store the computer program 510. Alternatively, it can be a server that stores the computer program 510, which can send the stored computer program 510 to other devices for execution or run the stored computer program 510 itself.
[0114] The above description is merely an embodiment of this application and does not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A training method, characterized in that, The method includes: Obtain the target object region from the original image; Based on a first preset size range, the size of the target object region is subjected to a first transformation process to obtain a first target image, wherein the size of the first target image belongs to the first preset size range; The original image is subjected to a second transformation process to change the target object region in the original image, thereby obtaining a second target image; The detection model is trained using the first target image and the second target image; Wherein, after receiving the first target image and the second target image, the detection model detects whether the second target image contains the target object contained in the first target image; Prior to training the detection model using the first target image and the second target image, the method further includes: The outer perimeter of the second target image is filled, and subsequent steps are performed based on the second target image after the filling process. The step of training the detection model using the first target image and the second target image includes: Multiple training batches are obtained, each training batch includes multiple first target images and second target images, and the second target images included in the same training batch have the same size, while the second target images included in different training batches have different sizes. The detection model is trained using multiple training batches; The detection model includes a first feature extraction module, a second feature extraction module, and a region proposal module. The first feature extraction module is used to extract features from the received first target image to obtain a first feature map; The second feature extraction module is used to extract features from the received second target image to obtain a second feature map; The region proposal module includes a downsampling unit and a cross-correlation unit. The downsampling unit is used to downsample the first feature map to obtain a third feature map. The cross-correlation unit is used to cross-correlate the second feature map and the third feature map.
2. The method according to claim 1, characterized in that, The step of performing a first transformation on the size of the target object region based on a first preset size range to obtain a first target image includes: The first transformation process is applied to the size of the target object region to make the resulting first target image a square, and the side length of the square belongs to the first preset size range.
3. The method according to claim 1, characterized in that, The first transformation process includes at least one of scaling the target object region and filling the periphery of the target object region.
4. The method according to claim 3, characterized in that, The step of performing a first transformation on the size of the target object region based on a first preset size range to obtain a first target image includes: The target object region is scaled proportionally until the long side of the scaled target object region falls within the first preset size range; The first target image is obtained by filling the area around the scaled target object region.
5. The method according to claim 1, characterized in that, The step of performing a second transformation on the original image to change the target object region in the original image, thereby obtaining a second target image, includes: The original image is subjected to the second transformation process to change at least one of the size and position of the target object region in the original image.
6. The method according to claim 5, characterized in that, The step of performing the second transformation process on the original image to change at least one of the size and position of the target object region in the original image includes: The original image is subjected to the second transformation process to randomly change the width and height of the target object region in the original image, so that the scaling ratio of the width and height of the target object region falls within a second preset range.
7. The method according to claim 5, characterized in that, The step of performing the second transformation process on the original image to change at least one of the size and position of the target object region in the original image includes: The original image is subjected to the second transformation process to randomly change the position of the target object region in the original image, and to make the offset of the target object region within a preset offset range.
8. A detection method, characterized in that, The method includes: Input the image to be identified into the detection model; Using the detection model, based on the first target image, it is determined whether the image to be identified contains a target object contained in the first target image; The detection model is trained using the training method described in any one of claims 1-7; the first target image is obtained by performing the first transformation process on a reference image containing the target object.
9. The method according to claim 8, characterized in that, Before determining whether a target object contained in the first target image exists in the image to be identified based on the first target image using the detection model, the method further includes: The reference image containing the target object is input into the detection model; The first transformation process is applied to the reference image using the detection model to obtain the first target image.
10. The method according to claim 9, characterized in that, The input of the detection model consists of multiple reference images, and the pose of the target object is different in at least two of the multiple reference images.
11. An electronic device, characterized in that, The electronic device includes a processor, a memory, and a communication circuit. The processor is coupled to the memory and the communication circuit. The memory stores program data. The processor executes the program data in the memory to implement the steps of the method as described in any one of claims 1-10.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that can be executed by a processor to implement the steps of the method as described in any one of claims 1-10.
Citation Information
Patent Citations
Image recognition method and related device
CN113536876A