WO2023201963A1 - 图像理解方法、装置、设备及介质 - Google Patents

图像理解方法、装置、设备及介质 Download PDF

Info

Publication number
WO2023201963A1
WO2023201963A1 PCT/CN2022/116913 CN2022116913W WO2023201963A1 WO 2023201963 A1 WO2023201963 A1 WO 2023201963A1 CN 2022116913 W CN2022116913 W CN 2022116913W WO 2023201963 A1 WO2023201963 A1 WO 2023201963A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
text
model
training
function value
Prior art date
Application number
PCT/CN2022/116913
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 苏州浪潮智能科技有限公司
Publication of WO2023201963A1 publication Critical patent/WO2023201963A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • 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
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • 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

  • This application relates to the field of artificial intelligence, and in particular to image understanding methods, devices, equipment and media.
  • Image Caption uses a computer system to interpret images to understand the external world just like the human visual system. The purpose is to obtain target information in the image to be detected and use this information to obtain target text data.
  • the social media communication industry is developed. People are expressing personal opinions all the time on domestic social software Douyin and Weibo, as well as foreign social software Twitter and Instagram. These remarks usually appear in the form of pictures and texts, and the text is usually a text explanation related to the image set by the user.
  • the inventor realized that due to the cryptic nature of language, that is, the relationship between images and text is a weak correlation, therefore in this practical situation, there is a problem in the prior art using computational models to try to understand people's social language.
  • Cognitive Impairment The assumption of a strong correlation between text and images is different from the actual social media data, which is caused by humans having richer background knowledge compared to computational models. Therefore, ordinary image understanding methods are still not applicable in social media-oriented scenarios.
  • this application discloses an image understanding method, including:
  • this application discloses an image understanding device, including:
  • the graphic data acquisition module is used to construct the first text data corresponding to the training image based on the original text data corresponding to the training image, and to process the training image using a simple visual language model to obtain the second text data corresponding to the training image. ;
  • the model initialization module is used to construct image-text pairs based on the training image, the first text data and the second text data to obtain the corresponding image-text pair set, and initialize the image understanding model;
  • the model parameter update module is used to select image-text pairs as training data from the image-text pair set, and use the current image understanding model to calculate the overall model loss function value corresponding to the training data, and then perform image understanding based on the overall model loss function value.
  • the parameters in the model are updated;
  • the model determination module is used to jump back to the step of selecting image-text pairs as training data from the image-text pair set when the preset iteration end conditions are not currently met, until the preset iteration end conditions are met, and the current output
  • the image understanding model serves as the target image understanding model
  • the image understanding module is used to use the target image understanding model to obtain target text data corresponding to the image to be detected.
  • this application discloses an electronic device, including: a memory and one or more processors.
  • Computer readable instructions are stored in the memory.
  • the computer readable instructions are executed by the one or more processors, such that The above one or more processors execute the steps of the above disclosed image understanding method.
  • the present application discloses one or more non-volatile computer-readable storage media storing computer-readable instructions.
  • the above-mentioned computer-readable instructions are executed by one or more processors, the above-mentioned one or more processors
  • the processor executes the steps of the aforementioned disclosed image understanding method.
  • Figure 1 is a flow chart of an image understanding method disclosed in this application according to one or more embodiments
  • Figure 2 is a flow chart of a specific first text data construction method disclosed in this application according to one or more embodiments;
  • Figure 3 is a flow chart of a specific image understanding method disclosed in this application according to one or more embodiments.
  • Figure 4 is a flow chart of a specific image understanding method disclosed in this application according to one or more embodiments.
  • Figure 5 is a flow chart of a specific image understanding method disclosed in this application according to one or more embodiments.
  • Figure 6 is a schematic structural diagram of an image understanding device disclosed in this application according to one or more embodiments.
  • Figure 7 is a structural diagram of an electronic device disclosed according to one or more embodiments of this application.
  • this application accordingly provides an image understanding solution, which realizes image understanding that is closer to real application scenarios and can be oriented to social media.
  • an embodiment of the present application discloses an image understanding method.
  • the method is explained by taking its application to computer equipment as an example.
  • the method includes:
  • Step S11 Construct first text data corresponding to the training image based on the original text data corresponding to the training image, and process the training image using a simple visual language model to obtain second text data corresponding to the training image.
  • Original text features that is, using CLIP (Contrastive Language-Image Pre-training) in the image understanding model to obtain the semantic information of the original text data; using the image encoder in the image understanding model to obtain training images global features and shallow features, and calculate the correlation vector between the original text data and the training image based on the original text features, global features and shallow features, and the correlation vector can be used to train the CLIP-based image understanding model; calculation The product of the associated vector and the preset hyperparameter, and the updated text feature is obtained based on the sum of the product and the original text feature, and then the first text data is obtained based on the updated text feature, so that the subsequent text data can be paired based on the first text data and the second text data
  • the image understanding model is tested, in which the preset hyperparameters can be set according
  • Step S12 Construct an image-text pair based on the training image, the first text data and the second text data to obtain a corresponding image-text pair set, and initialize the image understanding model.
  • the training image (I 1 ) corresponds to the first text data (t 1 weak ), and the training image (I 1 ) corresponds to the second text data (t 1 strong ).
  • Step S13 Select the image-text pairs used as training data from the image-text pair set, and use the current image understanding model to calculate the overall model loss function value corresponding to the training data, and then calculate the parameters in the image understanding model based on the overall model loss function value. Make an update.
  • Step S14 Determine whether the preset iteration end condition is currently met. If not, jump back to the step of selecting image-text pairs used as training data from the image-text pair set until the preset iteration end condition is met, and the currently output image
  • the understanding model serves as the target image understanding model.
  • Step S15 Use the target image understanding model to obtain target text data corresponding to the image to be detected.
  • determining whether the preset iteration end condition is currently met may be to determine whether the preset iteration number has been reached. For example, the preset iteration number is 1 million. If the current iteration number has not reached 1 million, jump to The step of selecting image-text pairs used as training data from the image-text pair set. If the number of times reaches 1 million, the training will be stopped. It can be understood that the parameters of the current image understanding model will be updated during each iteration, and the model output by the last iteration is the target image understanding model, and the target image understanding model is used to output the target of the image to be detected. text data.
  • this application first constructs the first text data corresponding to the training image based on the original text data corresponding to the training image, and uses a simple visual language model to process the training image to obtain the second text data corresponding to the training image; based on the training The image, the first text data and the second text data construct an image-text pair to obtain the corresponding image-text pair set, and initialize the image understanding model; select the image-text pair used as training data from the image-text pair set, and use the current
  • the image understanding model calculates the overall model loss function value corresponding to the training data, and then updates the parameters in the image understanding model based on the overall model loss function value; determines whether the preset iteration end conditions are currently met, and if not, jumps back to the image text
  • this application constructs weakly relevant first text data corresponding to the training image based on the original text data corresponding to the training image, so that the subsequent image understanding model can mine the weakly relevant semantic relationship between the training image and the first text data. , obtain rich semantic level supervision; process the training image through a simple visual language model to obtain the second text data that is strongly related to the training image, so that the overall loss of the model can be calculated based on the first text data and the second text data.
  • the embodiment of the present application discloses a specific image understanding method, including:
  • Step S21 Obtain the first text data corresponding to the training image based on the correlation vector between the training image and the original text data and the original feature data of the original text data, and use a simple visual language model to process the training image to obtain the data corresponding to the training image. the second text data.
  • obtaining the first text data corresponding to the training image based on the correlation vector between the training image and the original text data and the original feature data of the original text data specifically includes: obtaining the training image and the original text data corresponding to the training image; Extract the original text features of the original text data, and calculate the correlation vector between the training image and the original text data; use the correlation vector to update the original text features to obtain the first text data.
  • CLIP consisting of two encoders in the image understanding model.
  • the two encoders include an image encoder and a text encoder.
  • the image encoder can be ResNet or ViT (Vision Transformer, visual depth model).
  • the knowledge learned in the process is transferred to the downstream classification task.
  • a simple and effective method is to construct a set of text prompts based on the template, such as "a photo of a [CLS]", where [CLS] can be the category of the actual picture. replace. Then, given an image, CLIP is used to calculate the similarity between the image and the text prompt in the embedding space, and the class with the highest score is used as the final prediction.
  • the text template can be of K categories, and the text template contains a text prompt (prompt), such as "[V] 1 [V] 2 ...[V] M [CLS]” , it should be noted that "[V] 1 [V] 2 ...[V] M " and "[CLS]” are both unfixed words, so the text template is more flexible and close to the actual application scenario;
  • K represents the number of categories
  • C represents the number of channels
  • t represents the updated original text feature
  • t q represents the original text feature
  • represents the hyperparameter
  • v represents the correlation vector
  • calculating the association vector between the training image and the original text data specifically includes: using the image encoder in the image understanding model to calculate the global features and shallow features corresponding to the training image; based on the global features and shallow features features, and use the decoder of the deep model in the image understanding model to calculate the correlation vector between the training image and the original text data.
  • an image encoder needs to be used to extract the feature vector of the training image.
  • the feature map mapping is expressed as Preload CLIP in the image understanding model, and use CLIP to introduce an attention pooling layer (Attention Pooling) in the ResNet (residual network) encoder.
  • CLIP first Perform global average pooling to obtain global features of training images where x 4 represents the feature map of the fourth stage, represents the Euclidean space, H 4 represents the height of the feature map, W 4 represents the width of the feature map, C represents the number of feature map channels, and the connected features containing the feature map and global characteristics are sent to the multi-head attention layer (multi head self attention, That is MHSA), which involves the following formula:
  • z represents shallow features
  • x 4 represents the feature map of the fourth stage.
  • the association vector is obtained based on global features, shallow features and original text features, and the decoder of the deep model is used.
  • a deep model composed of an attention mechanism is used to obtain the association vector, involving the formula as follows:
  • v represents the association vector
  • t represents the original text feature
  • z represents shallow features
  • s represents the pixel text score
  • H 4 represents the height of the feature map
  • W 4 represents the width of the feature map
  • C represents the number of feature map channels.
  • Step S22 Construct an image-text pair based on the training image, the first text data and the second text data to obtain a corresponding image-text pair set, and initialize the image understanding model.
  • Step S23 Select the image-text pairs used as training data from the image-text pair set, and use the current image understanding model to calculate the overall model loss function value corresponding to the training data, and then calculate the parameters in the image understanding model based on the overall model loss function value. Make an update.
  • the parameters in the image understanding model are updated based on the overall model loss function value, which specifically includes: based on the model overall loss function value and the adaptive moment estimation optimizer, and using the gradient descent optimization algorithm to update the parameters of the image understanding model.
  • the overall model loss function value which specifically includes: based on the model overall loss function value and the adaptive moment estimation optimizer, and using the gradient descent optimization algorithm to update the parameters of the image understanding model.
  • Make an update First, use the current image understanding model to calculate the pixel-text matching loss function value and text distance loss function value of the image-text pair, and determine the overall model loss function value based on the pixel-text matching loss function value and text distance loss function value; then based on the overall model loss function value Loss function value and adaptive moment estimation optimizer (Adam), and use gradient descent optimization algorithm to update the parameters of the image understanding model.
  • Adam adaptive moment estimation optimizer
  • Step S24 Determine whether the preset iteration end condition is currently met. If not, jump back to the step of selecting image-text pairs used as training data from the image-text pair set until the preset iteration end condition is met, and the currently output image
  • the understanding model serves as the target image understanding model.
  • Step S25 Use the target image understanding model to obtain target text data corresponding to the image to be detected.
  • this application constructs the first text data weakly related to the training image based on the original text data corresponding to the training image and its original text features. It not only uses the second text data strongly related to the training image as the training data, but also uses the second text data that is strongly related to the training image as the training data. On the one hand, it avoids the inaccuracy of the training data due to the difference between the second text data and the actual text data. On the other hand, using the weakly related first text data can enrich the weakly related semantic relationship between the image and the text and the semantic level supervision. , more flexible and more realistic.
  • the embodiment of the present application discloses a specific image understanding method, including:
  • Step S31 Construct first text data corresponding to the training image based on the original text data corresponding to the training image, and process the training image using a simple visual language model to obtain second text data corresponding to the training image.
  • the images published in social networking sites and the text corresponding to the images are first crawled as training images and original text data respectively.
  • the "round cake” picture is obtained as the training image
  • the corresponding original text data " "Happy birthday, Make a wish” obtain the "dog and man” picture as a training image
  • the corresponding original text data "We are friends forever” obtain the original text data "We are friends forever”.
  • the original text data "We are friends forever” and the corresponding training images are input into the image understanding model.
  • the text encoder in the image understanding model will be based on the preset K category text templates and the text templates.
  • the included text prompt obtains the first text data "The man is sitting with his dog” corresponding to the original text data, so that the first text data can be subsequently used to calculate the pixel text matching loss function value and the text distance loss function value.
  • Step S32 Construct an image-text pair based on the training image, the first text data and the second text data to obtain a corresponding image-text pair set, and initialize the image understanding model.
  • Step S33 Select the image-text pair used as training data from the image-text pair set, and use the current image understanding model to calculate the pixel-text matching loss function value and text distance loss function value of the image-text pair.
  • the current image understanding model is used to calculate the pixel-text matching loss function value and text distance loss function value of the image-text pair, which specifically includes: calculating and image-text centering training through the image encoder in the current image understanding model.
  • the shallow features corresponding to the image based on the shallow features, the first text feature of the first text data in the image-text pair and the second text feature of the second text data, and use the image understanding model to calculate the pixel-text matching loss of the image-text pair Function value and text distance loss function value.
  • the image understanding model to calculate the pixel-text matching loss function value of the image-text pair and the text distance loss function value, which may specifically include: using an image understanding model to determine the regularized first text feature and the regularized second text feature; using shallow features, the regularized first text feature and the regularized second text feature to calculate the pixel-text matching loss function value of the image-text pair, and use the regularized first text feature and the regularized second text feature to calculate the pixel-text matching loss function value of the image-text pair. Text distance loss function value.
  • L p&t represents the pixel text matching loss function value
  • t strong represents the text feature of the second text data
  • t weak represents the text feature of the first text data
  • T represents the transposition
  • L t represents the text distance loss function value
  • Step S34 Determine the overall loss function value of the model based on the pixel-text matching loss function value and the text distance loss function value, and update the parameters in the image understanding model based on the overall model loss function value.
  • the sum of the pixel-text matching loss function value and the text distance loss function value is calculated, and the sum of the pixel-text matching loss function value and the text distance loss function value is used as the overall loss function value of the model, where the calculation formula is as follows:
  • L represents the overall loss function value of the model
  • L p&t represents the pixel text matching loss function value
  • L t represents the text distance loss function value
  • Step S35 Determine whether the preset iteration end condition is currently met. If not, jump back to the step of selecting image-text pairs used as training data from the image-text pair set until the preset iteration end condition is met, and the currently output image
  • the understanding model serves as the target image understanding model.
  • Step S36 Use the target image understanding model to obtain target text data corresponding to the image to be detected.
  • this application uses the current image understanding model to calculate the pixel-text matching loss function value and text distance loss function value of the image-text pair, and determines the overall loss function value of the model based on the pixel-text matching loss function value and the text distance loss function value. , and then update the parameters in the image understanding model based on the overall loss function value of the model to optimize the image understanding model until the preset iteration end conditions are met, and the optimal target image understanding model is obtained, so that the target image understanding model can be obtained Target text data corresponding to the image to be detected.
  • an image understanding device which includes:
  • the graphic data acquisition module 11 is configured to construct first text data corresponding to the training image based on the original text data corresponding to the training image, and process the training image using a simple visual language model to obtain the second text corresponding to the training image. data;
  • the model initialization module 12 is used to construct an image-text pair based on the training image, the first text data and the second text data to obtain the corresponding image-text pair set, and initialize the image understanding model;
  • the model parameter update module 13 is used to select image-text pairs used as training data from the image-text pair set, and use the current image understanding model to calculate the model overall loss function value corresponding to the training data, and then calculate the image based on the model overall loss function value. Understand the parameters in the model and update them;
  • the model determination module 14 is used to determine whether the preset iteration end condition is currently met, and if not, jump back to the step of selecting image-text pairs used as training data from the image-text pair set, until the preset iteration end condition is met, and The currently output image understanding model is used as the target image understanding model.
  • the image understanding module 15 is configured to use the target image understanding model to obtain target text data corresponding to the image to be detected.
  • this application first constructs the first text data corresponding to the training image based on the original text data corresponding to the training image, and uses a simple visual language model to process the training image to obtain the second text data corresponding to the training image; based on the training The image, the first text data and the second text data construct an image-text pair to obtain the corresponding image-text pair set, and initialize the image understanding model; select the image-text pair used as training data from the image-text pair set, and use the current
  • the image understanding model calculates the overall model loss function value corresponding to the training data, and then updates the parameters in the image understanding model based on the overall model loss function value; determines whether the preset iteration end conditions are currently met, and if not, jumps back to the image text The step of selecting image-text pairs used as training data until the preset iteration end conditions are met, and using the currently output image understanding model as the target image understanding model, so as to use the target image understanding model to obtain the target corresponding to the image to be detected.
  • this application constructs weakly relevant first text data corresponding to the training image based on the original text data corresponding to the training image, so that the subsequent image understanding model can mine the weakly relevant semantic relationship between the training image and the first text data. , obtain rich semantic level supervision; process the training image through a simple visual language model to obtain the second text data that is strongly related to the training image, so that the overall loss of the model can be calculated based on the first text data and the second text data.
  • FIG. 7 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • the electronic device may be a computer device, and the computer device may be a terminal or a server. Specifically, it may include: at least one processor 21, at least one memory 22, power supply 23, communication interface 24, input and output interface 25 and communication bus 26.
  • the memory 22 is used to store computer readable instructions, which are loaded and executed by the processor 21 to implement the relevant steps in the image understanding method executed by the computer device disclosed in any of the foregoing embodiments.
  • the power supply 23 is used to provide operating voltage for each hardware device on the computer device 20;
  • the communication interface 24 can create a data transmission channel between the computer device 20 and external devices, and the communication protocol it follows can be applicable Any communication protocol of the technical solution of this application is not specifically limited here;
  • the input and output interface 25 is used to obtain external input data or output data to the external world, and its specific interface type can be selected according to specific application needs. Here Not specifically limited.
  • the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc.
  • the processor 21 can adopt at least one hardware form among DSP (Digital Signal Processing, digital signal processing), FPGA (Field-Programmable Gate Array, field programmable gate array), and PLA (Programmable Logic Array, programmable logic array).
  • the processor 21 may also include a main processor and a co-processor.
  • the main processor is a processor used to process data in the wake-up state, also called CPU (Central Processing Unit, central processing unit); the co-processor is A low-power processor used to process data in standby mode.
  • the processor 21 may be integrated with a GPU (Graphics Processing Unit, image processor), and the GPU is responsible for rendering and drawing the content that needs to be displayed on the display screen.
  • the processor 21 may also include an AI (Artificial Intelligence, artificial intelligence) processor, which is used to process computing operations related to machine learning.
  • AI Artificial Intelligence, artificial intelligence
  • the memory 22, as a carrier for resource storage can be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc.
  • the resources stored thereon include the operating system 221, computer readable instructions 222 and data 223, etc., and the storage method can be short-term. Storage or permanent storage.
  • the operating system 221 is used to manage and control each hardware device and computer readable instructions 222 on the computer device 20 to realize the operation and processing of the massive data 223 in the memory 22 by the processor 21. It can be Windows, Unix, Linux wait.
  • the computer-readable instructions 222 may further include computer-readable instructions that can be used to complete other specific tasks. instruction.
  • the data 223 may also include data collected by its own input and output interface 25, etc.
  • embodiments of the present application also disclose a computer-readable storage medium.
  • Computer-readable instructions are stored in the storage medium.
  • the image processing disclosed in any of the foregoing embodiments is realized. Understand the methodological steps performed in the process.
  • embodiments of the present application also provide a non-volatile computer-readable storage medium.
  • Computer-readable instructions are stored in the non-volatile computer-readable storage medium.
  • the computer-readable instructions are processed by one or more processors. When executed, the disclosed method steps executed in the image understanding process in any of the above embodiments may be implemented.
  • Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • Volatile memory may include random access memory (RAM) or external cache memory.
  • RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Synchlink DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
  • SRAM static RAM
  • DRAM dynamic RAM
  • SDRAM synchronous DRAM
  • DDRSDRAM double data rate SDRAM
  • ESDRAM enhanced SDRAM
  • SLDRAM synchronous chain Synchlink DRAM
  • Rambus direct RAM
  • DRAM direct memory bus dynamic RAM
  • RDRAM memory bus dynamic RAM

