Image model training method, device and electronic device

By randomly selecting positions in the target area or non-target area of ​​the target image to generate positive sample pairs, the problem of dissimilarity of positive sample pairs in image model training is solved, and the detection accuracy and effect of downstream tasks are improved.

CN115115911BActive Publication Date: 2025-03-21VIVO MOBILE COMM HANGZHOU CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210828528.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-13
Publication Date
2025-03-21
Estimated Expiration
2042-07-13

AI Technical Summary

Technical Problem

In the prior art In image model training, when generating positive sample pairs by random cropping, the generated two images may be different, thereby reducing detection accuracy.

Method used

The positive sample pair is generated by randomly selecting positions in the target area or non-target area of ​​the target image so that both images in the generated positive sample pair are from the target area or both from the non-target area, thereby improving similarity.

Benefits of technology

The detection accuracy of image models trained based on positive and negative sample pairs is improved, and the effect of downstream tasks is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115115911B_ABST
    Figure CN115115911B_ABST
Patent Text Reader

Abstract

The present application discloses an image model training method, which belongs to the field of image processing technology. The image model training method comprises: for a target image in a training data set, generating a positive sample pair corresponding to the target image based on a first position in the target image; the first position includes a position in a target area or a position in a non-target area; generating a negative sample pair corresponding to the target image; training an initial image model based on each positive sample pair and negative sample pair corresponding to the target image to obtain a target image model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of artificial intelligence processing technology, and specifically relates to an image model training method, device and electronic equipment. Background Art

[0002] Self-supervised pre-training technology has made great progress in the field of computer vision. Since no labeled data is required, a large amount of unlabeled data can be used to train the model, which has fewer restrictions than supervised training. In some tasks such as image classification, object detection, and instance segmentation, self-supervised pre-training has achieved the same results as supervised training or even exceeded supervised training. Contrastive learning is a self-supervised pre-training method. Typical contrastive learning methods include SimCLR, MoCo, BYOL, or SimSiam. The main idea of ​​contrastive learning is to bring similar samples (positive samples) closer in space and push dissimilar samples (negative samples) farther in space. By optimizing this task, high-quality image representations can be obtained, and then the image representations can be used to improve the effects of downstream tasks.

[0003] In the related art, when constructing a positive sample pair, two images obtained after performing data enhancement twice on an image are usually used to form a positive sample pair; wherein data enhancement includes random cropping, random change of brightness, random change of contrast, random change of saturation, random change of hue, random conversion to grayscale, random Gaussian blur, random exposure, or random horizontal flipping, etc.

[0004] However, in the above-mentioned related technologies, when randomly cropping an image, the two randomly cropped images will be dissimilar, thereby reducing the detection accuracy of the image model trained based on the positive sample. Summary of the invention

[0005] The purpose of the embodiments of the present application is to provide an image model training method, device and electronic device, which can solve the problem of reducing the detection accuracy of the image model obtained by training based on positive samples.

[0006] In a first aspect, an embodiment of the present application provides an image model training method, comprising:

[0007] For a target image in a training data set, a positive sample pair corresponding to the target image is generated based on a first position in the target image; the first position includes a position in a target area or a position in a non-target area;

[0008] Generate a negative sample pair corresponding to the target image;

[0009] An initial image model is trained based on the positive sample pairs and the negative sample pairs corresponding to each of the target images to obtain a target image model.

[0010] In a second aspect, an embodiment of the present application provides an image model training device, comprising:

[0011] A first generating module is used to generate a positive sample pair corresponding to a target image in a training data set based on a first position in the target image; the first position includes a position in a target area or a position in a non-target area;

[0012] A second generation module, used to generate a negative sample pair corresponding to the target image;

[0013] The training module is used to train the initial image model based on the positive sample pairs and the negative sample pairs corresponding to each of the target images to obtain the target image model.

[0014] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the method described in the first aspect are implemented.

[0015] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.

[0016] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.

[0017] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the first aspect.

[0018] In an embodiment of the present application, for a target image in a training data set, a positive sample pair corresponding to the target image is generated based on whether the first position is in the target area or the non-target area of ​​the target image, so that the two images in the generated positive sample pair are both from the target area or both from the non-target area, thereby improving the similarity between the two images in the positive sample pair, and thereby improving the detection accuracy of the target image model obtained by training based on the positive sample pair and the negative sample pair. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 This is one of the flowcharts of the image model training method provided in the embodiment of the present application;

[0020] Figure 2 It is one of the schematic diagrams of the image provided in the embodiment of the present application;

[0021] Figure 3 This is the second schematic diagram of the image provided in the embodiment of the present application;

[0022] Figure 4 This is the third schematic diagram of the image provided in the embodiment of the present application;

[0023] Figure 5 This is the fourth schematic diagram of the image provided in the embodiment of the present application;

[0024] Figure 6 This is the fifth schematic diagram of the image provided in the embodiment of the present application;

[0025] Figure 7 This is the second flow chart of the image model training method provided in the embodiment of the present application;

[0026] Figure 8 This is the sixth schematic diagram of the image provided in the embodiment of the present application;

[0027] Fig. 9 This is the seventh schematic diagram of the image provided in the embodiment of the present application;

[0028] Fig.10 This is the third flow chart of the image model training method provided in the embodiment of the present application;

[0029] Fig.11 This is the eighth schematic diagram of the image provided in the embodiment of the present application;

[0030] Fig.12 is a structural diagram of an image model training device provided in an embodiment of the present application;

[0031] Fig.13 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;

[0032] Fig.14 A schematic diagram of the hardware structure of an electronic device implementing an embodiment of the present application. DETAILED DESCRIPTION

[0033] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.

[0034] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0035] The image model training method, image model training device, electronic device and readable storage medium provided in the embodiments of the present application are described in detail below in combination with the accompanying drawings through specific embodiments and their application scenarios.

[0036] Figure 1 is one of the flow charts of the image model training method provided in the embodiment of the present application, such as Figure 1 As shown, the image model training method includes the following steps 101, 102 and 103:

