WO2023159819A1 - 视觉处理及模型训练方法、设备、存储介质及程序产品 - Google Patents

视觉处理及模型训练方法、设备、存储介质及程序产品 Download PDF

Info

Publication number
WO2023159819A1
WO2023159819A1 PCT/CN2022/100368 CN2022100368W WO2023159819A1 WO 2023159819 A1 WO2023159819 A1 WO 2023159819A1 CN 2022100368 W CN2022100368 W CN 2022100368W WO 2023159819 A1 WO2023159819 A1 WO 2023159819A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
sample
model
loss
training
Prior art date
Application number
PCT/CN2022/100368
Other languages
English (en)
French (fr)
Inventor
郭若愚
杜宇宁
李晨霞
刘其文
赖宝华
马艳军
于佃海
Original Assignee
北京百度网讯科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京百度网讯科技有限公司 filed Critical 北京百度网讯科技有限公司
Priority to JP2023512344A priority Critical patent/JP2024510361A/ja
Priority to US18/170,902 priority patent/US20230206668A1/en
Publication of WO2023159819A1 publication Critical patent/WO2023159819A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/241Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Definitions

  • the present disclosure relates to fields such as computer vision and deep learning in computer technology, and in particular to a vision processing and model training method, device, storage medium and program product.
  • OCR Optical Character Recognition, Optical Character Recognition
  • OCR is a technology that can convert image information into text information that is easier to edit and store. At present, it is widely used in various scenarios, such as bill recognition, bank card information recognition, formula recognition, etc.
  • OCR also helps many downstream tasks, such as subtitle translation, security monitoring, etc.; it can also be applied to other computer vision tasks, such as Video search and more.
  • the second is to synthesize a large amount of labeled data, mix the labeled synthetic data and real data as training data, train the visual model, and obtain the final visual model.
  • overfitting often occurs due to the simplicity of the synthetic data, resulting in low accuracy of the trained model.
  • a visual processing and model training method device, storage medium and program product.
  • a method for visual model training including:
  • the image classification network is carried out self-supervised training to obtain a trained image classification network
  • weight of the backbone network of the trained image classification network initialize the weight of the backbone network of the visual model to obtain the pre-training model
  • the pre-trained model is trained by using the labeled second data set to obtain a trained visual model.
  • a visual processing method including:
  • an apparatus for training a visual model including:
  • a network establishment module configured to establish an image classification network, the image classification network having the same backbone network as the visual model
  • the first training module is used to use the unlabeled first data set to perform self-supervised training on the image classification network to obtain a trained image classification network;
  • the pre-training model determination module is used to initialize the weight of the backbone network of the visual model according to the weight of the backbone network of the trained image classification network to obtain the pre-training model;
  • the second training module is configured to use the labeled second data set to train the pre-trained model to obtain a trained visual model.
  • a visual processing device including:
  • An image acquisition module configured to acquire images to be processed
  • a visual processing module configured to input the image to be processed into a visual model, perform computer vision processing on the image to be processed through the visual model, and obtain a processing result, wherein the visual model is composed of the device described in the third aspect above generate;
  • the result output module is used to output the processing result.
  • an electronic device comprising:
  • the memory stores instructions executable by the at least one processor, the instructions are executed by the at least one processor, so that the at least one processor can execute the method described in the first aspect or the second aspect .
  • a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute the method described in the first aspect or the second aspect.
  • a computer program product comprising: a computer program stored in a readable storage medium, at least one processor of an electronic device can read from the The computer program is read by reading the storage medium, and the at least one processor executes the computer program so that the electronic device executes the method described in the first aspect or the second aspect.
  • Techniques according to this disclosure improve the accuracy of the visual model.
  • FIG. 1 is a flowchart of a method for visual model training according to a first embodiment of the present disclosure
  • FIG. 2 is a flowchart of a method for visual model training according to a second embodiment of the present disclosure
  • FIG. 3 is a flowchart of a visual processing method according to a third embodiment of the present disclosure.
  • FIG. 4 is a schematic structural diagram of a device for visual model training according to a fourth embodiment of the present disclosure.
  • FIG. 5 is a schematic structural diagram of a device for visual model training according to a fifth embodiment of the present disclosure.
  • FIG. 6 is a schematic structural diagram of a visual processing device according to a sixth embodiment of the present disclosure.
  • FIG. 7 is a block diagram of an electronic device used to implement the method for training a visual model according to an embodiment of the present disclosure.
  • OCR Optical Character Recognition, Optical Character Recognition
  • OCR is a technology that can convert image information into text information that is easier to edit and store. At present, it is widely used in various scenarios, such as bill recognition, bank card information recognition, formula recognition, etc.
  • OCR also helps many downstream tasks, such as subtitle translation, security monitoring, etc.; it can also be applied to other computer vision tasks, such as Video search and more.
  • model training is performed based on a large amount of synthetic data and a small amount of real data with label information.
  • the second is to synthesize a large amount of labeled data, mix the labeled synthetic data and real data as training data, train the visual model, and obtain the final visual model.
  • the present disclosure provides a visual model training method, device, storage medium, and program product, which are applied to computer vision, deep learning, etc. in computer technology, so as to improve the accuracy of the visual model.
  • the visual model training method constructs an image classification network based on the visual model, so that the image classification network and the visual model have the same backbone network; uses the unlabeled first data set to perform self-supervised training on the image classification network to optimize the image
  • the backbone network of the classification network uses the unlabeled first data set to perform self-supervised training on the image classification network to optimize the image
  • the backbone network of the classification network uses the unlabeled first data set to perform self-supervised training on the image classification network to optimize the image
  • the backbone network of the classification network according to the weight of the backbone network of the trained image classification network, the weight of the backbone network of the visual model is initialized to obtain the pre-training model.
  • the backbone network of the pre-training model is consistent with the backbone network of the visual model.
  • the unlabeled data set in the computer vision task scene is easy to obtain, and the pre-training model is trained based on the real unlabeled data set, which makes the pre-training model more suitable for the training of the visual model in the current computer vision task, and improves the effectiveness of the pre-training model. and then use the labeled second data set to train the pre-training model to obtain a trained visual model, which can improve the accuracy of the visual model.
  • the trained vision model can be applied to various computer vision task scenarios for corresponding computer vision processing.
  • the visual model may be an OCR text recognition model, which is used to perform text recognition processing on the input image to obtain the text information contained in the input image.
  • FIG. 1 is a flowchart of a method for training a visual model according to a first embodiment of the present disclosure.
  • the method for training a visual model provided in this embodiment may be specifically applied to an electronic device, where the electronic device is used to implement training of a visual model.
  • Step S101 establishing an image classification network, which has the same backbone network as the visual model.
  • the image classification network includes a backbone network and a decoding module.
  • the backbone network refers to the encoding module in the network and is also a module for feature extraction.
  • the image classification network is constructed based on the visual model, so that the image classification network and the visual model have the same backbone network, that is, the image classification network and the visual model have the same encoding module for feature extraction, but the decoding module is different.
  • Step S102 using the unlabeled first data set to perform self-supervised training on the image classification network to obtain a trained image classification network.
  • the first data set is an unlabeled data set, which contains real image data under the current computer vision task scene. Additionally, the first data set may also include synthetic data.
  • self-supervised training is performed on the image classification network based on the unlabeled first data set of the current computer vision task scene, so as to optimize the weight of the backbone network of the image classification network, so that the backbone network is more suitable for the current computer vision task , for better feature extraction when applied to computer vision tasks, without using labeled datasets.
  • Step S103 according to the weight of the backbone network of the trained image classification network, initialize the weight of the backbone network of the visual model to obtain a pre-trained model.
  • the weight of the backbone network of the trained image classification network is used as the initial weight of the backbone network of the visual model, and the visual model is initialized to obtain pre-training Model, the pre-training model is consistent with the structure of the vision model, and the weight of the backbone network is optimized using the real data set in the current computer vision task scenario.
  • Step S104 using the labeled second data set to train the pre-trained model to obtain a trained visual model.
  • the second data set is a marked data set, including real image data and labeling information under the current computer vision task scene.
  • the pre-training model obtained in step S103 is consistent with the structure of the visual model, and the weight of the backbone network is optimized using the real data set under the current computer vision task scenario, based on the pre-training model, using the current computer vision task scenario Model training is performed on the labeled second data set to obtain the final visual model, which can effectively improve the accuracy of the visual model. Even with a small amount of labeled data, a visual model with high accuracy can be trained.
  • the image classification network with the same backbone network as the visual model is established, and the image classification network is self-supervised training using the first data set without labels to obtain a trained image classification network; according to the trained image classification network
  • the weight of the backbone network initialize the weight of the backbone network of the vision model, obtain the pre-training model, the structure of the pre-training model is consistent with the vision model, and use the real data set in the current computer vision task scene to optimize the weight of the backbone network , which is more suitable for current computer vision tasks; and then use the labeled second data set to train the pre-trained model to obtain a trained visual model, which can effectively improve the accuracy of the visual model.
  • Fig. 2 is a flowchart of a method for training a visual model according to a second embodiment of the present disclosure.
  • self-supervised training is performed on the image classification network using the unlabeled first data set to obtain a trained image classification network, including: obtaining the unlabeled first data set, the first data set includes multiple sets of sample images, and the direction information of each sample image, wherein each set of sample images includes a first sample image, and a second sample image obtained by rotating the first sample image by a preset angle; Extract the image features of each sample image in the first data set through the image classification network, and determine the direction prediction result of each sample image according to the image features; according to the image features of two sample images whose direction information differs by 180 degrees in the same group of sample images , calculate the first loss; and calculate the second loss according to the real direction and direction prediction result of each sample image; adjust the weight of the backbone network of the image classification network according to the first loss and the second loss, which can be realized by using
  • Step S201 establishing an image classification network, which has the same backbone network as the visual model.
  • the image classification network includes a backbone network and a decoding module.
  • the backbone network refers to the encoding module in the network and is also a module for feature extraction.
  • the image classification network is constructed based on the visual model, so that the image classification network and the visual model have the same backbone network, that is, the image classification network and the visual model have the same encoding module for feature extraction, but the decoding module is different.
  • the text recognition model can adopt CRNN (Convolutional Recurrent Neural Network, Convolutional Recurrent Neural Network), RARE (Robust text recognizer with Automatic Rectification, with the robustness of automatic correction function text recognizer), NRTR, etc.
  • the backbone network of the image classification network is used to realize the processing of feature extraction in CRNN, RARE, and NRTR.
  • the full name of CRNN is mainly used to recognize text sequences of variable length end-to-end. Instead of cutting a single text first, it converts text recognition into a time-series-dependent sequence learning problem, which is image-based sequence recognition.
  • CRNN mainly includes a convolutional layer, a cyclic layer, and a transcription layer, and finally realizes the prediction of a sequence of variable length using a fixed-length input.
  • the image classification network decoding module is used to decode the features extracted by the backbone network to obtain classification results.
  • Step S202 Obtain a first dataset without labels.
  • the first dataset includes multiple sets of sample images and the orientation information of each sample image, wherein each set of sample images includes the first sample image, the rotation of the first sample image
  • the second sample image obtained from a preset angle.
  • the first data set is an unlabeled data set, which contains real image data under the current computer vision task scene. Additionally, the first data set may also include synthetic data.
  • a large amount of real image data of the current computer vision task scene is obtained to generate the first data set, and there is no need to label the first data set.
  • this step can be implemented in the following manner:
  • the preset angle includes one or more different angles, which can be set according to actual application scenarios, and are not specifically limited here.
  • the preset angle may only include 180 degrees.
  • the preset angle may include 180 degrees and at least one angle other than 180 degrees.
  • the preset angle may include 90 degrees and 180 degrees.
  • the preset angle may include a first angle and a second angle, and a difference between the first angle and the second angle is 180 degrees.
  • the preset angles may include 90 degrees and 270 degrees.
  • the preset angle may include a first angle, a second angle and at least one third angle, wherein the difference between the first angle and the second angle is 180 degrees.
  • the preset angles may include 90 degrees (first angle), 270 degrees (second angle), and 180 degrees (third angle).
  • the direction information of the first sample image is set as 0 degrees
  • the direction information of the second sample image obtained by rotating the preset angle is set as the corresponding rotation angle
  • the orientation information of the three second sample images obtained is 90 degrees, 180 degrees, and 270 degrees in sequence, while the first The orientation information of this image is 0 degrees.
  • Each first sample image and the second sample image obtained by rotating the first sample image are a set of sample images, and the first loss is determined based on two sample images whose direction information differs by 180 degrees in the same set of sample images , to determine the second loss based on the direction prediction result and real direction information of the same sample image, which can enrich the loss function used for self-supervised training to improve the training effect of the pre-trained model.
  • sample images with other direction information can also be included, which can further enrich the sample data and improve the pre-training model. training effect.
  • the acquisition of the first sample image without labels can be specifically implemented in the following manner:
  • the original image is obtained, and the original image includes at least one of the following: a synthetic image and a real image; preprocessing the original image to obtain a sample image meeting the model training requirements; performing random data augmentation on the sample image to obtain the first sample image.
  • each original image is a real image or a synthetic image under the current computer vision task scene.
  • the process of model training there are requirements for the size of the sample image input to the model and whether it contains specific content such as faces and texts.
  • the processed sample image meets the training requirements of the model, thereby ensuring that the sample image can be used for training the image classification model to improve the training effect of the image classification model.
  • the original image is preprocessed to obtain a sample image that meets the model training requirements, including:
  • the text detection model can be used to perform text detection on the original image, extract the image of the region where the text information is located, and obtain the text detection result.
  • the text detection result may be a polygon.
  • the border of the sample image is required to be a rectangular frame.
  • the number of sample images can be greatly increased, making the first data set more abundant.
  • step S202 can also be performed after step S201, and step S202 can also be performed before step S201, and the execution order of S202 and S201 is not specifically limited here.
  • the number of categories of the image classification model is set to be related to the number of preset angles, and the number of categories of the image classification model is equal to the number of preset angles plus 1.
  • the image classification model is used to classify the direction information of the sample image and predict the direction information corresponding to the sample image.
  • the number of categories of the image classification model is set to 4, and the direction information used by the image classification model to predict the input sample image is 0 degrees, 90 degrees, and 180 degrees. degrees, 270 degrees which one.
  • steps S203-S207 are executed cyclically, and the image classification model is subjected to self-supervised iterative training based on the unlabeled first data set, until the iteration stop condition is met, and the iteration is stopped.
  • Step S203 extracting the image features of each sample image in the first data set through the image classification network, and determining the direction prediction result of each sample image according to the image features.
  • the sample images in the first data set are input into the image classification network, the image features of the sample images are extracted through the backbone network of the image classification network, and the direction of the sample images is predicted through the decoding module of the image classification network according to the image features of the sample images information to obtain the direction prediction result of the sample image.
  • normalization processing is performed on the sample images.
  • the loss function when performing the self-supervised training of the image classification network, two kinds of loss functions are used, and one loss function is used to calculate the first difference between the image features of two sample images whose direction information differs by 180 degrees in the same group of sample images.
  • the first loss, the other loss function is used to calculate the real direction of each sample image and the second loss of the direction prediction result, which can enrich the loss function used for supervised training and improve the effect of model training.
  • Step S204 calculating the first loss according to the image features of two sample images whose orientation information differs by 180 degrees in the same group of sample images.
  • the preset angle includes at least 180 degrees. This step can specifically be implemented in the following manner:
  • the first loss calculated in this way can accurately reflect the difference between the image features of two sample images whose direction information differs by 180 degrees in the same group of sample images, and self-supervised training of the image classification model based on the first loss , so that the backbone network of the image classification model can learn the rotation angle of the image, so that the feature extraction module can better extract image features, which can further improve the robustness of the image classification model, thereby improving the accuracy of the final visual model.
  • the preset angle includes at least a first angle and a second angle, the second angle is equal to the first angle plus 180 degrees, and the first angle is not 0 degrees.
  • the first angle is 90 degrees
  • the second angle is 270 degrees.
  • This step can specifically be implemented in the following manner:
  • the first loss is calculated according to the difference between the image features of the sample images whose orientation information is the first angle in the same group of sample images and the image features obtained after rotating 180 degrees, and the image features of the sample images whose orientation information is the second angle.
  • the first loss calculated in this way can also accurately reflect the difference between the image features of two sample images whose direction information differs by 180 degrees in the same set of sample images, and self-supervise the image classification model based on the first loss Training, so that the backbone network of the image classification model can learn the rotation angle of the image, so that the feature extraction module can better extract image features, which can further improve the robustness of the image classification model, thereby improving the accuracy of the final visual model .
  • the image feature of the sample image rotated 90 degrees is used as the first feature
  • the image feature of the sample image rotated 270 degrees is The feature is used as the second feature
  • the first loss is calculated based on the difference between the feature obtained after 180 degrees from the first feature and the second feature.
  • the preset angle includes 180 degrees, and also includes the first angle and the second angle, in this step, the above two optional implementation manners may be combined to calculate the first loss.
  • the first loss may be an L2 loss.
  • the first loss may also be an L1 loss, and the acquisition may be a loss calculated by using other loss functions with type effects, which is not specifically limited in this embodiment.
  • Step S205 calculating the second loss according to the real direction of each sample image and the direction prediction result.
  • the second loss is calculated according to the difference between the real orientation of each sample image and the orientation prediction result.
  • calculating the second loss may use a cross-entropy loss function, or may use other loss functions commonly used in classification models for measuring the quality of classification results, which are not specifically limited in this embodiment.
  • step S204 and step S205 may be performed in parallel, or may be performed sequentially in any order.
  • Step S206 adjusting the weight of the backbone network of the image classification network according to the first loss and the second loss.
  • the weights of the backbone network of the image classification network are adjusted according to the first loss and the second loss, so as to optimize the weights of the backbone network.
  • the sum of the first loss and the second loss can be calculated as the final loss; according to the final loss, the weight of the backbone network of the image classification network can be adjusted, and two different loss functions can be combined to perform self-supervised training on the image classification network , to improve the robustness and effectiveness of image classification networks.
  • Step S207 whether the iteration end condition is satisfied.
  • step S208 is continued.
  • step S203 If the iteration end condition is not satisfied, continue to execute step S203 to start the next iteration.
  • the iteration stop condition may include at least one of the following: the number of iterations reaches a preset number threshold, the final loss is less than the loss threshold, and the change of the weight value between two iterations is very small.
  • Step S208 according to the weight of the backbone network of the trained image classification network, initialize the weight of the backbone network of the visual model to obtain the pre-trained model.
  • the weight of the backbone network of the trained image classification network is used as the initial weight of the backbone network of the visual model, and the visual model is initialized to obtain pre-training Model, the pre-training model is consistent with the structure of the vision model, and the weight of the backbone network is optimized using the real data set in the current computer vision task scenario.
  • Step S209 using the labeled second data set to train the pre-trained model to obtain a trained visual model.
  • the second data set is an annotated data set, which includes real image data and annotation information in the current computer vision task scene.
  • the structure of the pre-training model is consistent with the vision model, and the weight of the backbone network in the pre-training model is optimized by using the real data set in the current computer vision task scenario.
  • the pre-training model is trained again to obtain the final visual model, which can effectively improve the accuracy of the visual model. Even with a small amount of labeled data, a visual model with high accuracy can be trained.
  • a trained image classification network is obtained, making full use of the unlabeled data pair
  • the backbone network used to extract features is trained; further, when performing self-supervised training of the image classification network, two loss functions are used to calculate the difference between the image features of two sample images whose direction information differs by 180 degrees in the same group of sample images.
  • the first loss calculates the real direction of each sample image and the second loss of the direction prediction result, optimizes the weight of the backbone network based on the first loss and the second loss, and considers the loss of classification results and the loss of image feature alignment, which can enrich the use of
  • the loss function for supervised training improves the robustness of the pre-trained model and the accuracy of feature extraction.
  • the weight of the backbone network of the vision model is initialized to obtain the pre-training model.
  • the structure of the pre-training model is consistent with the vision model, and the current computer vision task scenario
  • the real data set optimizes the weight of the backbone network, which is more suitable for current computer vision tasks; and then uses the labeled second data set to train the pre-training model to obtain a trained visual model, which can effectively improve vision. model accuracy.
  • Fig. 3 is a flowchart of a visual processing method according to a third embodiment of the present disclosure.
  • the visual processing method provided in this embodiment may be specifically applied to an electronic device, and the electronic device is used to realize visual processing of an image by using a trained visual model.
  • Step S301 acquiring an image to be processed.
  • Step S302 Input the image to be processed into the visual model, and perform computer vision processing on the image to be processed through the visual model to obtain a processing result.
  • the visual model is obtained by training through the method of the above-mentioned first embodiment or the second embodiment, and the specific training process will not be repeated here.
  • the vision model may be a text recognition model.
  • the text recognition process is performed on the input image through the text recognition model, and the obtained processing result is the text information contained in the input image.
  • Step S303 outputting the processing result.
  • the trained visual model is used to perform visual processing on the input image, and the visual processing result is obtained and output.
  • Fig. 4 is a schematic structural diagram of an apparatus for visual model training according to a fourth embodiment of the present disclosure.
  • the apparatus for training a visual model provided in the embodiments of the present disclosure may execute the processing procedure provided in the method embodiment for training a visual model.
  • the device 40 for training the visual model includes:
  • the network establishment module 41 is configured to establish an image classification network, and the image classification network has the same backbone network as the visual model.
  • the first training module 42 is configured to use the unlabeled first data set to perform self-supervised training on the image classification network to obtain a trained image classification network.
  • the pre-training model determining module 43 is configured to initialize the weight of the backbone network of the visual model according to the weight of the trained backbone network of the image classification network to obtain the pre-training model.
  • the second training module 44 is configured to use the labeled second data set to train the pre-trained model to obtain a trained visual model.
  • the device provided in the embodiment of the present disclosure may be specifically used to execute the method embodiment provided in the above-mentioned first embodiment, and the specific functions realized will not be repeated here.
  • the image classification network with the same backbone network as the visual model is established, and the image classification network is self-supervised training using the first data set without labels to obtain a trained image classification network; according to the trained image classification network
  • the weight of the backbone network initialize the weight of the backbone network of the vision model, obtain the pre-training model, the structure of the pre-training model is consistent with the vision model, and use the real data set in the current computer vision task scene to optimize the weight of the backbone network , which is more suitable for current computer vision tasks; and then use the labeled second data set to train the pre-trained model to obtain a trained visual model, which can effectively improve the accuracy of the visual model.
  • Fig. 5 is a schematic structural diagram of an apparatus for visual model training according to a fifth embodiment of the present disclosure.
  • the apparatus for training a visual model provided in the embodiments of the present disclosure may execute the processing procedure provided in the method embodiment for training a visual model.
  • the device 50 for training the visual model includes:
  • the network establishment module 51 is configured to establish an image classification network, and the image classification network has the same backbone network as the visual model.
  • the first training module 52 is configured to use the unlabeled first data set to perform self-supervised training on the image classification network to obtain a trained image classification network.
  • the pre-training model determination module 53 is configured to initialize the weights of the backbone network of the visual model according to the weights of the trained backbone network of the image classification network to obtain the pre-training model.
  • the second training module 54 is configured to use the labeled second data set to train the pre-trained model to obtain a trained visual model.
  • the first training module 52 includes:
  • An unlabeled dataset acquisition unit 521 configured to acquire an unlabeled first dataset, the first dataset includes multiple sets of sample images, and direction information of each sample image, wherein each set of sample images includes the first sample image , the second sample image obtained by rotating the first sample image by a preset angle.
  • the classification prediction unit 522 is configured to extract the image features of each sample image in the first data set through the image classification network, and determine the direction prediction result of each sample image according to the image features.
  • the loss calculation unit 523 is used to calculate the first loss according to the image features of two sample images whose direction information differs by 180 degrees in the same group of sample images; and calculate the second loss according to the real direction information and direction prediction results of each sample image .
  • the weight optimization unit 524 is configured to adjust the weight of the backbone network of the image classification network according to the first loss and the second loss.
  • the unlabeled data set acquisition unit includes:
  • the sample image acquisition subunit is configured to acquire a first sample image without labels, and determine the direction information of the first sample image as 0 degree.
  • the image rotation subunit is configured to rotate the first sample image by a preset angle to obtain a second sample image, and determine the direction information of the second sample image as the preset angle.
  • the preset angle includes at least 180 degrees.
  • the loss calculation unit includes:
  • the first loss calculation subunit is used to obtain features after rotating 180 degrees according to the image features of the first sample image in each group of sample images, and obtain the image features of the second sample image obtained after rotating 180 degrees with the first sample image The difference between , calculate the first loss.
  • the preset angle includes at least a first angle and a second angle, the second angle is equal to the first angle plus 180 degrees, and the first angle is not 0 degrees.
  • the loss calculation unit includes:
  • the second loss calculation subunit is based on the difference between the feature obtained after rotating 180 degrees of the image feature of the sample image whose direction information is the first angle in the same group of sample images, and the image feature of the sample image whose direction information is the second angle , computing the first loss.
  • sample image acquisition subunit is also used for:
  • the original image is obtained, and the original image includes at least one of the following: a synthetic image and a real image; preprocessing the original image to obtain a sample image meeting the model training requirements; performing random data augmentation on the sample image to obtain the first sample image.
  • sample image acquisition subunit is also used for:
  • the weight optimization unit is also used for:
  • the device provided in the embodiment of the present disclosure may be specifically used to execute the method embodiment provided in the above-mentioned second embodiment, and the specific functions realized will not be repeated here.
  • a trained image classification network is obtained, making full use of the unlabeled data pair
  • the backbone network used to extract features is trained; further, when performing self-supervised training of the image classification network, two loss functions are used to calculate the difference between the image features of two sample images whose direction information differs by 180 degrees in the same group of sample images.
  • the first loss calculates the real direction of each sample image and the second loss of the direction prediction result, optimizes the weight of the backbone network based on the first loss and the second loss, and considers the loss of classification results and the loss of image feature alignment, which can enrich the use of
  • the loss function for supervised training improves the robustness of the pre-trained model and the accuracy of feature extraction.
  • the weight of the backbone network of the vision model is initialized to obtain the pre-training model.
  • the structure of the pre-training model is consistent with the vision model, and the current computer vision task scenario
  • the real data set optimizes the weight of the backbone network, which is more suitable for current computer vision tasks; and then uses the labeled second data set to train the pre-training model to obtain a trained visual model, which can effectively improve vision. model accuracy.
  • FIG. 6 is a schematic structural diagram of a visual processing device according to a sixth embodiment of the present disclosure.
  • the vision processing device provided by the embodiment of the present disclosure can execute the processing flow provided by the embodiment of the vision processing method.
  • the visual processing device 60 includes: an image acquisition module 61 , a visual processing module 62 and a result output module 63 .
  • the image acquisition module 61 is configured to acquire images to be processed.
  • the visual processing module 62 is configured to input the image to be processed into a visual model, and perform computer vision processing on the image to be processed through the visual model to obtain a processing result, wherein the visual model is generated by the device of the fourth embodiment or the fifth embodiment.
  • the result output module 63 is used to output the processing result.
  • the device provided in the embodiment of the present disclosure may be specifically used to execute the method embodiment provided in the third embodiment above, and the specific functions realized will not be repeated here.
  • the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.
  • the present disclosure also provides a computer program product.
  • the computer program product includes: a computer program, the computer program is stored in a readable storage medium, and at least one processor of an electronic device can read from the readable storage medium. Taking a computer program, at least one processor executes the computer program so that the electronic device executes the solution provided by any one of the above embodiments.
  • FIG. 7 shows a schematic block diagram of an example electronic device 700 that may be used to implement embodiments of the present disclosure.
  • Electronic device is intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other suitable computers.
  • Electronic devices may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smart phones, wearable devices, and other similar computing devices.
  • the components shown herein, their connections and relationships, and their functions, are by way of example only, and are not intended to limit implementations of the disclosure described and/or claimed herein.
  • the device 700 includes a computing unit 701 that can execute according to a computer program stored in a read-only memory (ROM) 702 or loaded from a storage unit 708 into a random-access memory (RAM) 703. Various appropriate actions and treatments. In the RAM 703, various programs and data necessary for the operation of the device 700 can also be stored.
  • the computing unit 701, ROM 702, and RAM 703 are connected to each other through a bus 704.
  • An input/output (I/O) interface 705 is also connected to the bus 704 .
  • the I/O interface 705 includes: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a magnetic disk, an optical disk, etc. ; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, and the like.
  • the communication unit 709 allows the device 700 to exchange information/data with other devices over a computer network such as the Internet and/or various telecommunication networks.
  • the computing unit 701 may be various general-purpose and/or special-purpose processing components having processing and computing capabilities. Some examples of computing units 701 include, but are not limited to, central processing units (CPUs), graphics processing units (GPUs), various dedicated artificial intelligence (AI) computing chips, various computing units that run machine learning model algorithms, digital signal processing processor (DSP), and any suitable processor, controller, microcontroller, etc.
  • the computing unit 701 executes various methods and processes described above, such as a visual model training method or a visual processing method.
  • the method of vision model training or the method of vision processing may be implemented as a computer software program tangibly embodied in a machine-readable medium, such as storage unit 708 .
  • part or all of the computer program may be loaded and/or installed on the device 700 via the ROM 702 and/or the communication unit 709.
  • the computer program When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the above-described visual model training method or visual processing method can be executed.
  • the computing unit 701 may be configured in any other appropriate way (for example, by means of firmware) to execute the method for training a visual model.
  • Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips Implemented in a system of systems (SOC), complex programmable logic device (CPLD), computer hardware, firmware, software, and/or combinations thereof.
  • FPGAs field programmable gate arrays
  • ASICs application specific integrated circuits
  • ASSPs application specific standard products
  • SOC system of systems
  • CPLD complex programmable logic device
  • computer hardware firmware, software, and/or combinations thereof.
  • programmable processor can be special-purpose or general-purpose programmable processor, can receive data and instruction from storage system, at least one input device, and at least one output device, and transmit data and instruction to this storage system, this at least one input device, and this at least one output device an output device.
  • Program codes for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special purpose computer, or other programmable data processing devices, so that the program codes, when executed by the processor or controller, make the functions/functions specified in the flow diagrams and/or block diagrams Action is implemented.
  • the program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.
  • a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device.
  • a machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium.
  • a machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing.
  • machine-readable storage media would include one or more wire-based electrical connections, portable computer discs, hard drives, random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, compact disk read only memory (CD-ROM), optical storage, magnetic storage, or any suitable combination of the foregoing.
  • RAM random access memory
  • ROM read only memory
  • EPROM or flash memory erasable programmable read only memory
  • CD-ROM compact disk read only memory
  • magnetic storage or any suitable combination of the foregoing.
  • the systems and techniques described herein can be implemented on a computer having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user. ); and a keyboard and pointing device (eg, a mouse or a trackball) through which a user can provide input to the computer.
  • a display device e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor
  • a keyboard and pointing device eg, a mouse or a trackball
  • Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and can be in any form (including Acoustic input, speech input or, tactile input) to receive input from the user.
  • the systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., as a a user computer having a graphical user interface or web browser through which a user can interact with embodiments of the systems and techniques described herein), or including such backend components, middleware components, Or any combination of front-end components in a computing system.
  • the components of the system can be interconnected by any form or medium of digital data communication, eg, a communication network. Examples of communication networks include: Local Area Network (LAN), Wide Area Network (WAN) and the Internet.
  • a computer system may include clients and servers.
  • Clients and servers are generally remote from each other and typically interact through a communication network.
  • the relationship of client and server arises by computer programs running on the respective computers and having a client-server relationship to each other.
  • the server can be a cloud server, also known as cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the problem of traditional physical host and VPS service ("Virtual Private Server", or "VPS”) Among them, there are defects such as difficult management and weak business scalability.
  • the server can also be a server of a distributed system, or a server combined with a blockchain.
  • steps may be reordered, added or deleted using the various forms of flow shown above.
  • each step described in the present disclosure may be executed in parallel, sequentially, or in a different order, as long as the desired result of the technical solution disclosed in the present disclosure can be achieved, no limitation is imposed herein.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Artificial Intelligence (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Evolutionary Computation (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computational Linguistics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Evolutionary Biology (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Image Analysis (AREA)

Abstract

本公开提供了视觉处理及模型训练方法、设备、存储介质及程序产品,涉及计算机技术领域,尤其涉及计算机视觉、深度学习领域。具体实现方案为:通过建立与视觉模型具有相同骨干网络的图像分类网络,使用无标注的第一数据集对图像分类网络进行自监督训练;根据训练好的图像分类网络的骨干网络的权重,初始化视觉模型的骨干网络的权重,得到预训练模型,预训练模型与视觉模型的结构一致,并且使用当前计算机视觉任务场景下的真实数据集对骨干网络的权重进行了优化,更加适用于当前的计算机视觉任务;再使用有标注的第二数据集对预训练模型进行训练,得到训练好的视觉模型,能够有效提升视觉模型的精准度。

Description

视觉处理及模型训练方法、设备、存储介质及程序产品
本公开要求于2022年02月25日提交中国专利局、申请号为202210181868.0、申请名称为“视觉处理及模型训练方法、设备、存储介质及程序产品”的中国专利申请的优先权,其全部内容通过引用结合在本公开中。
技术领域
本公开涉及计算机技术中的计算机视觉、深度学习等领域,尤其涉及一种视觉处理及模型训练方法、设备、存储介质及程序产品。
背景技术
OCR(Optical Character Recognition,光学字符识别)是一项可以将图片信息转换为更易编辑和存储的文本信息的技术。目前被广泛应用于各种场景,如票据识别、银行卡信息识别、公式识别等,此外OCR也帮助了很多下游任务,比如字幕翻译、安全监控等;同时也可以应用于其他计算机视觉任务,如视频搜索等。
在目标检测、图像分割、文本识别等各种计算机视觉任务中,通常需要训练用于计算机视觉任务的视觉模型。在实际场景中,虽然有大量的真实图像数据,但是对真实图像数据的标注成本高。目前,多是利用已知标注信息的简单数据与背景图合成,基于大量的合成数据和少量具有标注信息的真实数据进行模型训练,主要有以下两种方式:一是,合成大量有标注的数据,基于有标注的合成数据训练视觉模型,再使用真实数据及标注信息训练视觉模型,得到最终的视觉模型。二是,合成大量有标注的数据,将有标注的合成数据和真实数据混合在一起作为训练数据,训练视觉模型,得到最终的视觉模型。但是基于合成数据进行模型训练时,常常由于合成数据过于简单而发生过拟合,导致训练得到的模型的精度较低。
发明内容
提供了一种视觉处理及模型训练方法、设备、存储介质及程序产品。
根据本公开的第一方面,提供了一种视觉模型训练的方法,包括:
建立图像分类网络,所述图像分类网络与所述视觉模型具有相同的骨干网络;
使用无标注的第一数据集,对所述图像分类网络进行自监督训练,得到训练好的 图像分类网络;
根据训练好的图像分类网络的骨干网络的权重,初始化所述视觉模型的骨干网络的权重,得到预训练模型;
使用有标注的第二数据集,对所述预训练模型进行训练,得到训练好的视觉模型。
根据本公开的第二方面,提供了一种视觉处理方法,包括:
获取待处理图像;
将所述待处理图像输入视觉模型,通过所述视觉模型对所述待处理图像进行计算机视觉处理,得到处理结果,其中所述视觉模型通过上述第一方面所述的方法训练得到;
输出处理结果。
根据本公开的第三方面,提供了一种视觉模型训练的装置,包括:
网络建立模块,用于建立图像分类网络,所述图像分类网络与所述视觉模型具有相同的骨干网络;
第一训练模块,用于使用无标注的第一数据集,对所述图像分类网络进行自监督训练,得到训练好的图像分类网络;
预训练模型确定模块,用于根据训练好的图像分类网络的骨干网络的权重,初始化所述视觉模型的骨干网络的权重,得到预训练模型;
第二训练模块,用于使用有标注的第二数据集,对所述预训练模型进行训练,得到训练好的视觉模型。
根据本公开的第四方面,提供了一种视觉处理装置,包括:
图像获取模块,用于获取待处理图像;
视觉处理模块,用于将所述待处理图像输入视觉模型,通过所述视觉模型对所述待处理图像进行计算机视觉处理,得到处理结果,其中所述视觉模型由上述第三方面所述的装置生成;
结果输出模块,用于输出处理结果。
根据本公开的第五方面,提供了一种电子设备,包括:
至少一个处理器;以及
与所述至少一个处理器通信连接的存储器;其中,
所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行第一方面或第二方面所述的方法。
根据本公开的第六方面,提供了一种存储有计算机指令的非瞬时计算机可读存储 介质,其中,所述计算机指令用于使所述计算机执行第一方面或第二方面所述的方法。
根据本公开的第七方面,提供了一种计算机程序产品,所述计算机程序产品包括:计算机程序,所述计算机程序存储在可读存储介质中,电子设备的至少一个处理器可以从所述可读存储介质读取所述计算机程序,所述至少一个处理器执行所述计算机程序使得电子设备执行第一方面或第二方面所述的方法。
根据本公开的技术提高了视觉模型的精准度。
应当理解,本部分所描述的内容并非旨在标识本公开的实施例的关键或重要特征,也不用于限制本公开的范围。本公开的其它特征将通过以下的说明书而变得容易理解。
附图说明
附图用于更好地理解本方案,不构成对本公开的限定。其中:
图1是根据本公开第一实施例的视觉模型训练的方法流程图;
图2是根据本公开第二实施例的视觉模型训练的方法流程图;
图3是根据本公开第三实施例的视觉处理方法流程图;
图4是根据本公开第四实施例的视觉模型训练的装置的结构示意图;
图5是根据本公开第五实施例的视觉模型训练的装置的结构示意图;
图6是根据本公开第六实施例的视觉处理装置的结构示意图;
图7是用来实现本公开实施例的视觉模型训练的方法的电子设备的框图。
具体实施方式
以下结合附图对本公开的示范性实施例做出说明,其中包括本公开实施例的各种细节以助于理解,应当将它们认为仅仅是示范性的。因此,本领域普通技术人员应当认识到,可以对这里描述的实施例做出各种改变和修改,而不会背离本公开的范围和精神。同样,为了清楚和简明,以下的描述中省略了对公知功能和结构的描述。
本公开所涉及的术语“第一”、“第二”、“第三”等仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。在以下各实施例的描述中,“多个”的含义是两个以上,除非另有明确具体的限定。
OCR(Optical Character Recognition,光学字符识别)是一项可以将图片信息转换为更易编辑和存储的文本信息的技术。目前被广泛应用于各种场景,如票据识别、银行卡信息识别、公式识别等,此外OCR也帮助了很多下游任务,比如字幕翻译、安全监控等;同时也可以应用于其他计算机视觉任务,如视频搜索等。
在目标检测、图像分割、文本识别等各种计算机视觉任务中,通常需要训练用于计算机视觉任务的视觉模型。
在实际场景中,虽然有大量的真实图像数据,但是对真实图像数据的标注成本高。为了提高模型训练效果,可以使用图像分类中的预训练模型,来加速模型的收敛过程,提升模型精度。但是在一些计算机视觉任务,如基于OCR的文本识别任务中,由于文本识别任务场景的图像数据与图像分类的预训练模型使用的数据集差异很大,文本识别模型与预训练模型的结构差异较大,直接加载基于图像分类的预训练模型用于训练文本识别模型,无法带来文本识别模型的精度收益。无标注的文本识别数据十分常见、容易获取,但是无标注的数据无法直接用于训练文本识别模型。
目前,对于视觉模型的训练,多是利用已知标注信息的简单数据与背景图合成,基于大量的合成数据和少量具有标注信息的真实数据进行模型训练。主要有以下两种方式:一是,合成大量有标注的数据,基于有标注的合成数据训练视觉模型,再使用真实数据及标注信息训练视觉模型,得到最终的视觉模型。二是,合成大量有标注的数据,将有标注的合成数据和真实数据混合在一起作为训练数据,训练视觉模型,得到最终的视觉模型。
但是,基于合成数据进行模型训练时,常常由于合成数据过于简单而发生过拟合,导致训练得到的模型的精度较低。
本公开提供一种视觉模型训练的方法、设备、存储介质及程序产品,应用于计算机技术中的计算机视觉、深度学习等,以提高视觉模型的精准度。
本公开提供的视觉模型训练的方法,基于视觉模型构建图像分类网络,使得图像分类网络与视觉模型具有相同的骨干网络;使用无标注的第一数据集对图像分类网络进行自监督训练,优化图像分类网络的骨干网络;根据训练好的图像分类网络的骨干网络的权重,初始化视觉模型的骨干网络的权重,得到预训练模型,该预训练模型的骨干网络与视觉模型的骨干网络一致,由于当前的计算机视觉任务场景下的无标注数据集容易获取,基于真实的无标注数据集训练预训练模型,使得预训练模型更适用于当前的计算机视觉任务中视觉模型的训练,提高预训练模型的有效性;再使用有标注的第二数据集对预训练模型进行训练,得到训练好的视觉模型,能够提高视觉模型的精准度。
另外,即使用较少量的有标注的数据,也可以训练得到精准度较高的视觉模型。
训练得到的视觉模型可以应用于各种计算机视觉任务场景,进行对应的计算机视觉处理。例如,视觉模型可以是OCR文本识别模型,用于对输入图像进行文本识别处 理,得到输入图像所包含的文本信息。
下面以具体地实施例对本申请的技术方案以及本申请的技术方案如何解决上述技术问题进行详细说明。下面这几个具体的实施例可以相互结合,对于相同或相似的概念或过程可能在某些实施例中不再赘述。下面将结合附图,对本申请的实施例进行描述。
图1是根据本公开第一实施例的视觉模型训练的方法流程图。本实施例提供的视觉模型训练的方法具体可以应用于电子设备,该电子设备用于实现对视觉模型的训练。
如图1所示,该方法具体步骤如下:
步骤S101、建立图像分类网络,图像分类网络与视觉模型具有相同的骨干网络。
其中,图像分类网络包括骨干网络和解码模块,骨干网络是指网络中的编码模块,也是用于进行特征提取的模块。
本实施例中,基于视觉模型构建图像分类网络,使得图像分类网络与视觉模型具有相同的骨干网络,也即图像分类网络与视觉模型中用于进行特征提取的编码模块一致,但是解码模块不同。
步骤S102、使用无标注的第一数据集,对图像分类网络进行自监督训练,得到训练好的图像分类网络。
其中,第一数据集是无标注的数据集,包含当前计算机视觉任务场景下的真实图像数据。另外,第一数据集还可以包括合成数据。
本实施例中,基于当前计算机视觉任务场景的无标注的第一数据集对图像分类网络进行自监督训练,以优化图像分类网络的骨干网络的权重,使得骨干网络更适用于当前的计算机视觉任务,在应用于计算机视觉任务时更好地进行特征提取,并且无需使用有标注的数据集。
步骤S103、根据训练好的图像分类网络的骨干网络的权重,初始化视觉模型的骨干网络的权重,得到预训练模型。
在使用无标注的第一训练集完成图像分类网络的自监督训练之后,将训练好的图像分类网络的骨干网络的权重作为视觉模型的骨干网络的初始权重,对视觉模型进行初始化,得到预训练模型,该预训练模型与视觉模型的结构一致,并且使用当前计算机视觉任务场景下的真实数据集对骨干网络的权重进行了优化。
步骤S104、使用有标注的第二数据集,对预训练模型进行训练,得到训练好的视觉模型。
其中,第二数据集是有标注的数据集,包含当前计算机视觉任务场景下的真实图 像数据及标注信息。
由于步骤S103得到的预训练模型,与视觉模型的结构一致,并且使用当前计算机视觉任务场景下的真实数据集对骨干网络的权重进行了优化,基于该预训练模型,使用当前计算机视觉任务场景下有标注的第二数据集进行模型训练,得到最终的视觉模型,能够有效提升视觉模型的精准度。即使用较少量的有标注的数据,也可以训练得到精准度较高的视觉模型。
本实施例通过建立与视觉模型具有相同的骨干网络的图像分类网络,使用无标注的第一数据集对图像分类网络进行自监督训练,得到训练好的图像分类网络;根据训练好的图像分类网络的骨干网络的权重,初始化视觉模型的骨干网络的权重,得到预训练模型,预训练模型与视觉模型的结构一致,并且使用当前计算机视觉任务场景下的真实数据集对骨干网络的权重进行了优化,更加适用于当前的计算机视觉任务;再使用有标注的第二数据集,对预训练模型进行训练,得到训练好的视觉模型,能够有效提升视觉模型的精准度。
图2是根据本公开第二实施例的视觉模型训练的方法流程图。在上述第一实施例的基础上,本实施例中,使用无标注的第一数据集,对图像分类网络进行自监督训练,得到训练好的图像分类网络,包括:获取无标注的第一数据集,第一数据集包括多组样本图像,以及每一样本图像的方向信息,其中每一组样本图像包括第一样本图像、第一样本图像旋转预设角度得到的第二样本图像;通过图像分类网络提取第一数据集中每一样本图像的图像特征,并根据图像特征确定每一样本图像的方向预测结果;根据同一组样本图像中方向信息相差180度的两个样本图像的图像特征,计算第一损失;并根据每一样本图像的真实方向和方向预测结果计算第二损失;根据第一损失和第二损失,调整图像分类网络的骨干网络的权重,能够使用无标注数据集实现图像分类网络的自监督训练,对骨干网络的权重进行优化,使得骨干网络更加适用于计算机视觉任务的特征提取,能够提高最终得到的视觉模型的精准度。
如图2所示,该方法具体步骤如下:
步骤S201、建立图像分类网络,图像分类网络与视觉模型具有相同的骨干网络。
其中,图像分类网络包括骨干网络和解码模块,骨干网络是指网络中的编码模块,也是用于进行特征提取的模块。
本实施例中,基于视觉模型构建图像分类网络,使得图像分类网络与视觉模型具有相同的骨干网络,也即图像分类网络与视觉模型中用于进行特征提取的编码模块一致,但是解码模块不同。
示例性地,以视觉模型为文本识别模型为例,文本识别模型可以采用CRNN(Convolutional Recurrent Neural Network,卷积循环神经网络)、RARE(Robust text recognizer with Automatic Rectification,具有自动校正功能的鲁棒性文本识别器)、NRTR等实现。图像分类网络的骨干网络用于实现CRNN、RARE、NRTR中特征提取的处理。其中,CRNN全称为主要用于端到端地对不定长的文本序列进行识别,不用先对单个文字进行切割,而是将文本识别转化为时序依赖的序列学习问题,就是基于图像的序列识别。CRNN主要包括卷积层、循环层和转录层,最终实现使用定长输入对不定长的序列的预测。
图像分类网络解码模块用于根据骨干网络提取的特征,解码得到分类结果。
步骤S202、获取无标注的第一数据集,第一数据集包括多组样本图像,以及每一样本图像的方向信息,其中每一组样本图像包括第一样本图像、第一样本图像旋转预设角度得到的第二样本图像。
其中,第一数据集是无标注的数据集,包含当前计算机视觉任务场景下的真实图像数据。另外,第一数据集还可以包括合成数据。
在实际的计算机视觉任务场景中,容易获取到大量的真实图像数据,可不使用合成数据,以减少合成数据的环节,并去除对合成数据的依赖。
本实施例中,获取当前计算机视觉任务场景的大量真实图像数据,生成第一数据集,并且无需对第一数据集进行标注。
具体地,该步骤可以采用如下方式实现:
获取无标注的第一样本图像,将第一样本图像的方向信息确定为0度;将第一样本图像旋转预设角度,得到第二样本图像,将第二样本图像的方向信息确定为预设角度。
其中,预设角度包括一个或者多个不同的角度,可以根据实际应用场景进行设置,此处不做具体限定。
可选地,预设角度可以只包括180度。
可选地,预设角度可以包括180度和至少一个除180度之外的角度。例如,预设角度可以包括90度、180度。
可选地,预设角度可以包括第一角度和第二角度,第一角度和第二角度的差值为180度。例如,预设角度可以包括90度、270度。
可选地,预设角度可以包括第一角度,第二角度和至少一个第三角度,其中第一角度和第二角度的差值为180度。例如,预设角度可以包括90度(第一角度)、270 度(第二角度)、180度(第三角度)。
本实施例中,设置第一样本图像的方向信息为0度,将旋转预设角度得到的第二样本图像的方向信息设置为对应的旋转角度。
示例性地,以将第一样本图像分别旋转90度、180度、270度为例,得到的三张第二样本图像的方向信息依次为90度、180度、270度,而第一样本图像的方向信息为0度。
每一张第一样本图像和该第一样本图像经旋转得到的第二样本图像为一组样本图像,基于同一组样本图像中方向信息相差180度的两个样本图像来确定第一损失,基于同一样本图像的方向预测结果和真实方向信息来确定第二损失,能够丰富用于自监督训练的损失函数,以提高预训练模型的训练效果。
另外,通过设置多个预设角度,使得同一组样本图像中除了方向信息相差180度的两个样本图像之外,还可以包括其他方向信息的样本图像,能够进一步丰富样本数据,提高预训练模型的训练效果。
进一步地,获取无标注的第一样本图像,具体可以采用如下方式实现:
获取原始图像,原始图像包括以下至少一种:合成图像、真实图像;对原始图像进行预处理,得到满足模型训练要求的样本图像;对样本图像进行随机数据增广,得到第一样本图像。
其中,每一张原始图像是当前计算机视觉任务场景下的真实图像或合成图像。
在模型训练过程中,对于输入模型的样本图像的尺寸,是否包含人脸、文本等特定内容等信息有要求。通过对每一张原始图像进行预处理,使得处理后的样本图像满足模型的训练要求,从而保证样本图像能够用于对图像分类模型的训练,以提高图像分类模型训练的效果。
可选地,若视觉模型应用于文本识别场景,对原始图像进行预处理,得到满足模型训练要求的样本图像,包括:
对的原始图像进行文本检测,提取文本信息所在区域的图像;对文本信息所在区域的图像进行图像校正,得到满足模型训练要求的样本图像,从而保证样本图像能够用于对图像分类模型的训练,以提高图像分类模型训练的效果。
示例性地,可以通过文本检测模型对的原始图像进行文本检测,提取出文本信息所在区域的图像,得到文本检测结果。文本检测结果可能是多边形,使用仿射变换的方法对文本检测结果进行图像校正,得到满足模型训练要求的样本图像,通常要求样本图像的边框为矩形框。
另外,通过对样本图像进行随机数据增广,得到第一样本图像,可以大大增加样本图像的数量,使得第一数据集更加丰富。
另外,步骤S202也可以在步骤S201之后执行,步骤S202也可以在步骤S201之前进行,此处对于S202和S201的执行顺序不做具体限定。
需要说明的是,图像分类模型的类别数设置为与预设角度的数量相关,图像分类模型的类别数等于预设角度的数量加1。图像分类模型用于对样本图像进行方向信息分类,预测样本图像对应的方向信息。
示例性地,以预设角度包括90度、180度、270度为例,图像分类模型的类别数设置为4,图像分类模型用于预测输入样本图像的方向信息为0度、90度、180度、270度中的哪一个。
在获取到无标注的第一数据集之后,循环执行步骤S203-S207,基于无标注的第一数据集,对图像分类模型进行自监督的迭代训练,直至满足迭代停止条件时,停止迭代。
步骤S203、通过图像分类网络提取第一数据集中每一样本图像的图像特征,并根据图像特征确定每一样本图像的方向预测结果。
该步骤中,将第一数据集中的样本图像输入图像分类网络,通过图像分类网络的骨干网络提取样本图像的图像特征,通过图像分类网络的解码模块根据样本图像的图像特征,预测样本图像的方向信息,得到样本图像的方向预测结果。
可选地,在将样本图像输入图像分类网络之前,对样本图像进行归一化处理。
本实施例中,进行图像分类网络的自监督训练时,使用两种损失函数,一种损失函数用于计算同一组样本图像中方向信息相差180度的两个样本图像的图像特征之间的第一损失,另一种损失函数用于计算每一样本图像的真实方向和方向预测结果的第二损失,能够丰富用于监督训练的损失函数,提升模型训练的效果。
步骤S204、根据同一组样本图像中方向信息相差180度的两个样本图像的图像特征,计算第一损失。
一种可选地实施方式中,预设角度至少包括180度。该步骤具体可以采用如下方式实现:
根据每一组样本图像中第一样本图像的图像特征旋转180度后得到特征,与第一样本图像旋转180度后得到的第二样本图像的图像特征之间的差异,计算第一损失。
通过这种方式计算的第一损失,能够准确地反映同一组样本图像中方向信息相差180度的两个样本图像的图像特征之间的差异情况,基于第一损失对图像分类模型进 行自监督训练,使得图像分类模型的骨干网络能够学习图像的旋转角度,使得特征提取模块能够更好地提取图像特征,能够进一步提升图像分类模型的鲁棒性,从而能提高最终得到的视觉模型的精准度。
另一种可选地实施方式中,预设角度至少包括第一角度和第二角度,第二角度等于第一角度加180度,第一角度不是0度。例如,第一角度为90度,第二角度为270度。
该步骤具体可以采用如下方式实现:
根据同一组样本图像中方向信息为第一角度的样本图像的图像特征旋转180度后得到的特征,与方向信息为第二角度的样本图像的图像特征之间的差异,计算第一损失。
通过这种方式计算的第一损失,也能够准确地反映同一组样本图像中方向信息相差180度的两个样本图像的图像特征之间的差异情况,基于第一损失对图像分类模型进行自监督训练,使得图像分类模型的骨干网络能够学习图像的旋转角度,使得特征提取模块能够更好地提取图像特征,能够进一步提升图像分类模型的鲁棒性,从而能提高最终得到的视觉模型的精准度。
示例性地,根据同一样本图像分别旋转90度和旋转270度后的样本图像的图像特征,将旋转90度后的样本图像的图像特征作为第一特征,将旋转270度后的样本图像的图像特征作为第二特征,根据第一特征180度后得到的特征与第二特征之间的差异,计算第一损失。
可选地,在预设角度即包括180度,又包括第一角度和第二角度时,该步骤中可以将上述两种可选地实施方式可以结合起来计算第一损失。
可选地,第一损失可以为L2损失。另外,第一损失还可以是L1损失、获取是使用其他具有类型效果的损失函数计算的损失,本实施例此处不做具体限定。
步骤S205、根据每一样本图像的真实方向和方向预测结果计算第二损失。
该步骤中,根据每一样本图像的真实方向和方向预测结果之间的差异,计算第二损失。
可选地,计算第二损失可以使用交叉熵损失函数,或者可以使用分类模型中常用的其他用于衡量分类结果质量的损失函数,本实施例此处不做具体限定。
本实施例中,步骤S204和步骤S205可以并行进行,或者可以按照任意顺序先后执行。
步骤S206、根据第一损失和第二损失,调整图像分类网络的骨干网络的权重。
在计算得到第一损失和第二损失之后,根据第一损失和第二损失对图像分类网络的骨干网络的权重进行调整,以优化骨干网络的权重。
可选地,可以计算第一损失和第二损失之和,作为最终损失;根据最终损失,调整图像分类网络的骨干网络的权重,能够结合两种不同的损失函数对图像分类网络进行自监督训练,提高图像分类网络的鲁棒性和有效性。
步骤S207、是否满足迭代结束条件。
在通过上述步骤S203-S206完成对图像分类网络的一次迭代训练后,判断是否满足迭代结束条件。
若满足迭代结束条件,则停止迭代,并确定方向分类精准度最高的图像分类模型,作为训练好的图像分类模型,继续执行步骤S208。
若不满足迭代结束条件,则继续执行步骤S203,开始下一次迭代。
其中,迭代停止条件可以包括以下至少一种:迭代次数达到预设次数阈值、最终损失小于损失阈值、两次迭代之间权重值的变化已经很小。
步骤S208、根据训练好的图像分类网络的骨干网络的权重,初始化视觉模型的骨干网络的权重,得到预训练模型。
在使用无标注的第一训练集完成图像分类网络的自监督训练之后,将训练好的图像分类网络的骨干网络的权重作为视觉模型的骨干网络的初始权重,对视觉模型进行初始化,得到预训练模型,该预训练模型与视觉模型的结构一致,并且使用当前计算机视觉任务场景下的真实数据集对骨干网络的权重进行了优化。
步骤S209、使用有标注的第二数据集,对预训练模型进行训练,得到训练好的视觉模型。
其中,第二数据集是有标注的数据集,包含当前计算机视觉任务场景下的真实图像数据及标注信息。
预训练模型与视觉模型的结构一致,并且使用当前计算机视觉任务场景下的真实数据集对预训练模型中骨干网络的权重进行了优化。使用当前计算机视觉任务场景下有标注的第二数据集,对该预训练模型再次进行模型训练,得到最终的视觉模型,能够有效提升视觉模型的精准度。即使用较少量的有标注的数据,也可以训练得到精准度较高的视觉模型。
本实施例通过建立与视觉模型具有相同的骨干网络的图像分类网络,使用无标注的第一数据集对图像分类网络进行自监督训练,得到训练好的图像分类网络,充分利用了无标注数据对用于提取特征的骨干网络进行训练;进一步地,进行图像分类网络 的自监督训练时使用两种损失函数,计算同一组样本图像中方向信息相差180度的两个样本图像的图像特征之间的第一损失,计算每一样本图像的真实方向和方向预测结果的第二损失,基于第一损失和第二损失优化骨干网络的权重,同时考虑分类结果损失和图像特征对齐的损失,能够丰富用于监督训练的损失函数,提升预训练模型的鲁棒性和特征提取的精准度。在此基础上,根据训练好的图像分类网络的骨干网络的权重,初始化视觉模型的骨干网络的权重,得到预训练模型,预训练模型与视觉模型的结构一致,并且使用当前计算机视觉任务场景下的真实数据集对骨干网络的权重进行了优化,更加适用于当前的计算机视觉任务;再使用有标注的第二数据集,对预训练模型进行训练,得到训练好的视觉模型,能够有效提升视觉模型的精准度。
图3是根据本公开第三实施例的视觉处理方法流程图。本实施例提供的视觉处理方法具体可以应用于电子设备,该电子设备用于实现利用训练好的视觉模型实现对图像的视觉处理。
如图3所示,该方法具体步骤如下:
步骤S301、获取待处理图像。
步骤S302、将待处理图像输入视觉模型,通过视觉模型对待处理图像进行计算机视觉处理,得到处理结果。
其中,视觉模型是通过上述第一实施例或第二实施例的方法训练得到的,具体训练过程此处不再赘述。
示例性地,视觉模型可以是文本识别模型。对于训练好的文本识别模型,通过将待处理图像输入文本识别模型,通过文本识别模型对输入的图像进行文本识别处理,得到的处理结果是输入的图像所包含的文本信息。
步骤S303、输出处理结果。
本实施例通过训练好的视觉模型,对输入图像进行视觉处理,得到视觉处理结果并输出。
图4是根据本公开第四实施例的视觉模型训练的装置的结构示意图。本公开实施例提供的视觉模型训练的装置可以执行视觉模型训练的方法实施例提供的处理流程。如图4所示,该视觉模型训练的装置40包括:
具体地,网络建立模块41,用于建立图像分类网络,图像分类网络与视觉模型具有相同的骨干网络。
第一训练模块42,用于使用无标注的第一数据集,对图像分类网络进行自监督训练,得到训练好的图像分类网络。
预训练模型确定模块43,用于根据训练好的图像分类网络的骨干网络的权重,初始化视觉模型的骨干网络的权重,得到预训练模型。
第二训练模块44,用于使用有标注的第二数据集,对预训练模型进行训练,得到训练好的视觉模型。
本公开实施例提供的装置可以具体用于执行上述第一实施例提供的方法实施例,所实现具体功能此处不再赘述。
本实施例通过建立与视觉模型具有相同的骨干网络的图像分类网络,使用无标注的第一数据集对图像分类网络进行自监督训练,得到训练好的图像分类网络;根据训练好的图像分类网络的骨干网络的权重,初始化视觉模型的骨干网络的权重,得到预训练模型,预训练模型与视觉模型的结构一致,并且使用当前计算机视觉任务场景下的真实数据集对骨干网络的权重进行了优化,更加适用于当前的计算机视觉任务;再使用有标注的第二数据集,对预训练模型进行训练,得到训练好的视觉模型,能够有效提升视觉模型的精准度。
图5是根据本公开第五实施例的视觉模型训练的装置的结构示意图。本公开实施例提供的视觉模型训练的装置可以执行视觉模型训练的方法实施例提供的处理流程。如图5所示,该视觉模型训练的装置50包括:
具体地,网络建立模块51,用于建立图像分类网络,图像分类网络与视觉模型具有相同的骨干网络。
第一训练模块52,用于使用无标注的第一数据集,对图像分类网络进行自监督训练,得到训练好的图像分类网络。
预训练模型确定模块53,用于根据训练好的图像分类网络的骨干网络的权重,初始化视觉模型的骨干网络的权重,得到预训练模型。
第二训练模块54,用于使用有标注的第二数据集,对预训练模型进行训练,得到训练好的视觉模型。
可选地,如图5所示,第一训练模块52,包括:
无标注数据集获取单元521,用于获取无标注的第一数据集,第一数据集包括多组样本图像,以及每一样本图像的方向信息,其中每一组样本图像包括第一样本图像、第一样本图像旋转预设角度得到的第二样本图像。
分类预测单元522,用于通过图像分类网络提取第一数据集中每一样本图像的图像特征,并根据图像特征确定每一样本图像的方向预测结果。
损失计算单元523,用于根据同一组样本图像中方向信息相差180度的两个样本 图像的图像特征,计算第一损失;并根据每一样本图像的真实方向信息和方向预测结果计算第二损失。
权重优化单元524,用于根据第一损失和第二损失,调整图像分类网络的骨干网络的权重。
可选地,无标注数据集获取单元,包括:
样本图像获取子单元,用于获取无标注的第一样本图像,将第一样本图像的方向信息确定为0度。
图像旋转子单元,用于将第一样本图像旋转预设角度,得到第二样本图像,将第二样本图像的方向信息确定为预设角度。
可选地,预设角度至少包括180度。损失计算单元包括:
第一损失计算子单元,用于根据每一组样本图像中第一样本图像的图像特征旋转180度后得到特征,与第一样本图像旋转180度后得到的第二样本图像的图像特征之间的差异,计算第一损失。
可选地,预设角度至少包括第一角度和第二角度,第二角度等于第一角度加180度,第一角度不是0度。损失计算单元包括:
第二损失计算子单元,根据同一组样本图像中方向信息为第一角度的样本图像的图像特征旋转180度后得到的特征,与方向信息为第二角度的样本图像的图像特征之间的差异,计算第一损失。
可选地,样本图像获取子单元还用于:
获取原始图像,原始图像包括以下至少一种:合成图像、真实图像;对原始图像进行预处理,得到满足模型训练要求的样本图像;对样本图像进行随机数据增广,得到第一样本图像。
可选地,样本图像获取子单元还用于:
对的原始图像进行文本检测,提取文本信息所在区域的图像;对文本信息所在区域的图像进行图像校正,得到满足模型训练要求的样本图像。
可选地,权重优化单元还用于:
计算第一损失和第二损失之和,作为最终损失;根据最终损失,调整图像分类网络的骨干网络的权重。
本公开实施例提供的装置可以具体用于执行上述第二实施例提供的方法实施例,所实现具体功能此处不再赘述。
本实施例通过建立与视觉模型具有相同的骨干网络的图像分类网络,使用无标注 的第一数据集对图像分类网络进行自监督训练,得到训练好的图像分类网络,充分利用了无标注数据对用于提取特征的骨干网络进行训练;进一步地,进行图像分类网络的自监督训练时使用两种损失函数,计算同一组样本图像中方向信息相差180度的两个样本图像的图像特征之间的第一损失,计算每一样本图像的真实方向和方向预测结果的第二损失,基于第一损失和第二损失优化骨干网络的权重,同时考虑分类结果损失和图像特征对齐的损失,能够丰富用于监督训练的损失函数,提升预训练模型的鲁棒性和特征提取的精准度。在此基础上,根据训练好的图像分类网络的骨干网络的权重,初始化视觉模型的骨干网络的权重,得到预训练模型,预训练模型与视觉模型的结构一致,并且使用当前计算机视觉任务场景下的真实数据集对骨干网络的权重进行了优化,更加适用于当前的计算机视觉任务;再使用有标注的第二数据集,对预训练模型进行训练,得到训练好的视觉模型,能够有效提升视觉模型的精准度。
图6是根据本公开第六实施例的视觉处理装置的结构示意图。本公开实施例提供的视觉处理装置可以执行视觉处理方法实施例提供的处理流程。如图6所示,该视觉处理装置60包括:图像获取模块61,视觉处理模块62和结果输出模块63。
具体地,图像获取模块61,用于获取待处理图像。
视觉处理模块62,用于将待处理图像输入视觉模型,通过视觉模型对待处理图像进行计算机视觉处理,得到处理结果,其中视觉模型由上述第四实施例或第五实施例的装置生成。
结果输出模块63,用于输出处理结果。
本公开实施例提供的装置可以具体用于执行上述第三实施例提供的方法实施例,所实现具体功能此处不再赘述。
本公开的技术方案中,所涉及的用户个人信息的收集、存储、使用、加工、传输、提供和公开等处理,均符合相关法律法规的规定,且不违背公序良俗。
根据本公开的实施例,本公开还提供了一种电子设备、一种可读存储介质和一种计算机程序产品。
根据本公开的实施例,本公开还提供了一种计算机程序产品,计算机程序产品包括:计算机程序,计算机程序存储在可读存储介质中,电子设备的至少一个处理器可以从可读存储介质读取计算机程序,至少一个处理器执行计算机程序使得电子设备执行上述任一实施例提供的方案。
图7示出了可以用来实施本公开的实施例的示例电子设备700的示意性框图。电 子设备旨在表示各种形式的数字计算机,诸如,膝上型计算机、台式计算机、工作台、个人数字助理、服务器、刀片式服务器、大型计算机、和其它适合的计算机。电子设备还可以表示各种形式的移动装置,诸如,个人数字处理、蜂窝电话、智能电话、可穿戴设备和其它类似的计算装置。本文所示的部件、它们的连接和关系、以及它们的功能仅仅作为示例,并且不意在限制本文中描述的和/或者要求的本公开的实现。
如图7所示,设备700包括计算单元701,其可以根据存储在只读存储器(ROM)702中的计算机程序或者从存储单元708加载到随机访问存储器(RAM)703中的计算机程序,来执行各种适当的动作和处理。在RAM 703中,还可存储设备700操作所需的各种程序和数据。计算单元701、ROM 702以及RAM 703通过总线704彼此相连。输入/输出(I/O)接口705也连接至总线704。
设备700中的多个部件连接至I/O接口705,包括:输入单元706,例如键盘、鼠标等;输出单元707,例如各种类型的显示器、扬声器等;存储单元708,例如磁盘、光盘等;以及通信单元709,例如网卡、调制解调器、无线通信收发机等。通信单元709允许设备700通过诸如因特网的计算机网络和/或各种电信网络与其他设备交换信息/数据。
计算单元701可以是各种具有处理和计算能力的通用和/或专用处理组件。计算单元701的一些示例包括但不限于中央处理单元(CPU)、图形处理单元(GPU)、各种专用的人工智能(AI)计算芯片、各种运行机器学习模型算法的计算单元、数字信号处理器(DSP)、以及任何适当的处理器、控制器、微控制器等。计算单元701执行上文所描述的各个方法和处理,例如视觉模型训练的方法或视觉处理方法。例如,在一些实施例中,视觉模型训练的方法或视觉处理方法可被实现为计算机软件程序,其被有形地包含于机器可读介质,例如存储单元708。在一些实施例中,计算机程序的部分或者全部可以经由ROM 702和/或通信单元709而被载入和/或安装到设备700上。当计算机程序加载到RAM 703并由计算单元701执行时,可以执行上文描述的视觉模型训练的方法或视觉处理方法的一个或多个步骤。备选地,在其他实施例中,计算单元701可以通过其他任何适当的方式(例如,借助于固件)而被配置为执行视觉模型训练的方法。
本文中以上描述的系统和技术的各种实施方式可以在数字电子电路系统、集成电路系统、场可编程门阵列(FPGA)、专用集成电路(ASIC)、专用标准产品(ASSP)、芯片上系统的系统(SOC)、复杂可编程逻辑设备(CPLD)、计算机硬件、固件、软件、和/或它们的组合中实现。这些各种实施方式可以包括:实施在一个或者多个计算 机程序中,该一个或者多个计算机程序可在包括至少一个可编程处理器的可编程系统上执行和/或解释,该可编程处理器可以是专用或者通用可编程处理器,可以从存储系统、至少一个输入装置、和至少一个输出装置接收数据和指令,并且将数据和指令传输至该存储系统、该至少一个输入装置、和该至少一个输出装置。
用于实施本公开的方法的程序代码可以采用一个或多个编程语言的任何组合来编写。这些程序代码可以提供给通用计算机、专用计算机或其他可编程数据处理装置的处理器或控制器,使得程序代码当由处理器或控制器执行时使流程图和/或框图中所规定的功能/操作被实施。程序代码可以完全在机器上执行、部分地在机器上执行,作为独立软件包部分地在机器上执行且部分地在远程机器上执行或完全在远程机器或服务器上执行。
在本公开的上下文中,机器可读介质可以是有形的介质,其可以包含或存储以供指令执行系统、装置或设备使用或与指令执行系统、装置或设备结合地使用的程序。机器可读介质可以是机器可读信号介质或机器可读储存介质。机器可读介质可以包括但不限于电子的、磁性的、光学的、电磁的、红外的、或半导体系统、装置或设备,或者上述内容的任何合适组合。机器可读存储介质的更具体示例会包括基于一个或多个线的电气连接、便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦除可编程只读存储器(EPROM或快闪存储器)、光纤、便捷式紧凑盘只读存储器(CD-ROM)、光学储存设备、磁储存设备、或上述内容的任何合适组合。
为了提供与用户的交互,可以在计算机上实施此处描述的系统和技术,该计算机具有:用于向用户显示信息的显示装置(例如,CRT(阴极射线管)或者LCD(液晶显示器)监视器);以及键盘和指向装置(例如,鼠标或者轨迹球),用户可以通过该键盘和该指向装置来将输入提供给计算机。其它种类的装置还可以用于提供与用户的交互;例如,提供给用户的反馈可以是任何形式的传感反馈(例如,视觉反馈、听觉反馈、或者触觉反馈);并且可以用任何形式(包括声输入、语音输入或者、触觉输入)来接收来自用户的输入。
可以将此处描述的系统和技术实施在包括后台部件的计算系统(例如,作为数据服务器)、或者包括中间件部件的计算系统(例如,应用服务器)、或者包括前端部件的计算系统(例如,具有图形用户界面或者网络浏览器的用户计算机,用户可以通过该图形用户界面或者该网络浏览器来与此处描述的系统和技术的实施方式交互)、或者包括这种后台部件、中间件部件、或者前端部件的任何组合的计算系统中。可以通过任何形式或者介质的数字数据通信(例如,通信网络)来将系统的部件相互连接。 通信网络的示例包括:局域网(LAN)、广域网(WAN)和互联网。
计算机系统可以包括客户端和服务器。客户端和服务器一般远离彼此并且通常通过通信网络进行交互。通过在相应的计算机上运行并且彼此具有客户端-服务器关系的计算机程序来产生客户端和服务器的关系。服务器可以是云服务器,又称为云计算服务器或云主机,是云计算服务体系中的一项主机产品,以解决了传统物理主机与VPS服务("Virtual Private Server",或简称"VPS")中,存在的管理难度大,业务扩展性弱的缺陷。服务器也可以为分布式系统的服务器,或者是结合了区块链的服务器。
应该理解,可以使用上面所示的各种形式的流程,重新排序、增加或删除步骤。例如,本发公开中记载的各步骤可以并行地执行也可以顺序地执行也可以不同的次序执行,只要能够实现本公开公开的技术方案所期望的结果,本文在此不进行限制。
上述具体实施方式,并不构成对本公开保护范围的限制。本领域技术人员应该明白的是,根据设计要求和其他因素,可以进行各种修改、组合、子组合和替代。任何在本公开的精神和原则之内所作的修改、等同替换和改进等,均应包含在本公开保护范围之内。

Claims (21)

  1. 一种视觉模型训练的方法,包括:
    建立图像分类网络,所述图像分类网络与所述视觉模型具有相同的骨干网络;
    使用无标注的第一数据集,对所述图像分类网络进行自监督训练,得到训练好的图像分类网络;
    根据训练好的图像分类网络的骨干网络的权重,初始化所述视觉模型的骨干网络的权重,得到预训练模型;
    使用有标注的第二数据集,对所述预训练模型进行训练,得到训练好的视觉模型,所述视觉模型用于执行计算机视觉处理得到处理结果。
  2. 根据权利要求1所述的方法,其中,所述使用无标注的第一数据集,对所述图像分类网络进行自监督训练,得到训练好的图像分类网络,包括:
    获取所述无标注的第一数据集,所述第一数据集包括多组样本图像,以及每一样本图像的方向信息,其中每一组样本图像包括第一样本图像、所述第一样本图像旋转预设角度得到的第二样本图像;
    通过所述图像分类网络提取所述第一数据集中每一样本图像的图像特征,并根据所述图像特征确定每一样本图像的方向预测结果;
    根据同一组样本图像中方向信息相差180度的两个样本图像的图像特征,计算第一损失;并根据每一样本图像的真实方向信息和方向预测结果计算第二损失;
    根据所述第一损失和所述第二损失,调整所述图像分类网络的骨干网络的权重。
  3. 根据权利要求2所述的方法,其中,所述获取所述无标注的第一数据集,包括:
    获取无标注的第一样本图像,将所述第一样本图像的方向信息确定为0度;
    将所述第一样本图像旋转所述预设角度,得到第二样本图像,将所述第二样本图像的方向信息确定为所述预设角度。
  4. 根据权利要求3所述的方法,其中,所述预设角度至少包括180度,
    所述根据同一组样本图像中方向信息相差180度的两个样本图像的图像特征,计算第一损失,包括:
    根据每一组样本图像中第一样本图像的图像特征旋转180度后得到特征,与第一样本图像旋转180度后得到的第二样本图像的图像特征之间的差异,计算第一损失。
  5. 根据权利要求3所述的方法,其中,所述预设角度至少包括第一角度和第二角度,所述第二角度等于所述第一角度加180度,所述第一角度不是0度;
    所述根据同一组样本图像中方向信息相差180度的两个样本图像的图像特征,计算第一损失,包括:
    根据同一组样本图像中方向信息为所述第一角度的样本图像的图像特征旋转180度后得到的特征,与方向信息为所述第二角度的样本图像的图像特征之间的差异,计算第一损失。
  6. 根据权利要求3-5中任一项所述的方法,其中,所述获取无标注的第一样本图像,包括:
    获取原始图像,所述原始图像包括以下至少一种:合成图像、真实图像;
    对所述原始图像进行预处理,得到满足模型训练要求的样本图像;
    对所述样本图像进行随机数据增广,得到所述第一样本图像。
  7. 根据权利要求6所述的方法,其中,若所述视觉模型应用于文本识别场景,所述对所述原始图像进行预处理,得到满足模型训练要求的样本图像,包括:
    对的所述原始图像进行文本检测,提取文本信息所在区域的图像;
    对所述文本信息所在区域的图像进行图像校正,得到满足模型训练要求的样本图像。
  8. 根据权利要求2-7中任一项所述的方法,其中,所述根据所述第一损失和所述第二损失,调整所述图像分类网络的骨干网络的权重,包括:
    计算所述第一损失和所述第二损失之和,作为最终损失;
    根据所述最终损失,调整所述图像分类网络的骨干网络的权重。
  9. 一种视觉处理方法,包括:
    获取待处理图像;
    将所述待处理图像输入视觉模型,通过所述视觉模型对所述待处理图像进行计算机视觉处理,得到处理结果,其中所述视觉模型通过如权利要求1-8中任一项所述的方法训练得到;
    输出处理结果。
  10. 一种视觉模型训练的装置,包括:
    网络建立模块,用于建立图像分类网络,所述图像分类网络与所述视觉模型具有相同的骨干网络;
    第一训练模块,用于使用无标注的第一数据集,对所述图像分类网络进行自监督训练,得到训练好的图像分类网络;
    预训练模型确定模块,用于根据训练好的图像分类网络的骨干网络的权重,初始 化所述视觉模型的骨干网络的权重,得到预训练模型;
    第二训练模块,用于使用有标注的第二数据集,对所述预训练模型进行训练,得到训练好的视觉模型。
  11. 根据权利要求10所述的装置,其中,第一训练模块,包括:
    无标注数据集获取单元,用于获取所述无标注的第一数据集,所述第一数据集包括多组样本图像,以及每一样本图像的方向信息,其中每一组样本图像包括第一样本图像、所述第一样本图像旋转预设角度得到的第二样本图像;
    分类预测单元,用于通过所述图像分类网络提取所述第一数据集中每一样本图像的图像特征,并根据所述图像特征确定每一样本图像的方向预测结果;
    损失计算单元,用于根据同一组样本图像中方向信息相差180度的两个样本图像的图像特征,计算第一损失;并根据每一样本图像的真实方向信息和方向预测结果计算第二损失;
    权重优化单元,用于根据所述第一损失和所述第二损失,调整所述图像分类网络的骨干网络的权重。
  12. 根据权利要求11所述的装置,其中,所述无标注数据集获取单元,包括:
    样本图像获取子单元,用于获取无标注的第一样本图像,将所述第一样本图像的方向信息确定为0度;
    图像旋转子单元,用于将所述第一样本图像旋转所述预设角度,得到第二样本图像,将所述第二样本图像的方向信息确定为所述预设角度。
  13. 根据权利要求12所述的装置,其中,所述预设角度至少包括180度,所述损失计算单元包括:
    第一损失计算子单元,用于根据每一组样本图像中第一样本图像的图像特征旋转180度后得到特征,与第一样本图像旋转180度后得到的第二样本图像的图像特征之间的差异,计算第一损失。
  14. 根据权利要求12所述的装置,其中,所述预设角度至少包括第一角度和第二角度,所述第二角度等于所述第一角度加180度,所述第一角度不是0度,所述损失计算单元包括:
    第二损失计算子单元,根据同一组样本图像中方向信息为所述第一角度的样本图像的图像特征旋转180度后得到的特征,与方向信息为所述第二角度的样本图像的图像特征之间的差异,计算第一损失。
  15. 根据权利要求12-14中任一项所述的装置,其中,所述样本图像获取子单元 还用于:
    获取原始图像,所述原始图像包括以下至少一种:合成图像、真实图像;
    对所述原始图像进行预处理,得到满足模型训练要求的样本图像;
    对所述样本图像进行随机数据增广,得到所述第一样本图像。
  16. 根据权利要求15所述的装置,其中,所述样本图像获取子单元还用于:
    对的所述原始图像进行文本检测,提取文本信息所在区域的图像;
    对所述文本信息所在区域的图像进行图像校正,得到满足模型训练要求的样本图像。
  17. 根据权利要求11-16中任一项所述的装置,其中,所述权重优化单元还用于:
    计算所述第一损失和所述第二损失之和,作为最终损失;
    根据所述最终损失,调整所述图像分类网络的骨干网络的权重。
  18. 一种视觉处理装置,包括:
    图像获取模块,用于获取待处理图像;
    视觉处理模块,用于将所述待处理图像输入视觉模型,通过所述视觉模型对所述待处理图像进行计算机视觉处理,得到处理结果,其中所述视觉模型由权利要求10-17中任一项所述的装置生成;
    结果输出模块,用于输出处理结果。
  19. 一种电子设备,包括:
    至少一个处理器;以及
    与所述至少一个处理器通信连接的存储器;其中,
    所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行权利要求1-9中任一项所述的方法。
  20. 一种存储有计算机指令的非瞬时计算机可读存储介质,其中,所述计算机指令用于使所述计算机执行根据权利要求1-9中任一项所述的方法。
  21. 一种计算机程序产品,包括计算机程序,该计算机程序被处理器执行时实现权利要求1-9中任一项所述方法。
PCT/CN2022/100368 2022-02-25 2022-06-22 视觉处理及模型训练方法、设备、存储介质及程序产品 WO2023159819A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
JP2023512344A JP2024510361A (ja) 2022-02-25 2022-06-22 視覚処理及びモデル訓練の方法、機器、記憶媒体及びプログラム製品
US18/170,902 US20230206668A1 (en) 2022-02-25 2023-02-17 Vision processing and model training method, device, storage medium and program product

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210181868.0 2022-02-25
CN202210181868.0A CN114549904B (zh) 2022-02-25 2022-02-25 视觉处理及模型训练方法、设备、存储介质及程序产品

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US18/170,902 Continuation US20230206668A1 (en) 2022-02-25 2023-02-17 Vision processing and model training method, device, storage medium and program product

Publications (1)

Publication Number Publication Date
WO2023159819A1 true WO2023159819A1 (zh) 2023-08-31

Family

ID=81678608

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/100368 WO2023159819A1 (zh) 2022-02-25 2022-06-22 视觉处理及模型训练方法、设备、存储介质及程序产品

Country Status (2)

Country Link
CN (1) CN114549904B (zh)
WO (1) WO2023159819A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114549904B (zh) * 2022-02-25 2023-07-07 北京百度网讯科技有限公司 视觉处理及模型训练方法、设备、存储介质及程序产品

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109919209A (zh) * 2019-02-26 2019-06-21 中国人民解放军军事科学院国防科技创新研究院 一种领域自适应深度学习方法及可读存储介质
CN112560874A (zh) * 2020-12-25 2021-03-26 北京百度网讯科技有限公司 图像识别模型的训练方法、装置、设备和介质
CN113705301A (zh) * 2021-03-16 2021-11-26 腾讯科技(深圳)有限公司 图像处理方法及装置
CN114549904A (zh) * 2022-02-25 2022-05-27 北京百度网讯科技有限公司 视觉处理及模型训练方法、设备、存储介质及程序产品

Family Cites Families (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3884428A1 (en) * 2019-05-29 2021-09-29 Leica Biosystems Imaging, Inc. Neural network based identification of areas of interest in digital pathology images
CN110263724A (zh) * 2019-06-21 2019-09-20 腾讯科技(深圳)有限公司 图片识别方法、识别模型训练方法、装置及存储介质
CN111382871A (zh) * 2020-03-11 2020-07-07 中国人民解放军军事科学院国防科技创新研究院 基于数据扩充一致性的领域泛化和领域自适应学习方法
CN111666846B (zh) * 2020-05-27 2023-05-30 厦门大学 一种人脸属性识别方法和装置
CN112801164B (zh) * 2021-01-22 2024-02-13 北京百度网讯科技有限公司 目标检测模型的训练方法、装置、设备及存储介质
CN112861975B (zh) * 2021-02-10 2023-09-26 北京百度网讯科技有限公司 分类模型的生成方法、分类方法、装置、电子设备与介质
CN113139623B (zh) * 2021-05-14 2021-11-09 中国人民解放军91977部队 舰船目标识别方法及装置
CN113486745A (zh) * 2021-06-24 2021-10-08 哈尔滨工业大学(深圳) 基于自监督神经网络的显微结构图像识别方法及装置
CN113378835A (zh) * 2021-06-28 2021-09-10 北京百度网讯科技有限公司 标注模型训练、样本标注方法及相关装置
CN113627483B (zh) * 2021-07-09 2024-02-02 武汉大学 基于自监督纹理对比学习的宫颈oct图像分类方法及设备
CN113792581A (zh) * 2021-08-02 2021-12-14 深圳市一心视觉科技有限公司 一种活体检测方法、装置及电子设备
CN113837238B (zh) * 2021-09-02 2023-09-01 南京大学 一种基于自监督和自蒸馏的长尾图像识别方法
CN113780578B (zh) * 2021-09-08 2023-12-12 北京百度网讯科技有限公司 模型训练方法、装置、电子设备及可读存储介质
CN113706564B (zh) * 2021-09-23 2023-07-18 苏州大学 基于多种监督方式的睑板腺分割网络的训练方法及装置
CN113869449A (zh) * 2021-10-11 2021-12-31 北京百度网讯科技有限公司 一种模型训练、图像处理方法、装置、设备及存储介质
CN113963186A (zh) * 2021-10-29 2022-01-21 北京百度网讯科技有限公司 目标检测模型的训练方法、目标检测方法及相关装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109919209A (zh) * 2019-02-26 2019-06-21 中国人民解放军军事科学院国防科技创新研究院 一种领域自适应深度学习方法及可读存储介质
CN112560874A (zh) * 2020-12-25 2021-03-26 北京百度网讯科技有限公司 图像识别模型的训练方法、装置、设备和介质
CN113705301A (zh) * 2021-03-16 2021-11-26 腾讯科技(深圳)有限公司 图像处理方法及装置
CN114549904A (zh) * 2022-02-25 2022-05-27 北京百度网讯科技有限公司 视觉处理及模型训练方法、设备、存储介质及程序产品

Also Published As

Publication number Publication date
CN114549904B (zh) 2023-07-07
CN114549904A (zh) 2022-05-27

Similar Documents

Publication Publication Date Title
WO2023015941A1 (zh) 文本检测模型的训练方法和检测文本方法、装置和设备
JP7331171B2 (ja) 画像認識モデルをトレーニングするための方法および装置、画像を認識するための方法および装置、電子機器、記憶媒体、並びにコンピュータプログラム
WO2023020045A1 (zh) 文字识别模型的训练方法、文字识别方法及装置
US20230106873A1 (en) Text extraction method, text extraction model training method, electronic device and storage medium
CN113313022B (zh) 文字识别模型的训练方法和识别图像中文字的方法
WO2022257487A1 (zh) 深度估计模型的训练方法, 装置, 电子设备及存储介质
US20220415072A1 (en) Image processing method, text recognition method and apparatus
WO2024036847A1 (zh) 图像处理方法和装置、电子设备和存储介质
EP3961584A2 (en) Character recognition method, model training method, related apparatus and electronic device
WO2023005253A1 (zh) 文本识别模型框架的训练方法、装置及系统
CN113657395B (zh) 文本识别方法、视觉特征提取模型的训练方法及装置
US20230215203A1 (en) Character recognition model training method and apparatus, character recognition method and apparatus, device and storage medium
CN114445831A (zh) 一种图文预训练方法、装置、设备以及存储介质
US20230133981A1 (en) Method of training image generation model, and method of generating image
CN115861462B (zh) 图像生成模型的训练方法、装置、电子设备及存储介质
WO2022213717A1 (zh) 模型训练方法、行人再识别方法、装置和电子设备
WO2023159819A1 (zh) 视觉处理及模型训练方法、设备、存储介质及程序产品
CN114817612A (zh) 多模态数据匹配度计算和计算模型训练的方法、相关装置
CN113657411A (zh) 神经网络模型的训练方法、图像特征提取方法及相关装置
CN113360683A (zh) 训练跨模态检索模型的方法以及跨模态检索方法和装置
WO2024040870A1 (zh) 文本图像生成、训练、文本图像处理方法以及电子设备
US20220343662A1 (en) Method and apparatus for recognizing text, device and storage medium
KR20230133808A (ko) Roi 검출 모델 훈련 방법, 검출 방법, 장치, 설비 및 매체
WO2023173536A1 (zh) 化学式识别方法、装置、计算机设备及存储介质
CN115359323A (zh) 图像的文本信息生成方法和深度学习模型的训练方法

Legal Events

Date Code Title Description
WWE Wipo information: entry into national phase

Ref document number: 2023512344

Country of ref document: JP

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22928090

Country of ref document: EP

Kind code of ref document: A1