Landscapes

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

Abstract

本申请公开了一种图像理解方法、装置、设备及介质,涉及人工智能领域,包括:基于训练图像对应的原始文本数据构建与训练图像对应的第一文本数据,利用简单视觉语言模型得到第二文本数据;基于训练图像、第一文本数据和第二文本数据构建图像文本对集,初始化图像理解模型;从图像文本对集中选取用作训练数据的图像文本对,利用当前的图像理解模型计算训练数据对应的模型总体损失函数值,对图像理解模型中的参数进行更新;判断当前是否满足结束条件,若否则跳转至从图像文本对集中选取用作训练数据的图像文本对的步骤,直到满足结束条件,利用当前输出的图像理解模型获取与待检测图像对应的目标文本数据。

Description

图像理解方法、装置、设备及介质
相关申请的交叉引用
本申请要求于2022年04月18日提交中国专利局,申请号为202210401296.2,申请名称为“图像理解方法、装置、设备及介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及人工智能领域,特别涉及图像理解方法、装置、设备及介质。
背景技术
图像理解(Image Caption)通过计算机系统来解释图像,实现犹如人类视觉系统理解外部世界,其目的是在待检测图像中获取目标信息并利用该信息以得到目标文本数据。当前社交媒体通讯业发达,人们在国内社交软件抖音、微博,以及国外社交软件推特、Instagram等,无时无刻不在发表着个人言论。这些言论通常是以图文形式绑定出现,此时文字通常是用户设定的与图像相关的文本解释。然而,发明人意识到,由于语言具有隐晦的性质,即图像与文本之间的关系为弱相关关系,因此在这种实际情况下,现有技术中使用计算模型试图理解人们的社交语言存在着认知障碍,文本与图像之间的强相关假设与实际社交媒体数据存在差异,这是由于人类相较于计算模型拥有更丰富的背景知识所导致的。因此,普通的图像理解方法依然无法适用在面向社交媒体的场景中。
综上可见,如何实现更加贴近真实的应用场景并且能够面向社交媒体的图像理解是本领域有待解决的问题。
发明内容
第一方面,本申请公开了一种图像理解方法,包括:
基于训练图像对应的原始文本数据构建与训练图像对应的第一文本数据,并利用简单视觉语言模型对训练图像进行处理,以得到与训练图像对应的第二文本数据;
基于训练图像、第一文本数据和第二文本数据构建图像文本对,以得到相应的图像文本对集,并初始化图像理解模型;
从图像文本对集中选取用作训练数据的图像文本对,并利用当前的图像理解模型计算训练数据对应的模型总体损失函数值,然后基于模型总体损失函数值对图像理解模型中的参数进行更新;
在当前未满足预设迭代结束条件时,重新跳转至从图像文本对集中选取用作训练数据的图像文本对的步骤,直到满足预设迭代结束条件,并将当前输出的图像理解模型作为目标图像理解模型;和
利用目标图像理解模型获取与待检测图像对应的目标文本数据。
第二方面,本申请公开了一种图像理解装置,包括:
图文数据获取模块,用于基于训练图像对应的原始文本数据构建与训练图像对应的第一文本数据,并利用简单视觉语言模型对训练图像进行处理,以得到与训练图像对应的第二文本数据;
模型初始化模块,用于基于训练图像、第一文本数据和第二文本数据构建图像文本对,以得到相应的图像文本对集,并初始化图像理解模型;
模型参数更新模块,用于从图像文本对集中选取用作训练数据的图像文本对,并利用当前的图像理解模型计算训练数据对应的模型总体损失函数值,然后基于模型总体损失函数值对图像理解模型中的参数进行更新;
模型确定模块,用于在当前未满足预设迭代结束条件时,重新跳转至从图像文本对集中选取用作训练数据的图像文本对的步骤,直到满足预设迭代结束条件,并将当前输出的图像理解模型作为目标图像理解模型;和
图像理解模块,用于利用目标图像理解模型获取与待检测图像对应的目标文本数据。
第三方面,本申请公开了一种电子设备,包括:存储器及一个或多个处理器,存储器中储存有计算机可读指令,上述计算机可读指令被上述一个或多个处理器执行时,使得上述一个或多个处理器执行上述公开的图像理解方法的步骤。
第四方面,本申请公开了一个或多个存储有计算机可读指令的非易失性计算机可读存储介质,上述计算机可读指令被一个或多个处理器执行时,使得上述一个或多个处理器执行前述公开的图像理解方法的步骤。
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其它特征和优点将从说明书、附图以及权利要求书变得明显。
附图说明
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据提供的附图获得其他的附图。
图1为本申请根据一个或多个实施例公开的一种图像理解方法流程图;
图2为本申请根据一个或多个实施例公开的一种具体的第一文本数据构建方法流程图;
图3为本申请根据一个或多个实施例公开的一种具体的图像理解方法流程图;
图4为本申请根据一个或多个实施例公开的一种具体的图像理解方法流程图;
图5为本申请根据一个或多个实施例公开的一种具体的图像理解方法流程图;
图6为本申请根据一个或多个实施例公开的一种图像理解装置结构示意图;
图7为本申请根据一个或多个实施例公开的一种电子设备结构图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
现有技术中使用计算模型试图理解人们的社交语言存在着认知障碍,文本与图像之间的强相关假设与实际社交媒体数据存在差异,这是由于人类相较于计算模型拥有更丰富的背景知识所导致的。因此,普通的图像理解方法依然无法适用在面向社交媒体的场景中。
为此本申请相应的提供了一种图像理解方案,实现了更加贴近真实的应用场景并且能够面向社交媒体的图像理解。
参见图1所示,本申请实施例公开了一种图像理解方法,该方法以应用于计算机设备为例进行说明,该方法包括:
步骤S11:基于训练图像对应的原始文本数据构建与训练图像对应的第一文本数据,并利用简单视觉语言模型对训练图像进行处理,以得到与训练图像对应的第二文本数据。
本实施例中,参见图2所示的第一文本数据构建方法流程图,首先爬取社交网站中以及公开发布的图像作为训练图像,以及与图像对应的原始文本数据,提取原始文本数据中的原始文本特征,即使用图像理解模型中的CLIP(Contrastive Language-Image Pre-training,即对 比语言-图像预训练模型)获取原始文本数据的语义信息;利用图像理解模型中的图像编码器获取训练图像的全局特征和浅层特征,并基于原始文本特征、全局特征以及浅层特征计算出原文本数据和训练图像之间的关联向量,并且可以利用关联向量对基于CLIP的图像理解模型进行训练;计算关联向量与预设超参的乘积,并基于乘积与原始文本特征的和获取更新后文本特征,然后基于更新后文本特征得到第一文本数据,以便后续基于第一文本数据和第二文本数据对图像理解模型进行测试,其中预设超参可以根据实际情况进行设置,例如可以设置为0.05或0.1。可以理解的是,第一文本数据与训练图像之间为弱相关,因此构建了弱相关的监督数据集,后续能够在此基础上挖掘图像与文本之间的弱相关语义关系,获得丰富的语义层次监督。将训练图像送入简单视觉语言模型中,获取与训练图像为强相关的第二文本数据,并且在获取第二本文数据过程中,还利用目前SOTA(State-Of-The-Art,即最先进)的图像理解方法,对训练图像进行标注。
步骤S12:基于训练图像、第一文本数据和第二文本数据构建图像文本对,以得到相应的图像文本对集,并初始化图像理解模型。
本实施例中,基于训练图像{I 1,I 2,…I n}、第一文本数据{t 1 weak,t 2 weak,…t n weak}以及第二文本数据{t 1 strong,t 2 strong,…t n strong}构建图像文本对{(I 1,t 1 weak,t 1 strong)、(I 2,t 2 weak,t 2 strong)、…(I n,t n weak,t n strong)},其中可以理解的是,训练图像(I 1)与第一文本数据(t 1 weak)相对应,训练图像(I 1)与第二文本数据(t 1 strong)相对应。
步骤S13:从图像文本对集中选取用作训练数据的图像文本对,并利用当前的图像理解模型计算训练数据对应的模型总体损失函数值,然后基于模型总体损失函数值对图像理解模型中的参数进行更新。
本实施例中,从图像文本对集{(I 1,t 1 weak,t 1 strong)、(I 2,t 2 weak,t 2 strong)、…(I n,t n weak,t n strong)}中选取用作训练数据的图像文本对;利用当前的图像理解模型计算训练数据对应的像素文本匹配损失函数值(Pixe-Text Matching Loss)和文本距离损失函数值(Text Distance Loss),并基于像素文本匹配损失函数值以及文本距离损失函数值确定模型总体损失函数值。
步骤S14:判断当前是否满足预设迭代结束条件,如果否则重新跳转至从图像文本对集中选取用作训练数据的图像文本对的步骤,直到满足预设迭代结束条件,并将当前输出的图像理解模型作为目标图像理解模型。
步骤S15:利用目标图像理解模型获取与待检测图像对应的目标文本数据。
本实施例中,判断当前是否满足预设迭代结束条件,可以为判断当前是否到达预设迭代次数,例如预设迭代次数为100万次,如果当前迭代次数未到达100万次则重新跳转至从图像文本对集中选取用作训练数据的图像文本对的步骤,若到达100万次,则停止训练。可以理解的是,在每一次迭代的过程中都会对当前的图像理解模型的参数进行更新,而最后一次迭代输出的模型即为目标图像理解模型,并利用目标图像理解模型输出待检测图像的目标文本数据。
可见,本申请首先基于训练图像对应的原始文本数据构建与训练图像对应的第一文本数据,并利用简单视觉语言模型对训练图像进行处理,以得到与训练图像对应的第二文本数据;基于训练图像、第一文本数据和第二文本数据构建图像文本对,以得到相应的图像文本对集,并初始化图像理解模型;从图像文本对集中选取用作训练数据的图像文本对,并利用当前的图像理解模型计算训练数据对应的模型总体损失函数值,然后基于模型总体损失函数值对图像理解模型中的参数进行更新;判断当前是否满足预设迭代结束条件,如果否则重新跳转至从图像文本对集中选取用作训练数据的图像文本对的步骤,直到满足预设迭代结束条件,并将当前输出的图像理解模型作为目标图像理解模型,以便利用目标图像理解模型获取与待检测图像对应的目标文本数据。
由此可见,本申请通过基于训练图像对应的原始文本数据构建与训练图像对应的弱相关的第一文本数据,以便后续图像理解模型能够挖掘训练图像和第一文本数据之间的弱相关语义关系,获得丰富的语义层次监督;通过简单视觉语言模型对训练图像进行处理,以得到与训练图像对应的强相关的第二文本数据,以便后续基于第一文本数据和第二文本数据计算模型总体损失函数值;基于模型总体损失函数值对图像理解模型中的参数进行更新,实现对图像理解模型进行优化,直至满足预设迭代结束条件,得到最优的目标图像理解模型,以便利用目标图像理解模型获取与待检测图像对应的目标文本数据,完成了更加贴近真实应用场景并可拓展至面向社交媒体的图像理解,又由于在得到目标图像理解模型过程中为端到端方法,所以更加容易落地实施。
参见图3所示,本申请实施例公开了一种具体的图像理解方法,包括:
步骤S21:基于训练图像与原始文本数据的关联向量以及原始文本数据的原始特征数据获取与训练图像对应的第一文本数据,并利用简单视觉语言模型对训练图像进行处理,以得到与训练图像对应的第二文本数据。
本实施例中,基于训练图像与原始文本数据的关联向量以及原始文本数据的原始特征数据获取与训练图像对应的第一文本数据,具体包括:获取训练图像以及与训练图像对应的原 始文本数据;提取原始文本数据的原始文本特征,并计算训练图像和原始文本数据之间的关联向量;利用关联向量对原始文本特征进行更新,以得到第一文本数据。在图像理解模型中引入由两个编码器组成的CLIP,其中两个编码器包括图像编码器和文本编码器,图像编码器可以为ResNet或ViT(Vision Transformer,即视觉深度模型),为了将CLIP中学习到的知识转移到下游的分类任务,一种简单而有效的方法是基于模板构造一组文本提示prompt,如“a photo of a[CLS]”,其中[CLS]可以被实际图片的类别替换。然后给定一幅图像,利用CLIP计算出该图像在嵌入空间中与文本提示符的相似度,以得分最高的类作为最终的预测。在预先构造第一文本数据的文本模板时,文本模板可以为K个类别,并且文本模板中包含文本提示(prompt),例如“[V] 1[V] 2…[V] M[CLS]”,需要注意的是,“[V] 1[V] 2…[V] M”以及“[CLS]”均为不固定的词语,因此文本模板更加灵活,贴近实际应用场景;获取文本特征,可以利用图像理解模型中的文本编码器提取原始文本数据的文本特征
Figure PCTCN2022116913-appb-000001
K表示类别个数,C表示通道数,
Figure PCTCN2022116913-appb-000002
表示欧式空间,其中利用关联向量对原始文本特征进行更新所涉及的公式如下:
t←t q+γv;
其中,t表示更新后的原始文本特征,t q表示原始文本特征,γ表示超参数,v表示关联向量。
本实施例中,计算训练图像和原始文本数据之间的关联向量,具体包括:利用图像理解模型中的图像编码器计算出与训练图像对应的全局特征和浅层特征;基于全局特征和浅层特征,并利用图像理解模型中的深度模型的解码器计算出训练图像和原始文本数据之间的关联向量。
本实施例中,在获取全局特征和浅层特征过程中,需要利用图像编码器提取训练图像的特征向量,例如以ResNet编码器为例,总共有4个阶段,将特征图映射表示为
Figure PCTCN2022116913-appb-000003
在图像理解模型中预加载CLIP,利用CLIP在ResNet(residual network,即残差网络)编码器中引入一个注意力池化层(Attention Pooling),CLIP首先对
Figure PCTCN2022116913-appb-000004
执行全局平均池,以获取训练图像的全局特性
Figure PCTCN2022116913-appb-000005
其中x 4表示第四阶段的特征图,
Figure PCTCN2022116913-appb-000006
表示 欧式空间,H 4表示特征图的高度,W 4表示特征图的宽度,C表示特征图通道数,并将包含特征图和全局特性的连接特征送入多头注意力层(multi head self attention,即MHSA),其中涉及公式如下:
Figure PCTCN2022116913-appb-000007
其中,
Figure PCTCN2022116913-appb-000008
表示全局特征,z表示浅层特征,
Figure PCTCN2022116913-appb-000009
表示第四阶段的全局特性,x 4表示第四阶段的特征图。
本实施例中,基于全局特征、浅层特征以及原始文本特征,并利用深度模型的解码器获取关联向量,例如利用一种由注意力机制组成的深度模型(Transformer),获取关联向量,涉及公式如下:
Figure PCTCN2022116913-appb-000010
其中,v表示关联向量,t表示原始文本特征,
Figure PCTCN2022116913-appb-000011
表示全局特征,z表示浅层特征。
本实施例中,获取到更新后文本特征、浅层特征,以便后续计算像素文本得分,其中涉及公式如下:
Figure PCTCN2022116913-appb-000012
其中,s表示像素文本得分,
Figure PCTCN2022116913-appb-000013
表示经过L 2正则化后的浅层特征,
Figure PCTCN2022116913-appb-000014
表示经过L 2正则化后的更新后的原始文本特征,
Figure PCTCN2022116913-appb-000015
表示欧式空间,H 4表示特征图的高度,W 4表示特征图的宽度,C表示特征图通道数。
步骤S22:基于训练图像、第一文本数据和第二文本数据构建图像文本对,以得到相应的图像文本对集,并初始化图像理解模型。
步骤S23:从图像文本对集中选取用作训练数据的图像文本对,并利用当前的图像理解模型计算训练数据对应的模型总体损失函数值,然后基于模型总体损失函数值对图像理解模型中的参数进行更新。
本实施例中,基于模型总体损失函数值对图像理解模型中的参数进行更新,具体包括:基于模型总体损失函数值和自适应矩估计优化器,并利用梯度下降优化算法对图像理解模型 的参数进行更新。首先利用当前的图像理解模型计算图像文本对的像素文本匹配损失函数值和文本距离损失函数值,并基于像素文本匹配损失函数值以及文本距离损失函数值确定模型总体损失函数值;然后基于模型总体损失函数值和自适应矩估计优化器(Adam),并利用梯度下降优化算法对图像理解模型的参数进行更新。
步骤S24:判断当前是否满足预设迭代结束条件,如果否则重新跳转至从图像文本对集中选取用作训练数据的图像文本对的步骤,直到满足预设迭代结束条件,并将当前输出的图像理解模型作为目标图像理解模型。
步骤S25:利用目标图像理解模型获取与待检测图像对应的目标文本数据。
由此可见,本申请根据与训练图像对应的原始文本数据及其原始文本特征构建与训练图像弱相关的第一文本数据,不仅仅以与训练图像强相关的第二文本数据为训练数据,第一方面避免了因第二文本数据与实际文本数据存在差异而导致训练数据的不准确,第二方面利用弱相关的第一文本数据能够丰富图像与文本之间的弱相关语义关系以及语义层次监督,更加灵活,更加符合实际。
参见图4所示,本申请实施例公开了一种具体的图像理解方法,包括:
步骤S31:基于训练图像对应的原始文本数据构建与训练图像对应的第一文本数据,并利用简单视觉语言模型对训练图像进行处理,以得到与训练图像对应的第二文本数据。
本实施例中,首先爬取社交网站中公开的图像以及与图像对应的文本,分别作为训练图像以及原始文本数据,例如,获取“圆蛋糕”图片作为训练图像,与之对应的原始文本数据“Happy birthday,Make a wish”,获取“狗和男人”图片作为训练图像,与之对应的原始文本数据“We are friends forever”。例如图5所示,将原始文本数据“We are friends forever”以及对应的训练图像输入至图像理解模型中,图像理解模型中的文本编码器会基于预设的K个类别文本模板以及文本模板中包含的文本提示获取与原始文本数据对应的第一文本数据“The man is sitting with his dog”,以便后续利用第一文本数据计算像素文本匹配损失函数值和文本距离损失函数值。
步骤S32:基于训练图像、第一文本数据和第二文本数据构建图像文本对,以得到相应的图像文本对集,并初始化图像理解模型。
步骤S33:从图像文本对集中选取用作训练数据的图像文本对,并利用当前的图像理解模型计算图像文本对的像素文本匹配损失函数值和文本距离损失函数值。
本实施例中,利用当前的图像理解模型计算图像文本对的像素文本匹配损失函数值和文本距离损失函数值,具体包括:通过当前的图像理解模型中的图像编码器计算与图像文本对中训练图像对应的浅层特征;基于浅层特征、图像文本对中第一文本数据的第一文本特征以及第二文本数据的第二文本特征,并利用图像理解模型计算图像文本对的像素文本匹配损失函数值和文本距离损失函数值。
本实施例中,基于浅层特征、图像文本对中第一文本数据的第一文本特征以及第二文本数据的第二文本特征,并利用图像理解模型计算图像文本对的像素文本匹配损失函数值和文本距离损失函数值,具体可以包括:利用图像理解模型确定经过正则化处理的第一文本特征以及经过正则化处理的第二文本特征;通过浅层特征、经过正则化处理的第一文本特征和经过正则化处理的第二文本特征计算出图像文本对的像素文本匹配损失函数值,并利用经过正则化处理的第一文本特征和经过正则化处理的第二文本特征计算出图像文本对的文本距离损失函数值。
其中,像素文本匹配损失函数(Pixe-Text Matching Loss)值计算公式如下:
Figure PCTCN2022116913-appb-000016
其中,L p&t表示像素文本匹配损失函数值,t strong表示第二文本数据的文本特征,t weak表示第一文本数据的文本特征,
Figure PCTCN2022116913-appb-000017
表示经过L 2正则化后的第二文本数据的文本特征,
Figure PCTCN2022116913-appb-000018
表示经过L 2正则化后的第一文本数据的文本特征,
Figure PCTCN2022116913-appb-000019
表示经过L 2正则化后的浅层特征,T表示转置。
其中,文本距离损失函数(Text Distance Loss)值计算公式如下:
Figure PCTCN2022116913-appb-000020
其中,L t表示文本距离损失函数值,
Figure PCTCN2022116913-appb-000021
表示经过L 2正则化后的第二文本数据的文本特征,
Figure PCTCN2022116913-appb-000022
表示经过L 2正则化后的第一文本数据的文本特征。
步骤S34:基于像素文本匹配损失函数值以及文本距离损失函数值确定模型总体损失函数值,并基于模型总体损失函数值对图像理解模型中的参数进行更新。
本实施例中,计算像素文本匹配损失函数值与文本距离损失函数值的和,并将像素文本匹配损失函数值与文本距离损失函数值的和作为模型总体损失函数值,其中计算公式如下:
L=L p&t+L t
其中,L表示模型总体损失函数值,L p&t表示像素文本匹配损失函数值,L t表示文本距离损失函数值。
步骤S35:判断当前是否满足预设迭代结束条件,如果否则重新跳转至从图像文本对集中选取用作训练数据的图像文本对的步骤,直到满足预设迭代结束条件,并将当前输出的图像理解模型作为目标图像理解模型。
步骤S36:利用目标图像理解模型获取与待检测图像对应的目标文本数据。
由此可见,本申请利用当前的图像理解模型计算图像文本对的像素文本匹配损失函数值和文本距离损失函数值,并基于像素文本匹配损失函数值以及文本距离损失函数值确定模型总体损失函数值,进而基于模型总体损失函数值对图像理解模型中的参数进行更新,实现对图像理解模型进行优化,直至满足预设迭代结束条件,得到最优的目标图像理解模型,以便利用目标图像理解模型获取与待检测图像对应的目标文本数据。
参见图6所示,本申请实施例公开了一种图像理解装置,包括:
图文数据获取模块11,用于基于训练图像对应的原始文本数据构建与训练图像对应的第一文本数据,并利用简单视觉语言模型对训练图像进行处理,以得到与训练图像对应的第二文本数据;
模型初始化模块12,用于基于训练图像、第一文本数据和第二文本数据构建图像文本对,以得到相应的图像文本对集,并初始化图像理解模型;
模型参数更新模块13,用于从图像文本对集中选取用作训练数据的图像文本对,并利用当前的图像理解模型计算训练数据对应的模型总体损失函数值,然后基于模型总体损失函数值对图像理解模型中的参数进行更新;
模型确定模块14,用于判断当前是否满足预设迭代结束条件,如果否则重新跳转至从图像文本对集中选取用作训练数据的图像文本对的步骤,直到满足预设迭代结束条件,并将当前输出的图像理解模型作为目标图像理解模型。
图像理解模块15,用于利用目标图像理解模型获取与待检测图像对应的目标文本数据。
可见,本申请首先基于训练图像对应的原始文本数据构建与训练图像对应的第一文本数据,并利用简单视觉语言模型对训练图像进行处理,以得到与训练图像对应的第二文本数据;基于训练图像、第一文本数据和第二文本数据构建图像文本对,以得到相应的图像文本对集,并初始化图像理解模型;从图像文本对集中选取用作训练数据的图像文本对,并利用当前的图像理解模型计算训练数据对应的模型总体损失函数值,然后基于模型总体损失函数值对图像理解模型中的参数进行更新;判断当前是否满足预设迭代结束条件,如果否则重新跳转至从图像文本对集中选取用作训练数据的图像文本对的步骤,直到满足预设迭代结束条件,并将当前输出的图像理解模型作为目标图像理解模型,以便利用目标图像理解模型获取与待检测图像对应的目标文本数据。由此可见,本申请通过基于训练图像对应的原始文本数据构建与训练图像对应的弱相关的第一文本数据,以便后续图像理解模型能够挖掘训练图像和第一文本数据之间的弱相关语义关系,获得丰富的语义层次监督;通过简单视觉语言模型对训练图像进行处理,以得到与训练图像对应的强相关的第二文本数据,以便后续基于第一文本数据和第二文本数据计算模型总体损失函数值;基于模型总体损失函数值对图像理解模型中的参数进行更新,实现对图像理解模型进行优化,直至满足预设迭代结束条件,得到最优的目标图像理解模型,以便利用目标图像理解模型获取与待检测图像对应的目标文本数据,完成了更加贴近真实应用场景并可拓展至面向社交媒体的图像理解,又由于在得到目标图像理解模型过程中为端到端方法,所以更加容易落地实施。
图7为本申请实施例提供的一种电子设备的结构示意图,该电子设备可以是计算机设备,计算机设备可以是终端或服务器。具体可以包括:至少一个处理器21、至少一个存储器22、电源23、通信接口24、输入输出接口25和通信总线26。其中,存储器22用于存储计算机可读指令,计算机可读指令由处理器21加载并执行,以实现前述任一实施例公开的由计算机设备执行的图像理解方法中的相关步骤。
本实施例中,电源23用于为计算机设备20上的各硬件设备提供工作电压;通信接口24能够为计算机设备20创建与外界设备之间的数据传输通道,其所遵循的通信协议是能够适 用于本申请技术方案的任意通信协议,在此不对其进行具体限定;输入输出接口25,用于获取外界输入数据或向外界输出数据,其具体的接口类型可以根据具体应用需要进行选取,在此不进行具体限定。
其中,处理器21可以包括一个或多个处理核心,比如4核心处理器、8核心处理器等。处理器21可以采用DSP(Digital Signal Processing,数字信号处理)、FPGA(Field-Programmable Gate Array,现场可编程门阵列)、PLA(Programmable Logic Array,可编程逻辑阵列)中的至少一种硬件形式来实现。处理器21也可以包括主处理器和协处理器,主处理器是用于对在唤醒状态下的数据进行处理的处理器,也称CPU(Central Processing Unit,中央处理器);协处理器是用于对在待机状态下的数据进行处理的低功耗处理器。在一些实施例中,处理器21可以在集成有GPU(Graphics Processing Unit,图像处理器),GPU用于负责显示屏所需要显示的内容的渲染和绘制。一些实施例中,处理器21还可以包括AI(Artificial Intelligence,人工智能)处理器,该AI处理器用于处理有关机器学习的计算操作。
另外,存储器22作为资源存储的载体,可以是只读存储器、随机存储器、磁盘或者光盘等,其上所存储的资源包括操作系统221、计算机可读指令222及数据223等,存储方式可以是短暂存储或者永久存储。
其中,操作系统221用于管理与控制计算机设备20上的各硬件设备以及计算机可读指令222,以实现处理器21对存储器22中海量数据223的运算与处理,其可以是Windows、Unix、Linux等。计算机可读指令222除了包括能够用于完成前述任一实施例公开的由计算机设备20执行的图像理解方法的计算机可读指令之外,还可以进一步包括能够用于完成其他特定工作的计算机可读指令。数据223除了可以包括计算机设备接收到的由外部设备传输进来的数据,也可以包括由自身输入输出接口25采集到的数据等。
进一步的,本申请实施例还公开了一种计算机可读存储介质,存储介质中存储有计算机可读指令,计算机可读指令被处理器加载并执行时,实现前述任一实施例公开的由图像理解过程中执行的方法步骤。
此外,本申请实施例还提供一种非易失性计算机可读存储介质,该非易失性计算机可读存储介质中存储有计算机可读指令,该计算机可读指令被一个或多个处理器执行时可实现上述任意一个实施例的公开的由图像理解过程中执行的方法步骤。
最后,还需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括上述要素的过程、方法、物品或者设备中还存在另外的相同要素。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机可读指令来指令相关的硬件来完成,上述的计算机可读指令可存储于一非易失性计算机可读取存储介质中,该计算机可读指令在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。
以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。
以上上述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对申请专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。