[0037] Step 101: for a target image in a training data set, generate a positive sample pair corresponding to the target image based on a first position in the target image; the first position includes a position in a target area or a position in a non-target area.

[0038] Among them, the training data set includes multiple images, and the multiple images can be obtained through at least one short video, or through at least one other video, or from a large number of pictures; the target area is the area representing the substantial part of the target image, that is, the object area, and the non-target area is the background area representing the target image.

[0039] In one embodiment, the target image is any image in the training data set. For each target image, a point is randomly selected in the target image, which is the first position, and it is determined whether the first position is in the target area of ​​the target image or in the non-target area of ​​the target image; if it is determined that the first position is in the target area of ​​the target image, a positive sample pair corresponding to the target image is generated based on the target area; if it is determined that the first position is in the non-target area of ​​the target image, a positive sample pair corresponding to the target image is generated based on the non-target area.

[0040] It should be noted that before executing step 101, it is necessary to perform target detection on each image in the training data set, so that each image contains each object, and the position of each object is recorded, that is, the area of ​​each object is recorded, that is, each target area is recorded; target detection can use the Faster R-CNN algorithm, etc. Figure 2 It is one of the schematic diagrams of the image provided in the embodiment of the present application, A represents the first position, and the dotted box represents the target area.

[0041] Step 102: Generate a negative sample pair corresponding to the target image.

[0042] In one embodiment, before training the initial image model, in addition to generating positive sample pairs corresponding to each target image, negative sample pairs corresponding to each target image also need to be generated. The specific method for generating negative sample pairs can be: selecting an image different from the target image in the training data set, and then performing data enhancement on the image and the target image respectively to obtain negative sample pairs corresponding to the target image.

[0043] Step 103: Train an initial image model based on the positive sample pairs and negative sample pairs corresponding to each of the target images to obtain a target image model.

[0044] In one embodiment, after the positive sample pairs and negative sample pairs corresponding to each target image are generated, the initial image model may be trained based on the positive sample pairs and negative sample pairs corresponding to each target image.

[0045] The initial image model includes a first initial image submodule and a second initial image submodule; the specific training process of training the initial image model based on the positive sample pairs and negative sample pairs corresponding to each target image is as follows:

[0046] For each target image, input one image in the positive sample pair corresponding to the target image into the first initial image sub-model to obtain a first feature vector output by the first initial image sub-model;

[0047] Inputting another image in the positive sample pair corresponding to the target image into the second initial image sub-model to obtain a second feature vector output by the second initial sub-model;

[0048] Inputting one image of the negative sample pair corresponding to the target image into the first initial image sub-model to obtain a third eigenvector output by the first initial image sub-model;

[0049] Inputting another image in the negative sample pair corresponding to the target image into the second initial image sub-model to obtain a fourth eigenvector output by the second initial image sub-model;

[0050] Based on the first eigenvector, the second eigenvector, the third eigenvector and the fourth eigenvector corresponding to each target image, the first initial image sub-model and the second initial image sub-model are optimized to obtain a target image model.

[0051] The first initial image sub-model and the second initial image sub-model are optimized based on the first eigenvector, the second eigenvector, the third eigenvector and the fourth eigenvector corresponding to each target image to obtain the target image model, which can be specifically achieved in the following manner:

[0052] For each target image, a loss function is determined based on the first eigenvector, the second eigenvector, the third eigenvector and the fourth eigenvector, and a total loss function is determined based on the loss function corresponding to each target image; based on the total loss function, the first initial image sub-model and the second initial image sub-model are optimized to obtain a target image model.

[0053] In one embodiment, a public parameter model such as vit-base is used as the backbone network. The first initial image sub-model includes an encoder query encoder and two MLP structures. The second initial image sub-module includes an encoder momentum encoder and one MLP structure. The two samples in the positive sample pair corresponding to the target image are q1 and k respectively. + Indicates that the two samples in the negative sample pair corresponding to the target object are q2 and k respectively. i Indicates; input q1 into the encoder query encoder, and the output of the encoder query encoder passes through 2 mlp structures to obtain the first feature vector corresponding to q1; k + The input encoder momentum encoder, the output of the encoder momentum encoder is then passed through an MLP structure to obtain k + The corresponding second eigenvector; q i The query encoder is input into the encoder, and the output of the encoder query encoder passes through two MLP structures to obtain q i The corresponding third eigenvector; k i The input encoder momentum encoder, the output of the encoder momentum encoder is then passed through an MLP structure to obtain k i The corresponding fourth eigenvector; finally, based on the first eigenvector corresponding to q1, k + The corresponding second eigenvector, the corresponding third eigenvector of q2 and k i The corresponding fourth eigenvector calculates the loss function. The loss function is shown in the following formula (1):

[0054]

[0055] Among them, L q represents the loss function, K represents the total number of training rounds, · represents the inner product, q1·k+ represents q1 and k + The similarity of q2·k i represents q2 and k i similarity, τ represents the temperature coefficient.

[0056] Based on the loss function corresponding to each target image, the corresponding loss is determined, and the total loss of the batch can be expressed as the average value of the loss corresponding to each target image.

[0057] Furthermore, the model parameters of the first initial image sub-model are updated based on the total loss function to obtain first target model parameters of the first initial image sub-model; the current model parameters of the second initial image sub-model are updated based on the first target model parameters to obtain second target model parameters of the second initial image sub-model; and the target image model is determined based on the first target model parameters and the second target model parameters.

[0058] In one embodiment, after obtaining the total loss of the batch, the parameters of the encoder are updated through back propagation, wherein the parameters of the encoder query encoder are directly updated, and the parameters of the encoder momentum encoder are momentum updated by weighting the updated parameters of the query encoder (the first target model parameters) and the current model parameters of the encoder momentum encoder; each batch training in a round is based on the encoder updated by the previous batch, and each round of training is based on the encoder finally updated by the previous round, until the number of training rounds reaches a preset total number of training rounds, and finally the target image model is obtained.