Claims (20)

  1. 一种图像理解方法,其特征在于,包括:
    基于训练图像对应的原始文本数据构建与所述训练图像对应的第一文本数据,并利用简单视觉语言模型对所述训练图像进行处理,以得到与所述训练图像对应的第二文本数据;
    基于所述训练图像、所述第一文本数据和所述第二文本数据构建图像文本对,以得到相应的图像文本对集,并初始化图像理解模型;
    从所述图像文本对集中选取用作训练数据的所述图像文本对,并利用当前的所述图像理解模型计算所述训练数据对应的模型总体损失函数值,然后基于所述模型总体损失函数值对所述图像理解模型中的参数进行更新;
    在当前未满足预设迭代结束条件时,重新跳转至所述从所述图像文本对集中选取用作训练数据的所述图像文本对的步骤,直到满足所述预设迭代结束条件,并将当前输出的所述图像理解模型作为目标图像理解模型;和
    利用所述目标图像理解模型获取与待检测图像对应的目标文本数据。
  2. 根据权利要求1所述的图像理解方法,其特征在于,所述方法还包括:
    在当前满足所述预设迭代结束条件时,将当前输出的所述图像理解模型作为目标图像理解模型。
  3. 根据权利要求1所述的图像理解方法,其特征在于,所述训练图像通过爬取社交网站中以及公开发布的图像得到。
  4. 根据权利要求1所述的图像理解方法,其特征在于,所述基于训练图像对应的原始文本数据构建与所述训练图像对应的第一文本数据,包括:
    获取训练图像以及与所述训练图像对应的原始文本数据;
    提取所述原始文本数据的原始文本特征,并计算所述训练图像和所述原始文本数据之间的关联向量;和
    利用所述关联向量对所述原始文本特征进行更新,以得到所述第一文本数据。
  5. 根据权利要求4所述的图像理解方法,其特征在于,所述利用所述关联向量对所述原始文本特征进行更新,包括:
    计算所述关联向量与预设超参的乘积,并基于乘积与原始文本特征的和获取更新后文本特征,然后基于更新后文本特征得到第一文本数据。
  6. 根据权利要求5所述的图像理解方法,其特征在于,所述计算所述关联向量与预设超参的乘积,并基于乘积与原始文本特征的和获取更新后文本特征,然后基于更新后文本特征得到第一文本数据所涉及的公式为:
    t←t q+γv
    其中,t表示更新后的原始文本特征,t q表示原始文本特征,γ表示预设超参数,v表示关联向量。
  7. 根据权利要求4所述的图像理解方法,其特征在于,所述计算所述训练图像和所述原始文本数据之间的关联向量,包括:
    利用所述图像理解模型中的图像编码器计算出与所述训练图像对应的全局特征和浅层特征;和
    基于所述全局特征和所述浅层特征,并利用所述图像理解模型中的深度模型的解码器计算出所述训练图像和所述原始文本数据之间的关联向量。
  8. 根据权利要求7所述的图像理解方法,其特征在于,所述图像编码器包括图像编码器和文本编码器。
  9. 根据权利要求7所述的图像理解方法,其特征在于,所述图像编码器ResNet或Vision Transformer视觉深度模型。
  10. 根据权利要求7所述的图像理解方法,其特征在于,所述基于所述全局特征和所述浅层特征,并利用所述图像理解模型中的深度模型的解码器计算出所述训练图像和所述原始文本数据之间的关联向量涉及的公式为:
    Figure PCTCN2022116913-appb-100001
    其中,v表示关联向量,t表示原始文本数据,
    Figure PCTCN2022116913-appb-100002
    表示全局特征,z表示浅层特征。
  11. 根据权利要求1所述的图像理解方法,其特征在于,所述利用当前的所述图像理解模型计算所述训练数据对应的模型总体损失函数值,包括:
    利用当前的所述图像理解模型计算所述图像文本对的像素文本匹配损失函数值和文本距离损失函数值,并基于所述像素文本匹配损失函数值以及所述文本距离损失函数值确定模型总体损失函数值。
  12. 根据权利要求11所述的图像理解方法,其特征在于,所述利用当前的所述图像理解模型计算所述图像文本对的像素文本匹配损失函数值和文本距离损失函数值,包括:
    通过当前的所述图像理解模型中的图像编码器计算与所述图像文本对中所述训练图像对应的浅层特征;和
    基于所述浅层特征、所述图像文本对中所述第一文本数据的第一文本特征以及所述第二文本数据的第二文本特征,并利用所述图像理解模型计算所述图像文本对的所述像素文本匹配损失函数值和所述文本距离损失函数值。
  13. 根据权利要求12所述的图像理解方法,其特征在于,所述基于所述浅层特征、所述图像文本对中所述第一文本数据的第一文本特征以及所述第二文本数据的第二文本特征,并利用所述图像理解模型计算所述图像文本对的所述像素文本匹配损失函数值和所述文本距离损失函数值,包括:
    利用所述图像理解模型确定经过正则化处理的所述第一文本特征以及经过正则化处理的所述第二文本特征;和
    通过所述浅层特征、经过正则化处理的所述第一文本特征和经过正则化处理的所述第二文本特征计算出所述图像文本对的所述像素文本匹配损失函数值,并利用经过正则化处理的所述第一文本特征和经过正则化处理的所述第二文本特征计算出所述图像文本对的所述文本距离损失函数值。
  14. 根据权利要求13所述的图像理解方法,其特征在于,所述像素文本匹配损失函数值计算公式为:
    Figure PCTCN2022116913-appb-100003
    其中,L p&t表示像素文本匹配损失函数值,t strong表示第二文本数据的文本特征,t weak表示第一文本数据的文本特征,
    Figure PCTCN2022116913-appb-100004
    表示经过L 2正则化后的第二文本数据的文本特征,
    Figure PCTCN2022116913-appb-100005
    表示经过L 2正则化后的第一文本数据的文本特征,
    Figure PCTCN2022116913-appb-100006
    表示经过L 2正则化后的浅层特征,T表示转置。
  15. 根据权利要求13所述的图像理解方法,其特征在于,所述文本距离损失函数值计算公式为:
    Figure PCTCN2022116913-appb-100007
    其中,L t表示文本距离损失函数值,
    Figure PCTCN2022116913-appb-100008
    表示经过L 2正则化后的第二文本数据的文本特征,
    Figure PCTCN2022116913-appb-100009
    表示经过L 2正则化后的第一文本数据的文本特征。
  16. 根据权利要求1至15任一项所述的图像理解方法,其特征在于,所述基于所述模型总体损失函数值对所述图像理解模型中的参数进行更新,包括:
    基于所述模型总体损失函数值和自适应矩估计优化器,并利用梯度下降优化算法对所述图像理解模型的参数进行更新。
  17. 根据权利要求1至15任一项所述的图像理解方法,其特征在于,所述基于所述模型总体损失函数值对所述图像理解模型中的参数进行更新,包括:
    利用当前的图像理解模型计算图像文本对的像素文本匹配损失函数值和文本距离损失函数值,并基于像素文本匹配损失函数值以及文本距离损失函数值确定模型总体损失函数值;然后基于模型总体损失函数值和自适应矩估计优化器,并利用梯度下降优化算法对所述图像理解模型的参数进行更新。
  18. 一种图像理解装置,其特征在于,包括:
    图文数据获取模块,用于基于训练图像对应的原始文本数据构建与所述训练图像对应的第一文本数据,并利用简单视觉语言模型对所述训练图像进行处理,以得到与所述训练图像对应的第二文本数据;
    模型初始化模块,用于基于所述训练图像、所述第一文本数据和所述第二文本数据构建图像文本对,以得到相应的图像文本对集,并初始化图像理解模型;
    模型参数更新模块,用于从所述图像文本对集中选取用作训练数据的所述图像文本对,并利用当前的所述图像理解模型计算所述训练数据对应的模型总体损失函数值,然后基于所述模型总体损失函数值对所述图像理解模型中的参数进行更新;
    模型确定模块,用于在当前未满足预设迭代结束条件时,重新跳转至所述从所述图像文本对集中选取用作训练数据的所述图像文本对的步骤,直到满足所述预设迭代结束条件,并将当前输出的所述图像理解模型作为目标图像理解模型;和
    图像理解模块,用于利用所述目标图像理解模型获取与待检测图像对应的目标文本数据。
  19. 一种电子设备,其特征在于,包括存储器及一个或多个处理器,所述存储器中储存有计算机可读指令,所述计算机可读指令被所述一个或多个处理器执行时,使得所述一个或多个处理器执行如权利要求1至17任一项所述的图像理解方法的步骤。
  20. 一个或多个存储有计算机可读指令的非易失性计算机可读存储介质,其特征在于,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行如权利要求1至17任一项所述的图像理解方法的步骤。