[0059] The image model training method provided in the embodiment of the present application generates, for the target image in the training data set, a positive sample pair corresponding to the target image based on whether the first position is in the target area or the non-target area of ​​the target image, so that the two images in the generated positive sample pair are both from the target area or both from the non-target area, thereby improving the similarity between the two images in the positive sample pair, thereby improving the detection accuracy of the target image model obtained by training based on the positive sample pair and the negative sample pair, and further improving the effects of downstream classification, retrieval, deduplication and other services.

[0060] Optionally, a positive sample pair corresponding to the target image is generated based on the first position in the target image, which can be specifically implemented in the following two ways:

[0061] In a first manner, when it is determined that the first position includes the position of a target area in the target image, a positive sample pair corresponding to the target image is generated based on the target area;

[0062] In one embodiment, generating a positive sample pair corresponding to the target image based on the target area may be achieved in the following manner:

[0063] The image of the target area is cropped twice to obtain a cropped first target image and a second target image; data enhancement is performed on the first target image to obtain a first target enhanced image; data enhancement is performed on the second target image to obtain a second target enhanced image; and the first target enhanced image and the second target enhanced image are determined as a positive sample pair corresponding to the target image.

[0064] Furthermore, a first cropping position and a second cropping position of the target area are determined based on the β distribution; the values ​​of the two parameters of the β distribution are the same, and the values ​​of the two parameters are both less than 1; the image of the target area is cropped based on the first cropping position to obtain the cropped first target image; the image of the target area is cropped based on the second cropping position to obtain the cropped second target image.

[0065] For example, when it is determined that the first position includes the position of the target area in the target image, the target area is first randomly cropped twice to obtain a cropped first target image and a cropped second target image, and then the cropped first target image and the cropped second target image are respectively data enhanced, wherein the data enhancement includes at least one of the following: stretching, compression, random change of brightness, random change of contrast, random change of saturation, random change of hue, random conversion to grayscale, random Gaussian blur, exposure and horizontal flipping, and finally a first target enhanced image and a second target enhanced image are obtained, and the first target enhanced image and the second target enhanced image are used as a positive sample pair corresponding to the target image. Figure 3 This is the second schematic diagram of the image provided in the embodiment of the present application, such as Figure 3 As shown, the positive sample pairs generated based on the target area are as follows Figure 3 The two arrows in the image are indicated.

[0066] In addition, when selecting the first cropping position and the second cropping position of the target area, β distribution random sampling is used. The two parameters of the β distribution have the same value and are less than 1. At this time, the β distribution is U-shaped. The probability of random sampling at the center of the target area is low, and the probability of sampling at the edge of the target area is high. The distance between the cropped first target image and the cropped second target image can be as far as possible. Under the premise of ensuring the rationality of the positive sample pair, the difficulty of the positive sample pair is made as high as possible.

[0067] In a second manner, when it is determined that the first position includes the position of a non-target area in the target image, a positive sample pair corresponding to the target image is generated based on the non-target area.

[0068] In one embodiment, generating a positive sample pair corresponding to the target image based on the non-target area may be specifically implemented in the following manner:

[0069] The image of the non-target area is cropped to obtain a cropped third target image; a fourth target image is determined based on the third target image; data enhancement is performed on the third target image to obtain a third target enhanced image; data enhancement is performed on the fourth target image to obtain a fourth target enhanced image; and the third target enhanced image and the fourth target enhanced image are determined as a positive sample pair corresponding to the target image.

[0070] Furthermore, the target vertex of the fourth target image is determined based on the second position in the third target image; other vertices of the fourth target image except the target vertex are determined in the non-target area based on the direction away from the center position of the third target image; and the image of the non-target area is cropped based on the target vertex and the other vertices to obtain the fourth target image.

[0071] Further, a second position in the third target image is determined based on the β distribution; the values ​​of two parameters of the β distribution are the same, and the values ​​of the two parameters are both less than 1; and the second position is determined as the target vertex of the fourth target image.

[0072] For example, when it is determined that the first position includes the position of the non-target area in the target image, the third target image is firstly cropped out in the non-target area (the specific cropping method may be random cropping), and then a point is randomly selected in the third target image as a vertex (target vertex) of the fourth target image. After the target vertex of the fourth target image is selected, other vertices of the fourth target image to be cropped are determined in the non-object area based on the direction away from the center position of the third target image. When the target vertex of the fourth target image is selected in the third target image, the β distribution random sampling is also used. The two parameters of the β distribution have the same value and are less than 1. At this time, the β distribution is U-shaped. The probability of random sampling sampling the center position of the non-object area is low, and the probability of sampling the edge of the non-object area is high, so that the third target image and the fourth target image finally obtained can overlap each other but be as far apart as possible. Data enhancement is performed on the cropped third target image and the fourth target image respectively, wherein the data enhancement includes at least one of the following: stretching, compression, random change of brightness, random change of contrast, random change of saturation, random change of hue, random conversion to grayscale, random Gaussian blur, exposure and horizontal flipping, and finally a third target enhanced image and a fourth target enhanced image are obtained, and the third target enhanced image and the fourth target enhanced image are used as positive sample pairs corresponding to the target images. Figure 4 This is the third schematic diagram of the image provided in the embodiment of the present application, such as Figure 4 As shown, the positive sample pairs generated based on the non-target area are as follows Figure 4 The two arrows in the image are indicated.

[0073] The image model training method provided in the embodiment of the present application uses β-distributed random sampling to generate positive sample pairs based on the target area, so that the probability of random sampling sampling the center of the target area is low, and the probability of sampling the edge of the target area is high, which can make the cropped first target image and the cropped second target image as far apart as possible, and make the difficulty of the positive sample pair as high as possible while ensuring the rationality of the positive sample pair; for generating positive sample pairs based on the non-target area, β-distributed random sampling is also used, and the two parameters of the β distribution have the same value and are less than 1. At this time, the β distribution is U-shaped, and the probability of random sampling sampling the center of the non-object area is low, and the probability of sampling the edge of the non-object area is high, which can make the third target image and the fourth target image finally obtained overlap with each other but as far apart as possible.

[0074] Optionally, the above step 102 of generating the negative sample pair corresponding to the target image may be implemented in the following manner:

[0075] Determining similar images to the target image in the training data set;

[0076] Deleting images similar to the similar image or the target image in the original negative sample queue to obtain a target negative sample queue;

[0077] The target image and any image in the target negative sample queue are determined as a negative sample pair corresponding to the target image.

[0078] For example, the existing public parameters of the image model are used to obtain the deep image representation of all images in the training data set; for each image in the training data set, the cosine similarity between the image and all other images in the training data set is calculated using the deep image representation, and the image corresponding to the cosine similarity greater than a preset value is taken as a similar image of the image. Figure 5 is a fourth schematic diagram of an image provided in an embodiment of the present application, and the search results of similar images are as follows Figure 5 Then, images similar to the similar image or the target image are searched and deleted in the pre-constructed original negative sample queue to obtain the target negative sample queue, and then any image is selected from the target negative sample queue to form a negative sample pair corresponding to the target image with the target image. Figure 6 This is a fifth schematic diagram of an image provided in an embodiment of the present application, such as Figure 6 As shown, the target image is represented by 601, the original negative sample queue is represented by 602, and the target negative sample queue is represented by 603.

[0079] It should be noted that, based on the pre-constructed original negative sample queue, the batch size setting can also be increased to allow more image samples to enter the original negative sample queue, and this application does not limit this.

[0080] The image model training method provided in the embodiment of the present application deletes images similar to similar images or target images in a pre-constructed original negative sample queue, and constructs negative sample pairs based on the images in the target negative sample queue and the target image, so that the similarity between the two images in the negative sample pair is smaller, thereby improving the rationality of the construction of the negative sample pair, and further improving the detection accuracy of the target image model.

[0081] Optionally, each image in the training data set is an image obtained by cropping a pure color edge or an edge containing only character information from a corresponding original image.

[0082] Optionally, Figure 7 This is the second flow chart of the image model training method provided in the embodiment of the present application, such as Figure 7 As shown, before step 101, the image model training method further includes the following steps:

[0083] Step 104: determine the image to be cropped in the initial data set; the image to be cropped is an image containing a pure color edge and / or an image whose edge contains characters.

[0084] For example, the initial data set includes multiple images, and the multiple images can be obtained through at least one short video, or through at least one other video, or from a large number of pictures; images containing pure color edges and / or images with characters on their edges are detected in the initial data set, and then all detected images containing pure color edges and / or images containing characters on their edges are determined as images to be cropped; wherein the color of the pure color edges can be any color, and the characters include information such as text, letters, and numbers.

[0085] Step 105 , traverse each pixel point within a preset value in the image to be cropped based on a target direction; the target direction includes a first direction or a second direction different from the first direction.

[0086] Step 106: Determine the standard deviation and mean of all pixels within the current preset value.

[0087] Step 107: When it is determined that the difference between the standard deviation of all pixels within the current preset value and the standard deviation of all pixels within the previous preset value is greater than a first threshold, and the mean is less than a second threshold, the position of the previous preset value is determined as the cropping position of the image to be cropped in the target direction.

[0088] Step 108: Crop the image to be cropped based on the cropping position in the target direction to obtain a cropped image.

[0089] For example, assuming that the pixels of the image to be cropped are H*W, the specific cropping method is: 1) converting the image to be cropped into a grayscale image; 2) determining the cropping position of the image to be cropped in a first direction, assuming that the H direction is the up and down direction, and the W direction is the left and right direction, then the first direction can be the up and down direction, assuming that the coordinates of the image to be cropped from bottom to top are from 0 to H, then traverse each preset value h from 0 to H / 2, and for each h, calculate the standard deviation and mean of the grayscale values ​​of all pixels under this h value, if the difference between the standard deviation s(h1) of all pixels within the current preset value h1 and the standard deviation s(h2) of all pixels within the previous preset value h2 is greater than the first threshold, and the mean u(h1) of all pixels within the current preset value h1 is less than the second threshold, then h2 is the lower cropping position of the image to be cropped, and the upper cropping position of the image to be cropped can be obtained by similar processing; Figure 8 This is the sixth schematic diagram of the image provided in the embodiment of the present application, and the specific cropping positions in the upper and lower directions are as follows Figure 8 The two dotted lines shown; 3) determining the cropping position of the image to be cropped in the second direction, wherein the second direction can be the left-right direction, assuming that the coordinates of the image to be cropped from left to right are from 0 to W, then traverse each preset value w from 0 to W / 2, and for each w, calculate the standard deviation and mean of the grayscale values ​​of all pixels under this w value, if the difference between the standard deviation s(w1) of all pixels within the current preset value w1 and the standard deviation s(w2) of all pixels within the previous preset value w2 is greater than the first threshold, and the mean u(w1) of all pixels within the current preset value w1 is less than the second threshold, then w2 is the left cropping position of the image to be cropped, and the right cropping position of the image to be cropped can be obtained by similar processing; 4) cropping the image to be cropped according to the cropping position determined above to obtain a cropped image; Fig. 9 This is the seventh schematic diagram of the image provided in the embodiment of the present application, and the specific cropping positions in the left and right directions are as follows Fig. 9 The two dashed lines are shown.

[0090] Step 109: Determine the training data set based on the cropped image and images in the initial data set except the image to be cropped.

[0091] For example, when determining the cropped image, the cropped image and images in the initial data set except the image to be cropped are combined into a training data set.

[0092] The image model training method provided in the embodiment of the present application crops images containing pure color edges and / or images whose edges contain characters in the initial data set, and determines a training data set based on the cropped images and images other than the images to be cropped in the initial data set. This enables subsequent image model training to focus on the parts of the image with substantial content, completes the data preprocessing process of the initial data set, and further improves the detection accuracy of the target image model.