PCT/CN2022/116913 2022-04-18 2022-09-02 图像理解方法、装置、设备及介质 WO2023201963A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210401296.2 2022-04-18
CN202210401296.2A CN114511043B (zh) 2022-04-18 2022-04-18 图像理解方法、装置、设备及介质

Publications (1)

Publication Number Publication Date
WO2023201963A1 true WO2023201963A1 (zh) 2023-10-26

Family

ID=81555166

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/116913 WO2023201963A1 (zh) 2022-04-18 2022-09-02 图像理解方法、装置、设备及介质

Country Status (2)

Country Link
CN (1) CN114511043B (zh)
WO (1) WO2023201963A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117789192A (zh) * 2024-02-26 2024-03-29 浪潮计算机科技有限公司 基本输入输出系统的设置项管理方法、装置、设备及介质

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114511043B (zh) * 2022-04-18 2022-07-08 苏州浪潮智能科技有限公司 图像理解方法、装置、设备及介质
CN114648681B (zh) * 2022-05-20 2022-10-28 浪潮电子信息产业股份有限公司 一种图像生成方法、装置、设备及介质
CN116580832A (zh) * 2023-05-05 2023-08-11 暨南大学 基于视频数据的老年痴呆症辅助诊断系统及其方法
CN116721334B (zh) * 2023-08-11 2023-11-21 腾讯科技(深圳)有限公司 图像生成模型的训练方法、装置、设备及存储介质
CN116824278B (zh) * 2023-08-29 2023-12-19 腾讯科技(深圳)有限公司 图像内容分析方法、装置、设备和介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110188819A (zh) * 2019-05-29 2019-08-30 电子科技大学 一种基于信息增益的cnn和lstm图像高层语义理解方法
CN113792113A (zh) * 2020-07-31 2021-12-14 北京京东尚科信息技术有限公司 视觉语言模型获得及任务处理方法、装置、设备及介质
CN114067321A (zh) * 2022-01-14 2022-02-18 腾讯科技(深圳)有限公司 一种文本检测模型训练方法、装置、设备及存储介质
CN114511043A (zh) * 2022-04-18 2022-05-17 苏州浪潮智能科技有限公司 图像理解方法、装置、设备及介质

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113792112A (zh) * 2020-07-31 2021-12-14 北京京东尚科信息技术有限公司 视觉语言任务处理系统、训练方法、装置、设备及介质

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110188819A (zh) * 2019-05-29 2019-08-30 电子科技大学 一种基于信息增益的cnn和lstm图像高层语义理解方法
CN113792113A (zh) * 2020-07-31 2021-12-14 北京京东尚科信息技术有限公司 视觉语言模型获得及任务处理方法、装置、设备及介质
CN114067321A (zh) * 2022-01-14 2022-02-18 腾讯科技(深圳)有限公司 一种文本检测模型训练方法、装置、设备及存储介质
CN114511043A (zh) * 2022-04-18 2022-05-17 苏州浪潮智能科技有限公司 图像理解方法、装置、设备及介质

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117789192A (zh) * 2024-02-26 2024-03-29 浪潮计算机科技有限公司 基本输入输出系统的设置项管理方法、装置、设备及介质
CN117789192B (zh) * 2024-02-26 2024-06-11 浪潮计算机科技有限公司 基本输入输出系统的设置项管理方法、装置、设备及介质