[0093] Optionally, Fig.10 This is the third flow chart of the image model training method provided in the embodiment of the present application, such as Fig.10 As shown, before step 104, the image model training method further includes the following steps:

[0094] Step 110: Filter the pure color images and / or images containing only characters in the initial data set.

[0095] For example, 1) using the public parameters of the existing image model, the deep image representation of all images in the initial data set is obtained; 2) a number of pure color images are selected from the initial data set, and the cosine similarity between each selected pure color image and other images in the initial data set is calculated using the deep image representation, and a first similarity threshold is set, and images whose cosine similarity is greater than the first similarity threshold are determined as pure color images. The selection of the first similarity threshold ensures that the recall of pure color images reaches 99% and the accuracy reaches 98%; 3) a number of images containing only a number of characters are selected from the initial data set, and the cosine similarity between each selected image containing only a number of characters and other images in the initial data set is calculated using the deep image representation, and a second similarity threshold is set, and images whose cosine similarity is greater than the second similarity threshold are determined as images containing only characters. The selection of the second similarity threshold ensures that the recall of images of solid colors with a number of characters reaches 99% and the accuracy reaches 97%. Fig.11 This is the eighth schematic diagram of the image provided in the embodiment of the present application, such as Fig.11 As shown, the selected image containing only a number of characters (seed image) is the leftmost image, and the images containing only characters similar to the image containing only a number of characters found in the initial data set are the two images on the right.

[0096] In addition, when the initial data set is filtered, determining the first image containing a pure color edge and / or the second image containing a character edge in the initial data set may be specifically implemented in the following manner:

[0097] The image to be cropped in the filtered initial data set is determined.

[0098] The image model training method provided in the embodiment of the present application deletes pure color images and / or images containing only characters in the initial data set, so that the initial data set after deletion only includes images containing specific content, thereby realizing the data cleaning process of the initial data set and further improving the detection accuracy of the target image model.

[0099] Optionally, determining similar images of the target image in the training data set may be specifically implemented in the following manner:

[0100] When the total number of training rounds reaches the target percentage, similar images of the target image are determined in the training data set based on the image model corresponding to the current model parameters.

[0101] The target percentage may be a preset percentage, for example, the preset percentage is at least one of 25%, 50% and 75%.

[0102] For example, when 25%, 50% and 75% of the total training rounds are completed, the image model corresponding to the current model parameters is used to determine similar images of the target image in the training data set, so as to update the search results of similar images in the training data set, and the updated similar images are used in subsequent rounds of training. In this way, the knowledge learned by the model on the training data can be utilized, so that the target negative sample queue obtained after eliminating images similar to the updated similar images in the original negative sample pairs based on the updated similar images is more reasonable and more conducive to subsequent model training.

[0103] The image model training method provided in the embodiment of the present application determines similar images of the target image in the training data set based on the image model corresponding to the current model parameters when the total number of training rounds reaches the target percentage, so that the determined similar images are more accurate and reasonable.

[0104] Fig.12 is a schematic diagram of the structure of the image model training device provided in the embodiment of the present application, such as Fig.12 As shown, the image model training device includes a first generation module 1201, a second generation module 1202 and a training module 1203; wherein:

[0105] A first generating module 1201 is used to generate a positive sample pair corresponding to a target image in a training data set based on a first position in the target image; the first position includes a position in a target area or a position in a non-target area;

[0106] A second generating module 1202 is used to generate a negative sample pair corresponding to the target image;

[0107] The training module 1203 is used to train the initial image model based on the positive sample pairs and the negative sample pairs corresponding to each of the target images to obtain the target image model.

[0108] The image model training device provided in the embodiment of the present application generates a positive sample pair corresponding to the target image in the training data set based on whether the first position is in the target area or the non-target area of ​​the target image, so that the two images in the generated positive sample pair are both from the target area or both from the non-target area, thereby improving the similarity between the two images in the positive sample pair, and further improving the detection accuracy of the target image model obtained by training based on the positive sample pair and the negative sample pair.

[0109] Optionally, the first generating module 1201 is further used for:

[0110] In a case where it is determined that the first position includes the position of the target area in the target image, cropping the image of the target area twice to obtain a cropped first target image and a second target image;

[0111] Performing data enhancement on the first target image to obtain a first target enhanced image;

[0112] Performing data enhancement on the second target image to obtain a second target enhanced image;

[0113] Determining the first target enhanced image and the second target enhanced image as a positive sample pair corresponding to the target image;

[0114] In a case where it is determined that the first position includes the position of a non-target area in the target image, cropping the image of the non-target area to obtain a cropped third target image;

[0115] determining a fourth target image based on the third target image;

[0116] Performing data enhancement on the third target image to obtain a third target enhanced image;

[0117] Performing data enhancement on the fourth target image to obtain a fourth target enhanced image;

[0118] The third target enhanced image and the fourth target enhanced image are determined as a positive sample pair corresponding to the target image.

[0119] Optionally, the first generating module 1201 is further used for:

[0120] Determining a first cropping position and a second cropping position of the target area based on a β distribution; the values ​​of two parameters of the β distribution are the same, and the values ​​of the two parameters are both less than 1;

[0121] Cropping the image of the target area based on the first cropping position to obtain the cropped first target image;

[0122] The image of the target area is cropped based on the second cropping position to obtain the cropped second target image.

[0123] Optionally, the first generating module 1201 is further used for:

[0124] determining a target vertex of the fourth target image based on a second position in the third target image;

[0125] Determine, in the non-target area, other vertices of the fourth target image except the target vertex based on a direction away from the center position of the third target image;

[0126] The image of the non-target area is cropped based on the target vertex and the other vertices to obtain the fourth target image.

[0127] Optionally, the first generating module 1201 is further used for:

[0128] Determining a second position in the third target image based on a β distribution; wherein two parameters of the β distribution have the same value and both of the two parameters are less than 1;

[0129] The second position is determined as a target vertex of the fourth target image.

[0130] Optionally, the second generating module 1202 is further used for:

[0131] Determining similar images to the target image in the training data set;

[0132] Deleting images similar to the similar image or the target image in the original negative sample queue to obtain a target negative sample queue;

[0133] The target image and any image in the target negative sample queue are determined as a negative sample pair corresponding to the target image.

[0134] Optionally, each image in the training data set is an image obtained by cropping a pure color edge or an edge containing only character information from a corresponding original image.

[0135] Optionally, the device further comprises:

[0136] A first determination module is used to determine an image to be cropped in an initial data set; the image to be cropped is an image containing a pure color edge and / or an image whose edge contains characters;

[0137] A traversal module, configured to traverse each pixel point within a preset value in the image to be cropped based on a target direction; the target direction includes a first direction or a second direction different from the first direction;

[0138] A second determination module is used to determine the standard deviation and mean of all pixels within the current preset value;

[0139] a third determining module, configured to determine the position of the previous preset value as the cropping position of the image to be cropped in the target direction when it is determined that the difference between the standard deviation of all pixels within the current preset value and the standard deviation of all pixels within the previous preset value is greater than a first threshold, and the mean is less than a second threshold;

[0140] A cropping module, used for cropping the image to be cropped based on the cropping position of the target direction to obtain a cropped image;

[0141] The fourth determination module is used to determine the training data set based on the cropped image and the images in the initial data set except the image to be cropped.

[0142] Optionally, the device further comprises:

[0143] A filtering module, used for filtering the pure color images and / or images containing only characters in the initial data set;

[0144] The first determining module is further used for:

[0145] The image to be cropped in the filtered initial data set is determined.

[0146] Optionally, the second generating module 1202 is further used for:

[0147] When the total number of training rounds reaches the target percentage, similar images of the target image are determined in the training data set based on the image model corresponding to the current model parameters.

[0148] The image model training method provided in the embodiment of the present application can be executed by the image model training Device In the embodiment of the present application, an image model training device executing an image model training method is taken as an example to illustrate the image model training device provided in the embodiment of the present application.

[0149] The image model training device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or it can be other devices other than the terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a car electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.

[0150] The image model training device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.

[0151] The image model training device provided in the embodiment of the present application can achieve Figures 1 to 11 To avoid repetition, the various processes implemented by the method embodiment are not described here.

[0152] Alternatively, if Fig.13 As shown, an embodiment of the present application also provides an electronic device 1300, including a processor 1301 and a memory 1302, and the memory 1302 stores a program or instruction that can be executed on the processor 1301. When the program or instruction is executed by the processor 1301, the various steps of the above-mentioned image model training method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0153] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.

[0154] Fig.14 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.

[0155] The electronic device 1400 includes but is not limited to: a radio frequency unit 1401, a network module 1402, an audio output unit 1403, an input unit 1404, a sensor 1405, a display unit 1406, a user input unit 1407, an interface unit 1408, a memory 1409, and a processor 1410 and other components.

[0156] Those skilled in the art will appreciate that the electronic device 1400 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 1410 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Fig.14 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.

[0157] The processor 1410 is configured to generate, for a target image in a training data set, a positive sample pair corresponding to the target image based on a first position in the target image; the first position includes a position in a target area or a position in a non-target area;

[0158] The processor 1410 is further configured to generate a negative sample pair corresponding to the target image;

[0159] The processor 1410 is further configured to train an initial image model based on the positive sample pairs and the negative sample pairs corresponding to each of the target images to obtain a target image model.

[0160] In the above implementation, for the target image in the training data set, a positive sample pair corresponding to the target image is generated based on whether the first position is in the target area or the non-target area of ​​the target image, so that the two images in the generated positive sample pair are both from the target area or both from the non-target area, thereby improving the similarity between the two images in the positive sample pair, and further improving the detection accuracy of the target image model trained based on the positive sample pair and the negative sample pair.

[0161] Optionally, the processor 1410 is further configured to, when determining that the first position includes the position of the target area in the target image, crop the image of the target area twice to obtain a cropped first target image and a second target image;

[0162] Performing data enhancement on the first target image to obtain a first target enhanced image;

[0163] Performing data enhancement on the second target image to obtain a second target enhanced image;

[0164] Determining the first target enhanced image and the second target enhanced image as a positive sample pair corresponding to the target image;

[0165] In a case where it is determined that the first position includes the position of a non-target area in the target image, cropping the image of the non-target area to obtain a cropped third target image;

[0166] determining a fourth target image based on the third target image;

[0167] Performing data enhancement on the third target image to obtain a third target enhanced image;

[0168] Performing data enhancement on the fourth target image to obtain a fourth target enhanced image;

[0169] The third target enhanced image and the fourth target enhanced image are determined as a positive sample pair corresponding to the target image.

[0170] Optionally, the processor 1410 is further configured to determine a first cropping position and a second cropping position of the target area based on a β distribution; the values ​​of two parameters of the β distribution are the same, and the values ​​of the two parameters are both less than 1;

[0171] Cropping the image of the target area based on the first cropping position to obtain the cropped first target image;

[0172] The image of the target area is cropped based on the second cropping position to obtain the cropped second target image.

[0173] Optionally, the processor 1410 is further configured to determine a target vertex of the fourth target image based on the second position in the third target image;

[0174] Determine, in the non-target area, other vertices of the fourth target image except the target vertex based on a direction away from the center position of the third target image;

[0175] The image of the non-target area is cropped based on the target vertex and the other vertices to obtain the fourth target image.

[0176] Optionally, the processor 1410 is further configured to determine a second position in the third target image based on a β distribution; two parameters of the β distribution have the same value, and both values ​​of the two parameters are less than 1;

[0177] The second position is determined as a target vertex of the fourth target image.