Also Published As

Publication number Publication date
CN114511043B (zh) 2022-07-08
CN114511043A (zh) 2022-05-17

Similar Documents

Publication Publication Date Title
WO2023201963A1 (zh) 图像理解方法、装置、设备及介质
US11544573B2 (en) Projection neural networks
WO2022007823A1 (zh) 一种文本数据处理方法及装置
US20230259784A1 (en) Regularized neural network architecture search
CN111754596B (zh) 编辑模型生成、人脸图像编辑方法、装置、设备及介质
US20190354895A1 (en) Learning data augmentation policies
US10679006B2 (en) Skimming text using recurrent neural networks
JP7483751B2 (ja) 教師なしデータ拡張を使用した機械学習モデルのトレーニング
WO2021212601A1 (zh) 一种基于图像的辅助写作方法、装置、介质及设备
CN113032585B (zh) 一种基于文档结构和外部知识的文档级实体关系抽取方法
CN111767694B (zh) 文本生成方法、装置和计算机可读存储介质
US20220101624A1 (en) Neural network training using the soft nearest neighbor loss
US20230119229A1 (en) Augmenting neural networks
KR20230068989A (ko) 멀티-태스크 모델의 학습을 수행하는 방법 및 전자 장치
US20220004849A1 (en) Image processing neural networks with dynamic filter activation
US11893990B2 (en) Audio file annotation
WO2021258482A1 (zh) 基于迁移与弱监督的美丽预测方法、装置及存储介质
WO2023231753A1 (zh) 一种神经网络的训练方法、数据的处理方法以及设备
CN116977885A (zh) 视频文本任务处理方法、装置、电子设备及可读存储介质
US11900222B1 (en) Efficient machine learning model architecture selection
US20230376755A1 (en) Training neural network systems to perform multiple machine learning tasks
US20220253695A1 (en) Parallel cascaded neural networks
CN117011403A (zh) 生成图像数据的方法及装置、训练方法、电子设备
CN117370802A (zh) 分类模型的训练方法、装置、设备和计算机存储介质
CN117372242A (zh) 图像生成方法、装置、设备及存储介质