[0178] In the above implementation, for generating positive sample pairs based on the target area, β-distributed random sampling is used, so that the probability of random sampling sampling the center of the target area is low, and the probability of sampling the edge of the target area is high, which can make the cropped first target image and the cropped second target image as far apart as possible, and make the difficulty of the positive sample pairs as high as possible while ensuring the rationality of the positive sample pairs; for generating positive sample pairs based on the non-target area, β-distributed random sampling is also used, and the two parameters of the β distribution have the same value and are less than 1. At this time, the β distribution is U-shaped, and the probability of random sampling sampling the center of the non-object area is low, and the probability of sampling the edge of the non-object area is high, which can make the third target image and the fourth target image finally obtained overlap with each other but as far apart as possible.

[0179] Optionally, the processor 1410 is further configured to determine similar images of the target image in the training data set;

[0180] Deleting images similar to the similar image or the target image in the original negative sample queue to obtain a target negative sample queue;

[0181] The target image and any image in the target negative sample queue are determined as a negative sample pair corresponding to the target image.

[0182] In the above implementation, images similar to similar images or target images in the pre-constructed original negative sample queue are deleted, and negative sample pairs are formed based on the images in the target negative sample queue and the target image, so that the similarity between the two images in the negative sample pair is smaller, thereby improving the rationality of the construction of the negative sample pair, and further improving the detection accuracy of the target image model.

[0183] Optionally, the processor 1410 is further configured to:

[0184] Determine an image to be cropped in an initial data set; the image to be cropped is an image containing a pure color edge and / or an image whose edge contains characters;

[0185] Traversing each pixel point within a preset value in the image to be cropped based on a target direction; the target direction includes a first direction or a second direction different from the first direction;

[0186] Determine the standard deviation and mean of all pixels within the current preset value;

[0187] When it is determined that the difference between the standard deviation of all pixels within the current preset value and the standard deviation of all pixels within the previous preset value is greater than a first threshold, and the mean is less than a second threshold, determining the position of the previous preset value as the cropping position of the image to be cropped in the target direction;

[0188] Cropping the image to be cropped based on the cropping position of the target direction to obtain a cropped image;

[0189] The training data set is determined based on the cropped image and images in the initial data set except the image to be cropped.

[0190] In the above implementation, images containing solid color edges and / or images whose edges contain characters in the initial data set are cropped, and a training data set is determined based on the cropped images and images in the initial data set excluding the images to be cropped. This enables subsequent image model training to focus on the parts of the image with substantial content, thereby completing the data preprocessing process of the initial data set and further improving the detection accuracy of the target image model.

[0191] Optionally, the processor 1410 is further configured to filter the pure color images and / or images containing only characters in the initial data set;

[0192] The image to be cropped in the filtered initial data set is determined.

[0193] In the above implementation, the solid color images and / or images containing only characters in the initial data set are deleted, so that the deleted initial data set only includes images containing specific content, thereby realizing the data cleaning process of the initial data set and further improving the detection accuracy of the target image model.

[0194] Optionally, the processor 1410 is further configured to determine similar images of the target image in the training data set based on the image model corresponding to the current model parameters when the total number of training rounds reaches a target percentage.

[0195] In the above implementation, when the total number of training rounds reaches the target percentage, similar images of the target image are determined in the training data set based on the image model corresponding to the current model parameters, so that the determined similar images are more accurate and reasonable.

[0196] It should be understood that in the embodiment of the present application, the input unit 1404 may include a graphics processor (Graphics Processing Unit, GPU) 14041 and a microphone 14042, and the graphics processor 14041 processes the image data of the static picture or video obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode. The display unit 1406 may include a display panel 14061, and the display panel 14061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 1407 includes a touch panel 14071 and at least one of other input devices 14072. The touch panel 14071 is also called a touch screen. The touch panel 14071 may include two parts: a touch detection device and a touch controller. Other input devices 14072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.

[0197] The memory 1409 can be used to store software programs and various data. The memory 1409 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 1409 may include a volatile memory or a non-volatile memory, or the memory 1409 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 1409 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.

[0198] The processor 1410 may include one or more processing units; optionally, the processor 1410 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 1410.

[0199] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned image model training method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0200] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.

[0201] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned image model training method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0202] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0203] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned image model training method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0204] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0205] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0206] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. An image model training method, characterized in that: include: For a target image in a training data set, generating a positive sample pair corresponding to the target image based on a first position in the target image; The first position includes a position in a target area or a position in a non-target area; the target area is an object area in the target image, and the non-target area is a background area in the target image; Generate a negative sample pair corresponding to the target image; Train an initial image model based on the positive sample pairs and the negative sample pairs corresponding to each of the target images to obtain a target image model; The generating a positive sample pair corresponding to the target image based on the first position in the target image includes: In a case where it is determined that the first position includes the position of the target area in the target image, cropping the image of the target area twice to obtain a cropped first target image and a second target image; Performing data enhancement on the first target image to obtain a first target enhanced image; Performing data enhancement on the second target image to obtain a second target enhanced image; Determining the first target enhanced image and the second target enhanced image as a positive sample pair corresponding to the target image; The step of cropping the image of the target area twice to obtain a cropped first target image and a cropped second target image comprises: Determining a first cropping position and a second cropping position of the target area based on a β distribution; the values ​​of two parameters of the β distribution are the same, and the values ​​of the two parameters are both less than 1; Cropping the image of the target area based on the first cropping position to obtain the cropped first target image; The image of the target area is cropped based on the second cropping position to obtain the cropped second target image.

2. The image model training method according to claim 1, characterized in that: The generating a positive sample pair corresponding to the target image based on the first position in the target image further includes: In a case where it is determined that the first position includes the position of a non-target area in the target image, cropping the image of the non-target area to obtain a cropped third target image; determining a fourth target image based on the third target image; Performing data enhancement on the third target image to obtain a third target enhanced image; Performing data enhancement on the fourth target image to obtain a fourth target enhanced image; The third target enhanced image and the fourth target enhanced image are determined as a positive sample pair corresponding to the target image.

3. The image model training method according to claim 2, characterized in that: The determining of the fourth target image based on the third target image comprises: determining a target vertex of the fourth target image based on a second position in the third target image; Determine, in the non-target area, other vertices of the fourth target image except the target vertex based on a direction away from the center position of the third target image; The image of the non-target area is cropped based on the target vertex and the other vertices to obtain the fourth target image.

4. The image model training method according to claim 3, characterized in that: The determining the target vertex of the fourth target image based on the second position in the third target image comprises: Determining a second position in the third target image based on a β distribution; wherein two parameters of the β distribution have the same value and both of the two parameters are less than 1; The second position is determined as a target vertex of the fourth target image.

5. The image model training method according to claim 1 or 2, characterized in that: The generating a negative sample pair corresponding to the target image comprises: Determining similar images to the target image in the training data set; Deleting images similar to the similar image or the target image in the original negative sample queue to obtain a target negative sample queue; The target image and any image in the target negative sample queue are determined as a negative sample pair corresponding to the target image.

6. The image model training method according to claim 5, characterized in that: Before generating a positive sample pair corresponding to the target image in the training data set based on the first position in the target image, the method further includes: Determine an image to be cropped in an initial data set; the image to be cropped is an image containing a pure color edge and / or an image whose edge contains characters; Traversing each pixel point within a preset value in the image to be cropped based on a target direction; the target direction includes a first direction or a second direction different from the first direction; Determine the standard deviation and mean of all pixels within the current preset value; When it is determined that the difference between the standard deviation of all pixels within the current preset value and the standard deviation of all pixels within the previous preset value is greater than a first threshold, and the mean is less than a second threshold, determining the position of the previous preset value as the cropping position of the image to be cropped in the target direction; Cropping the image to be cropped based on the cropping position of the target direction to obtain a cropped image; The training data set is determined based on the cropped image and images in the initial data set except the image to be cropped.

7. An image model training device, characterized in that: include: A first generating module is used to generate a positive sample pair corresponding to a target image in a training data set based on a first position in the target image; the first position includes a position in a target area or a position in a non-target area; the target area is an object area in the target image, and the non-target area is a background area in the target image; A second generation module, used to generate a negative sample pair corresponding to the target image; A training module, used for training an initial image model based on the positive sample pairs and the negative sample pairs corresponding to each of the target images to obtain a target image model; The first generating module is also used for: In a case where it is determined that the first position includes the position of the target area in the target image, cropping the image of the target area twice to obtain a cropped first target image and a second target image; Performing data enhancement on the first target image to obtain a first target enhanced image; Performing data enhancement on the second target image to obtain a second target enhanced image; Determining the first target enhanced image and the second target enhanced image as a positive sample pair corresponding to the target image; The first generating module is also used for: Determining a first cropping position and a second cropping position of the target area based on a β distribution; the values ​​of two parameters of the β distribution are the same, and the values ​​of the two parameters are both less than 1; Cropping the image of the target area based on the first cropping position to obtain the cropped first target image; The image of the target area is cropped based on the second cropping position to obtain the cropped second target image.

8. The image model training device according to claim 7, characterized in that: The first generating module is also used for: In a case where it is determined that the first position includes the position of a non-target area in the target image, cropping the image of the non-target area to obtain a cropped third target image; determining a fourth target image based on the third target image; Performing data enhancement on the third target image to obtain a third target enhanced image; Performing data enhancement on the fourth target image to obtain a fourth target enhanced image; The third target enhanced image and the fourth target enhanced image are determined as a positive sample pair corresponding to the target image.

9. The image model training device according to claim 8, characterized in that: The first generating module is also used for: determining a target vertex of the fourth target image based on a second position in the third target image; Determine, in the non-target area, other vertices of the fourth target image except the target vertex based on a direction away from the center position of the third target image; The image of the non-target area is cropped based on the target vertex and the other vertices to obtain the fourth target image.

10. The image model training device according to claim 9, characterized in that: The first generating module is also used for: Determining a second position in the third target image based on a β distribution; wherein two parameters of the β distribution have the same value and both of the two parameters are less than 1; The second position is determined as a target vertex of the fourth target image.

11. The image model training device according to claim 7 or 8, characterized in that: The second generating module is further used for: Determining similar images to the target image in the training data set; Deleting images similar to the similar image or the target image in the original negative sample queue to obtain a target negative sample queue; The target image and any image in the target negative sample queue are determined as a negative sample pair corresponding to the target image.

12. The image model training device according to claim 11, characterized in that: Also includes: A first determination module, used to determine the image to be cropped in the initial data set; The image to be cropped is an image containing a solid color edge and / or an image containing characters on its edge; A traversal module, configured to traverse each pixel point within a preset value in the image to be cropped based on a target direction; the target direction includes a first direction or a second direction different from the first direction; A second determination module is used to determine the standard deviation and mean of all pixels within the current preset value; a third determining module, configured to determine the position of the previous preset value as the cropping position of the image to be cropped in the target direction when it is determined that the difference between the standard deviation of all pixels within the current preset value and the standard deviation of all pixels within the previous preset value is greater than a first threshold, and the mean is less than a second threshold; A cropping module, used for cropping the image to be cropped based on the cropping position of the target direction to obtain a cropped image; The fourth determination module is used to determine the training data set based on the cropped image and the images in the initial data set except the image to be cropped.

13. An electronic device, characterized in that: It includes a processor and a memory, the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the image model training method as described in any one of claims 1 to 6 are implemented.

14. A readable storage medium, characterized in that: The readable storage medium stores programs or instructions, and when the programs or instructions are executed by the processor, the steps of the image model training method as described in any one of claims 1-6 are implemented.

Citation Information

Patent Citations

  • Image classification method and device, electronic equipment and storage medium

    CN112434178A

  • Image interpretation model training method and device, equipment and storage medium

    CN114332853A

  • Weak supervision semantic segmentation method based on attention mechanism image block metric learning

    CN114359559A