CN115578570A - Image processing method, device, readable medium and electronic equipment - Google Patents

Image processing method, device, readable medium and electronic equipment Download PDF

Info

Publication number
CN115578570A
CN115578570A CN202211204451.8A CN202211204451A CN115578570A CN 115578570 A CN115578570 A CN 115578570A CN 202211204451 A CN202211204451 A CN 202211204451A CN 115578570 A CN115578570 A CN 115578570A
Authority
CN
China
Prior art keywords
image
feature
target
text
fusion
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202211204451.8A
Other languages
Chinese (zh)
Inventor
荆雅
孔涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Youzhuju Network Technology Co Ltd
Original Assignee
Beijing Youzhuju Network Technology Co Ltd
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 Beijing Youzhuju Network Technology Co Ltd filed Critical Beijing Youzhuju Network Technology Co Ltd
Priority to CN202211204451.8A priority Critical patent/CN115578570A/en
Publication of CN115578570A publication Critical patent/CN115578570A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/44Local feature extraction by analysis of parts of the pattern, e.g. by detecting edges, contours, loops, corners, strokes or intersections; Connectivity analysis, e.g. of connected components
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/77Processing image or video features in feature spaces; using data integration or data reduction, e.g. principal component analysis [PCA] or independent component analysis [ICA] or self-organising maps [SOM]; Blind source separation
    • G06V10/80Fusion, i.e. combining data from various sources at the sensor level, preprocessing level, feature extraction level or classification level
    • G06V10/806Fusion, i.e. combining data from various sources at the sensor level, preprocessing level, feature extraction level or classification level of extracted features
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V2201/00Indexing scheme relating to image or video recognition or understanding
    • G06V2201/07Target detection

Abstract

The present disclosure relates to an image processing method, an image processing apparatus, a readable medium, and an electronic device, where the image processing method includes obtaining target detection data, where the target detection data includes an image to be detected and image description information of the image to be detected, and the image description information is designated position information representing an object generation area in the image to be detected, or is a description text representing an object in the image to be detected; and inputting the target detection data into a target image processing model to obtain an image processing result output by the target image processing model, wherein the target image processing model is used for outputting a reference expression text of the image corresponding to the reference expression generation area under the condition that the image description information is the specified position information, and outputting a target position of the reference expression object in the image to be detected under the condition that the image description information is the description text.

Description

Image processing method, device, readable medium and electronic equipment
Technical Field
The present disclosure relates to the field of image processing technologies, and in particular, to an image processing method and apparatus, a readable medium, and an electronic device.
Background
The generation of the reference expression (also called the reference expression) refers to the generation of a natural language description for a specified object in a given image, the natural language description can accurately describe the specified object, and the natural language description can be clearly distinguished from other objects in the image. The notional expression understanding (also called the localization of the notional expression) is the recognition of the object in question from a given image according to a natural language description. However, in the related art, the models for generating the indicative expressions and for understanding the indicative expressions have a problem of low integration level, which is not favorable for improving the resource utilization rate of the computer system.
Disclosure of Invention
This summary is provided to introduce a selection of concepts in a simplified form that are further described below in the detailed description. This summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
The disclosure provides an image processing method, an image processing device, a readable medium and an electronic device.
In a first aspect, the present disclosure provides a method of image processing, the method comprising:
acquiring target detection data, wherein the target detection data comprises an image to be detected and image description information of the image to be detected, and the image description information is appointed position information of an appointed reaching generation area in the image to be detected or description text of an appointed reaching object in the image to be detected;
and inputting the target detection data into a target image processing model to obtain an image processing result output by the target image processing model, wherein the target image processing model is used for outputting a reference expression text of the image corresponding to the reference expression generating region under the condition that the image description information is the specified position information, and outputting the target position of the reference expression object in the image to be detected under the condition that the image description information is the description text.
In a second aspect, the present disclosure provides an image processing apparatus, the apparatus comprising:
the system comprises an acquisition module, a display module and a display module, wherein the acquisition module is configured to acquire target detection data, the target detection data comprises an image to be detected and image description information of the image to be detected, and the image description information is appointed position information representing an expression generation area in the image to be detected or description text representing an expression object in the image to be detected;
and the determining module is configured to input the target detection data into a target image processing model to obtain an image processing result output by the target image processing model, wherein the target image processing model is used for outputting a reference expression text of the image corresponding to the reference expression generation region in the case that the image description information is the specified position information, and outputting a target position of the reference expression object in the image to be detected in the case that the image description information is the description text.
In a third aspect, the present disclosure provides a computer readable medium having stored thereon a computer program which, when executed by a processing apparatus, performs the steps of the method of the first aspect above.
In a fourth aspect, the present disclosure provides an electronic device comprising:
a storage device having a computer program stored thereon;
processing means for executing the computer program in the storage means to carry out the steps of the method of the first aspect above.
According to the technical scheme, target detection data are obtained, wherein the target detection data comprise an image to be detected and image description information of the image to be detected, and the image description information is appointed position information of an appointed reaching generation area in the image to be detected or description text of an appointed reaching object in the image to be detected; and inputting the target detection data into a target image processing model to obtain an image processing result output by the target image processing model, wherein the target image processing model is used for outputting a reference expression text of the image corresponding to the reference expression generation area under the condition that the image description information is the specified position information, and outputting a target position of the reference expression object in the image to be detected under the condition that the image description information is the description text. Therefore, the target image processing model integrates the two tasks of the indicative expression generation and the indicative expression understanding, so that the integration level of the model can be effectively improved in the scene that the indicative expression generation task and the indicative expression understanding task need to be completed, and the resource utilization rate of a computer system can be effectively improved.
Additional features and advantages of the present disclosure will be set forth in the detailed description which follows.
Drawings
The above and other features, advantages, and aspects of embodiments of the present disclosure will become more apparent by referring to the following detailed description when taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numbers refer to the same or similar elements. It should be understood that the drawings are schematic and that elements and components are not necessarily drawn to scale. In the drawings:
FIG. 1 is a flow chart illustrating a method of image processing in accordance with an exemplary embodiment of the present disclosure;
FIG. 2 is a schematic diagram illustrating a structure of a target image processing model according to an exemplary embodiment of the present disclosure;
FIG. 3 is a flow chart of a method of image processing according to the embodiment shown in FIGS. 1 and 2;
FIG. 4 is a flow chart of another image processing method according to the embodiment shown in FIGS. 1 and 2;
FIG. 5 is a flow chart diagram of a method of model training shown in an exemplary embodiment of the present disclosure;
fig. 6 is a block diagram of an image processing apparatus shown in an exemplary embodiment of the present disclosure;
fig. 7 is a block diagram of an electronic device shown in an exemplary embodiment of the present disclosure.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and the embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "including" and variations thereof as used herein is intended to be open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence relationship of the functions performed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
It is understood that, before the technical solutions disclosed in the embodiments of the present disclosure are used, the user should be informed of the type, the use range, the use scene, etc. of the personal information related to the present disclosure in a proper manner according to the relevant laws and regulations and obtain the authorization of the user.
For example, in response to receiving an active request from a user, a prompt message is sent to the user to explicitly prompt the user that the requested operation to be performed would require the acquisition and use of personal information to the user. Thus, the user can autonomously select whether to provide personal information to software or hardware such as an electronic device, an application program, a server, or a storage medium that performs the operations of the technical solution of the present disclosure, according to the prompt information.
As an optional but non-limiting implementation manner, in response to receiving an active request from the user, the manner of sending the prompt information to the user may be, for example, a pop-up window, and the prompt information may be presented in a text manner in the pop-up window. In addition, a selection control for providing personal information to the electronic device by the user's selection of "agreeing" or "disagreeing" can be carried in the popup.
It is understood that the above notification and user authorization process is only illustrative and is not intended to limit the implementation of the present disclosure, and other ways of satisfying the relevant laws and regulations may be applied to the implementation of the present disclosure.
Meanwhile, it is understood that the data involved in the present technical solution (including but not limited to the data itself, the acquisition or use of the data) should comply with the requirements of the corresponding laws and regulations and the related regulations.
FIG. 1 is a flow chart illustrating a method of image processing in accordance with an exemplary embodiment of the present disclosure; as shown in fig. 1, the method may include:
step 101, obtaining target detection data, wherein the target detection data comprises an image to be detected and image description information of the image to be detected, and the image description information is appointed position information of an appointed reaching generation area in the image to be detected or description text of an appointed reaching object in the image to be detected.
The expression generating region may be any designated region in the image to be detected, and the expression object may be one or more of a plurality of photographic objects included in the image to be detected.
It should be noted that, in an application scenario generated by referring expression, the image description information is the designated position information of the designated expression generation area in the image to be detected; in the scene of the comprehension of the expression (namely the positioning or segmentation of the expression), the image description information is the description text of the expression object.
Step 102, inputting the target detection data into a target image processing model to obtain an image processing result output by the target image processing model, wherein the target image processing model is configured to output a reference expression text of an image corresponding to the reference expression generating region under the condition that the image description information is the specified position information, and output a target position of the reference expression object in the image to be detected under the condition that the image description information is the description text.
Wherein, the target image processing model may include a visual encoder, a text encoder, a fusion encoder, a position detection network and a text prediction network, fig. 2 is a schematic structural diagram of a target image processing model according to an exemplary embodiment of the present disclosure; as shown in fig. 2, an output of the visual encoder is coupled to an input of the fusion encoder, an output of the text encoder is coupled to an input of the fusion encoder, an output of the fusion encoder is coupled to an input of the position detection network, and an output of the fusion encoder is further coupled to an input of the text prediction network.
It should be noted that the visual encoder may be based on ViT (Vision Transformers, transformations network for visual tasks), using CLIP-ViT [2 ]](contrast Language-Image Pre-training Vision transform) weight initialization to obtain Image extraction network, the Vision encoder is used to split the Image to be detected into non-overlapping patch (small blocks) uniformly, each small block can be seen as word in NLP (Natural Language Processing), then the small blocks are flattened into sequence, then the divided small blocks are embedded into the stacked transform encoder block, and the input is performed through Transnself-attention interaction in sformer encoder to generate image features
Figure BDA0003873104760000061
Wherein L is I Is the number of image blocks. The text Encoder may be a BERT (Bidirectional Encoder from Transformers) based text feature extraction network for segmenting an input description text referring to an expression object to obtain a plurality of token embeddings, and then converting the plurality of input embeddings into text features according to the plurality of input embeddings
Figure BDA0003873104760000062
Wherein L is T Is the number of input embeddings, z [cls] Is related to a special mark [ cls]Corresponding text features. The fusion encoder can comprise a plurality of decoding layers and a plurality of fusion modules, wherein the decoding layers are sequentially connected in series, the fusion modules are sequentially connected in series, the input end of the first decoding layer in the decoding layers is used as the input end of the fusion encoder, the output end of the last decoding layer in the decoding layers is coupled with the input end of the first fusion module, and the output end of the last fusion module in the fusion modules is the output end of the fusion encoder; wherein, the decoding layer is a decoder in a transform, the fusion module may include a self-attention layer, an image inter-attention layer, a region inter-attention layer, and a region prediction layer, an input of the self-attention layer serves as an input of the fusion module, an output of the self-attention layer is coupled to an input of the image inter-attention layer, an output of the image inter-attention layer is coupled to an input of the region prediction layer, an output of the image inter-attention layer is further coupled to an input of the region inter-attention layer, an output of the region prediction layer is coupled to an input of the region inter-attention layer, and an output of the region inter-attention layer serves as an output of the fusion module; the image mutual attention layer and the region mutual attention layer are formed by a self-attention network, and the images are mutually attention-relatedThe input of the attention layer is the output of the self-attention layer and the output of the visual encoder, the input of the region mutual attention layer is the output of the image mutual attention layer, the partial output of the visual encoder (belonging to the part of the image feature referring to the expression generation region) and the output of the region prediction layer. The region prediction layer may be an MLP (multi layer perceptron) network, the position detection network may include a fully connected layer for predicting a target position of the representation object in the image to be detected according to an output of the fusion encoder, and the text prediction network may include a linear regression network for determining a representation text of a representation generation region corresponding image according to an output of the fusion encoder.
According to the technical scheme, the target image processing model integrates the two tasks of the indicative expression generation and the indicative expression understanding, the integration level of the model can be effectively improved in a scene that the indicative expression generation task and the indicative expression understanding task need to be completed, so that the resource utilization rate of a computer system can be effectively improved, the correlation between the two tasks of the indicative expression generation and the indicative expression understanding can be fully utilized, and the accuracy of the indicative expression generation and the indicative expression understanding result can be effectively improved.
FIG. 3 is a flow chart of a method of image processing according to the embodiment shown in FIGS. 1 and 2; as shown in fig. 3, inputting the target detection data into the target image processing model to obtain the image processing result output by the target image processing model in step 102 in fig. 1 may include:
and 1021, inputting the image to be detected and the designated position information into the visual encoder to obtain image characteristics output by the visual encoder and regional position characteristics of the reference expression generation region under the condition that the image description information is the designated position information.
For example, if the vision encoder obtains the image characteristics of the image I to be detected as
Figure BDA0003873104760000081
Figure BDA0003873104760000082
The region position of the expression generation region is characterized by
Figure BDA0003873104760000083
Can be based on the regional location characteristics
Figure BDA0003873104760000084
Image features output from the visual encoder
Figure BDA0003873104760000085
To determine the region image feature corresponding to the specified position information
Figure BDA0003873104760000086
Figure BDA0003873104760000087
Wherein L is I Is the number, v, of image blocks in the image I to be detected j Is the feature vector of the jth image block, p i Is the image block number, L, overlapping the region R The number of the image blocks which are overlapped with the area R corresponding to the designated position information in the image I to be detected is determined.
Step 1022, acquiring a preset initial mask text, and inputting the initial mask text into the text encoder to obtain a mask text feature output by the text encoder.
The initial MASK text may be preset text including one or more MASKs.
And 1023, performing feature fusion on the image features, the region position features and the mask text features through the fusion encoder to obtain first target features.
The fusion encoder comprises a plurality of decoding layers and a plurality of fusion modules, wherein the decoding layers are sequentially connected in series, the fusion modules are sequentially connected in series, the input end of the first decoding layer in the decoding layers serves as the input end of the fusion encoder, the output end of the last decoding layer in the decoding layers is coupled with the input end of the first fusion module, and the output end of the last fusion module in the fusion modules serves as the output end of the fusion encoder; the fusion module comprises a self-attention layer, an image mutual attention layer, a region mutual attention layer and a region prediction layer, wherein an input end of the self-attention layer serves as an input end of the fusion module, an output end of the self-attention layer is coupled with an input end of the image mutual attention layer, an output end of the image mutual attention layer is coupled with an input end of the region prediction layer, an output end of the image mutual attention layer is further coupled with an input end of the region mutual attention layer, an output end of the region prediction layer is coupled with an input end of the region mutual attention layer, and an output end of the region mutual attention layer serves as an output end of the fusion module.
This step 1023 can be implemented by the steps shown in S1 to S3:
s1, fusing the region position feature and the mask text feature through the plurality of decoding layers under the condition that the image description information is the designated position information to obtain a first fusion feature.
Illustratively, if the region location is characterized by
Figure BDA0003873104760000091
The mask text is characterized by
Figure BDA0003873104760000092
Wherein p is i Is an index that overlaps with the region, L T Is the number of input embeddings, z [cls] Is related to a special mark [ cls]Inputting the region position feature P and the mask text feature Z into denoders in the Transformer according to the corresponding text features, and obtaining a first fusion feature output by the last decoding layer in a plurality of decoding layers
Figure BDA0003873104760000093
And S2, performing attention operation on the first fusion feature and the region position feature through the first fusion module to obtain a first to-be-determined feature.
In S2, a first attention feature corresponding to the first fusion feature may be acquired through the self-attention layer; performing multi-head attention operation on the first attention feature and the image feature through the image mutual attention layer to obtain a second attention feature; performing multi-head attention operation on the second attention feature and the region position feature through the region mutual attention layer to obtain a third attention feature; determining the first to-be-determined feature according to the third attention feature.
By way of example, the processing procedure of the self-attention layer may be represented as:
X Q =MHA(X,X,X)+X
where MHA is multi-head attention, X Q A first attention feature obtained from the first fusion feature X for a self-attention layer;
the image mutual attention layer and the region mutual attention layer may both include a multi-head attention network and a gated linear network, and the execution process of the image mutual attention layer may be expressed as:
Z I =MHA(X Q ,V I ,V I )
X I =GLU([Z I ,X Q ])+X Q
wherein, Z I For an intermediate representation of the multi-head attention network output in the image mutual attention layer, [,]representing concatenation of vectors, GLU gated linear network, GLU (X) = σ (XW) 1 )⊙XW 2 ,W 1 ,W 2 Is a learnable parameter, σ is a sigmoid function, and an indicates element-by-element multiplication. X I For gated linear network pair Z I ,X Q The result after processing, namely the second attention feature output by the image mutual attention layer.
The implementation of the regional mutual attention layer can be expressed as:
Z R =MHA(X I ,V R ,V R )
X R =GLU([Z R ,X Q ])+X I
wherein the location characteristics can be based on the region
Figure BDA0003873104760000101
Image features output from the visual encoder
Figure BDA0003873104760000102
To determine the region image feature corresponding to the specified position information
Figure BDA0003873104760000103
L I Is the number, v, of image blocks in the image I to be detected j Is the feature vector of the jth image block, p i Is the image block number, L, overlapping the region R The number of the image blocks which are overlapped with the area R corresponding to the designated position information in the image I to be detected is determined. Z is a linear or branched member R For an intermediate representation of the multi-head attention network output in the regional mutual attention layer, [,]concatenation of representational vectors, GLU gated linear network, X R For gated linear network pair Z R ,X Q ,X I The result after processing, namely the third attention feature output by the image mutual attention layer.
In addition, the fusion module may further include an FFN (feed-forward network) layer, where the first predetermined characteristic is determined according to the third attention characteristic, and an embodiment may be that the third attention characteristic is input to the location feed-forward network layer to obtain an output characteristic of the location feed-forward network layer, and the output characteristic of the location feed-forward network layer is used as the first predetermined characteristic.
And S3, determining the first target feature through other fusion modules except the first fusion module in the multiple fusion modules according to the first to-be-determined feature and the region position feature.
In S3, for each fusion module except the first fusion module in the multiple fusion modules, performing attention operation on the specified undetermined feature and the region position feature output by the previous fusion module to obtain a target undetermined feature output by the current fusion module; and taking the target undetermined characteristic output by the last fusion module as the first target characteristic.
Step 1024, generating a reference expression text of the image corresponding to the reference expression generating area according to the first target feature through the text prediction network.
In this step, a first word referring to an expression text can be determined according to the first target feature through the text prediction network; updating the initial mask text according to the first word; and determining other words in the reference expression text according to the updated initial mask text, the image features and the region position features to obtain the reference expression text.
Illustratively, when a detection box corresponding to a green grassland in an image to be detected is generated by referring expression, an initial mask text is a "mask mask mask", a first iteration process determines a first word "green", an updated initial mask text is a "green mask mask", a second iteration process determines a second word "color", an updated initial mask text is a "green mask", a third iteration process determines a third word "grass", an updated initial mask text is a "green grass mask", and the process is repeated until a "green grassland" of a referring expression text is obtained.
FIG. 4 is a flow chart of another image processing method according to the embodiment shown in FIGS. 1 and 2; as shown in fig. 4, inputting the target detection data into the target image processing model to obtain the image processing result output by the target image processing model in step 102 in fig. 1 may further include:
and 1025, inputting the image to be detected into the visual encoder to obtain the image characteristics output by the visual encoder and inputting the description text into the text encoder to obtain the description text characteristics output by the text encoder under the condition that the image description information is the description text.
Step 1026, inputting the image feature and the descriptive text feature into the fusion encoder to obtain a second target feature output by the fusion encoder.
This step can be implemented by the steps shown in S21 to S22 below:
s21, fusing the image features and the description text features through the plurality of decoding layers under the condition that the image description information is the description text to obtain second fusion features.
In this step, the decoding layer is a denoder in the transform, and the image feature and the description text feature are input into the denoder, so that the second fusion feature can be obtained.
And S22, fusing the second fusion characteristics and the image characteristics through the plurality of fusion modules to obtain the second target characteristics.
In S22, the attention operation may be performed on the second fusion feature and the image feature by the first fusion module to obtain a second undetermined feature; determining the second undetermined feature through other fusion modules except the first fusion module in the multiple fusion modules according to the second undetermined feature and the image feature; and determining the second target feature through other fusion modules except the first fusion module in the plurality of fusion modules according to the second feature to be determined and the second image feature.
The performing, by the first fusion module, attention operation on the second fusion feature and the image feature to obtain a second undetermined feature may include: performing attention operation on the second fusion feature through the self-attention layer in the first fusion module to obtain a first target attention feature; performing multi-head attention operation on the image feature and the first target attention feature through the image mutual attention layer in the first fusion module to obtain a second target attention feature; determining, by the regional prediction layer in the first fusion module, a predicted region image feature from the second target attention feature; performing multi-head attention operation on the image feature, the second target attention feature and the predicted region image feature through a region mutual attention layer in the first fusion module to obtain a third target attention feature; determining the second candidate feature from the third target attention feature.
The above-mentioned regional prediction layer is a multilayer perceptron network, and the determining, by the regional prediction layer in the first fusion module, a predicted regional image feature according to the second target attention feature includes:
determining the target probability of each unit region belonging to the region of the expression object according to the full-text features in the second target attention features through the multilayer perceptron network; and taking the image feature corresponding to the unit area with the target probability greater than or equal to a preset probability threshold value as the image feature of the prediction area.
For example, when performing the reference expression understanding, since the input image description information is a description text representing an object to be detected in the image to be detected, and no input of position information is specified, a region needs to be predicted according to the image feature output by the visual encoder and the description text feature output by the text encoder, and in order to make the input of the reference expression understanding the same as the generation of the reference expression, a region prediction layer is set to generate a prediction region position as an input of a region mutual attention layer. In implementation, each image block (i.e., unit area) may be based on
Figure BDA0003873104760000131
(full text feature) and ith image Block e i Is embedded in the calculated score alpha, and the score alpha is used i As the target probability that the unit region corresponding to the ith image block belongs to the region in which the expression object is located, the image feature of the region in which the image block with the score exceeding a preset probability threshold value delta is located may be selected to constitute a predicted region image feature V R The process can be expressed as:
Figure BDA0003873104760000132
Figure BDA0003873104760000133
wherein alpha is i The unit area corresponding to the ith image block belongs to the target probability of the area where the expression object is located,
Figure BDA0003873104760000134
and delta is the image characteristic of the ith image block and is a preset probability threshold.
The determining the second target feature by the other fusion module except the first fusion module in the plurality of fusion modules according to the second feature to be determined and the second image feature as described above may include:
under the condition that the image description information is the description text, performing attention operation on the specified undetermined feature and the region position feature output by the previous fusion module aiming at each fusion module except the first fusion module in the multiple fusion modules to obtain a target undetermined feature output by the current fusion module; and taking the target undetermined characteristic output by the last fusion module as the second target characteristic.
Step 1027, inputting the second target feature into the position detection network to obtain the target position of the expression object in the image to be detected.
The position detection network can comprise a full connection layer and is used for predicting the target position of the reference expression object in the image to be detected according to the second target characteristic.
According to the technical scheme, the variable transform decoder layer is replaced by the fusion module to expand the transform decoder, so that the difference between the generation of the indicative expression and the understanding of the indicative expression is closed, and the pseudo input region (the region output by the region prediction layer) is generated in the task of generating the indicative expression, so that the same representation space is shared between the generation of the indicative expression and the understanding of the indicative expression in a unified manner, the correlation between the generation of the indicative expression and the understanding of the indicative expression can be fully utilized, the unified modeling of the task of generating the indicative expression and the task of understanding the indicative expression is effectively realized, and the effect of ensuring the accuracy of the identification result and improving the integration degree of the model is achieved.
FIG. 5 is a flow chart diagram illustrating a method of model training in accordance with an exemplary embodiment of the present disclosure; as shown in fig. 5, the target image processing model may be obtained by training the following steps:
step 501, obtaining a plurality of pre-training data sets with different granularities, where the pre-training data sets include a plurality of sets of training data, each set of training data includes a sample image, a reference expression generation sample region and a reference expression text sample corresponding to the reference expression generation sample region, and the reference expression text sample includes a preset mask and text label data of the preset mask.
Part of the content in the sample of the reference expression text may be marked with a mask, for example, 25% of the text in the sample of the reference expression text may be marked with a mask, so as to obtain a sample of the reference expression text with a preset mask.
It should be noted that the pre-training data sets of different granularities may include a COCO (Common Objects in Context, common data set for object detection, segmentation, and key point detection) data set in the prior art; visual Genome phrase dataset; visual Genome region describes a dataset, and the region description can be a phrase or sentence and RefCOCO-MERGE (dataset in the prior art). The above data set is a data set commonly used in the prior art for training the referential expression generation or the referential expression positioning model, and the disclosure is not limited thereto.
Step 502, pre-training a preset initial model by using the pre-training data sets with different granularities as training data to obtain an image processing model to be determined.
The model structure of the preset initial model may refer to the model structure shown in fig. 2, which is not described herein again, and the model parameters in the preset initial model are initial parameters before training.
This step can be obtained by training the steps shown in S31 to S35:
and S31, sequentially inputting each group of training data in a plurality of pre-training data sets with different granularities into the preset initial model to obtain predicted text data and predicted boundary data corresponding to the training data.
And S32, calculating a first loss value through a first loss function according to the predicted text data and the text marking data of the preset mask.
It should be noted that, in the training, the pair mask can be used]Predicting the text content to obtain predicted text data, and calculating a first loss value L of a first preset loss function according to the predicted text data and the text marking data VMLM
Figure BDA0003873104760000151
Wherein, the sample image I, the reference expression generation sample region R and the reference expression text sample T corresponding to the reference expression generation sample region form an image-region-text triple (I, R, T), E (I,R,T) Is the expectation of data in a batch of data volume; theta G To generate the network parameters for the indicative expression,
Figure BDA0003873104760000152
the text data is predicted and the text data is predicted,
Figure BDA0003873104760000153
the text is labeled with data.
And S33, calculating a second loss value through a second loss function according to the prediction boundary data and the expression generation sample region, and determining a third loss value of a third loss function according to the labeled region mask and the predicted region mask.
Illustratively, the second loss function may be:
Figure BDA0003873104760000161
wherein, the first and the second end of the pipe are connected with each other,
Figure BDA0003873104760000162
is that
Figure BDA0003873104760000163
And the generalized cross-union of b,
Figure BDA0003873104760000164
is 1 1 The norm of the number of the first-order-of-arrival,
Figure BDA0003873104760000165
generating sample regions for the truly labeled reference expressions, b is the predicted bounding box position, E (I,T) The expectation of data in a batch of data volumes formed for sample images I and for reference expression text samples T.
The fourth loss function may be:
Figure BDA0003873104760000166
wherein, the first and the second end of the pipe are connected with each other,
Figure BDA0003873104760000167
respectively representing mask regions of the real labels, wherein m is a prediction mask region of the ith token embedding (image-region-text fusion embedding) output by the region prediction layer in the training process.
And S34, determining a fourth loss value through a fourth loss function according to the second loss value and the third loss value.
Wherein the fourth loss function may be L TRP
L TRP =L bbox +L pred
L bbox Is the second loss value, L pred And a third loss value.
And S35, performing iterative training on the preset initial model according to the first loss value and the fourth loss value to obtain the pending image processing model.
After one iteration calculation is completed, calculating the first loss value and the fourth loss value, determining whether the first loss value is greater than a first preset loss threshold value or not, and whether the fourth loss value is greater than a second preset loss threshold value or not, updating model parameters of the preset initial model when the first loss value is greater than the first preset loss threshold value or the fourth loss value is greater than the second preset loss threshold value, and circularly calculating the first loss value and the fourth loss value until determining whether the first loss value is greater than the first preset loss threshold value or not and whether the fourth loss value is greater than the second preset loss threshold value or not, until the current preset initial model is taken as the pending image processing model when the first loss value is less than or equal to the first preset loss threshold value and the fourth loss value is less than or equal to the second preset loss threshold value.
Step 503, obtaining a target training data set of a target granularity, and performing refined training on the to-be-determined image processing model by using the target training data set as training data to obtain the target image processing model.
In this step, a COCO dataset may be used; a Visual Genome phrase dataset; any one of a Visual Genome region description data set and RefCOCO-MERGE is used as a target training data set, other training data sets can be constructed, and fine training is still carried out in a training mode adopted in the pre-training process to obtain the target image processing model.
The training mode can fully utilize the correlation between the two tasks of the symbolic expression generation and the symbolic expression understanding, can train a model which has higher accuracy and can not only complete the task of the symbolic expression generation and the task of the symbolic expression understanding aiming at the unified modeling of the symbolic expression generation and the symbolic expression understanding, and can effectively improve the integration level of the model in a scene in which the task of the symbolic expression generation and the task of the symbolic expression understanding are required to be completed, thereby effectively improving the resource utilization rate of a computer system.
Fig. 6 is a block diagram of an image processing apparatus according to an exemplary embodiment of the present disclosure, which may include, as shown in fig. 6:
an obtaining module 601, configured to obtain target detection data, where the target detection data includes an image to be detected and image description information of the image to be detected, and the image description information is specified position information representing an expression generation area in the image to be detected or is a description text representing an expression object in the image to be detected;
a determining module 602, configured to input the target detection data into a target image processing model to obtain an image processing result output by the target image processing model, where the target image processing model is used to output a reference expression text of an image corresponding to the reference expression generation region in a case that the image description information is the specified position information, and output a target position of the reference expression object in the image to be detected in a case that the image description information is the description text.
According to the technical scheme, the target image processing model integrates the two tasks of the indicative expression generation and the indicative expression understanding, so that the integration level of the model can be effectively improved in a scene that the indicative expression generation task and the indicative expression understanding task need to be completed, and the resource utilization rate of a computer system can be effectively improved.
Optionally, the target image processing model includes a visual encoder, a text encoder, a fusion encoder, a position detection network, and a text prediction network, an output of the visual encoder is coupled to an input of the fusion encoder, an output of the text encoder is coupled to an input of the fusion encoder, an output of the fusion encoder is coupled to an input of the position detection network, and an output of the fusion encoder is further coupled to an input of the text prediction network;
the determining module 602 configured to:
under the condition that the image description information is the designated position information, inputting the image to be detected and the designated position information into the visual encoder so as to obtain image characteristics output by the visual encoder and area position characteristics of the reference expression generation area;
acquiring a preset initial mask text, and inputting the initial mask text into the text encoder to obtain mask text characteristics output by the text encoder;
performing feature fusion on the image feature, the region position feature and the mask text feature through the fusion encoder to obtain a first target feature;
generating the expression text of the image corresponding to the expression generating area according to the first target feature through the text prediction network.
Optionally, the determining module 602 is configured to:
determining a first word referring to an expression text according to the first target feature through the text prediction network;
updating the initial mask text according to the first word;
and determining other words in the reference expression text according to the updated initial mask text, the image features and the region position features to obtain the reference expression text.
Optionally, the determining module 602 is further configured to:
under the condition that the image description information is the description text, inputting the image to be detected into the visual encoder to obtain the image characteristics output by the visual encoder, and inputting the description text into the text encoder to obtain the description text characteristics output by the text encoder;
inputting the image feature and the description text feature into the fusion encoder to obtain a second target feature output by the fusion encoder;
and inputting the second target characteristic into the position detection network to acquire the target position of the expression object output by the position detection network in the image to be detected.
Optionally, the fusion encoder includes a plurality of decoding layers and a plurality of fusion modules, the decoding layers are sequentially connected in series, the fusion modules are sequentially connected in series, an input end of a first decoding layer of the decoding layers serves as an input end of the fusion encoder, an output end of a last decoding layer of the decoding layers is coupled with an input end of the first fusion module, and an output end of a last fusion module of the fusion modules is an output end of the fusion encoder;
the determining module 602 configured to:
under the condition that the image description information is the designated position information, fusing the region position feature and the mask text feature through the plurality of decoding layers to obtain a first fusion feature;
performing attention operation on the first fusion feature and the region position feature through the first fusion module to obtain a first to-be-determined feature;
and determining the first target feature through other fusion modules except the first fusion module in the plurality of fusion modules according to the first to-be-determined feature and the region position feature.
Optionally, the determining module 602 is configured to:
performing attention operation on the specified undetermined feature and the region position feature output by the previous fusion module aiming at each fusion module except the first fusion module in the multiple fusion modules to obtain a target undetermined feature output by the current fusion module;
and taking the target undetermined characteristic output by the last fusion module as the first target characteristic.
Optionally, the determining module 602 is configured to:
under the condition that the image description information is the description text, fusing the image features and the description text features through the plurality of decoding layers to obtain second fusion features;
fusing, by the plurality of fusion modules, the second fusion feature and the image feature,
to obtain the second target feature.
Optionally, the fusion module includes a self-attention layer, an image mutual attention layer, a region mutual attention layer, and a region prediction layer, an input of the self-attention layer serves as an input of the fusion module, an output of the self-attention layer is coupled to an input of the image mutual attention layer, an output of the image mutual attention layer is coupled to an input of the region prediction layer, an output of the image mutual attention layer is further coupled to an input of the region mutual attention layer, an output of the region prediction layer is coupled to an input of the region mutual attention layer, and an output of the region mutual attention layer serves as an output of the fusion module;
the determining module 602 configured to:
acquiring a first attention feature corresponding to the first fusion feature through the self-attention layer;
performing multi-head attention operation on the first attention feature and the image feature through the image mutual attention layer to obtain a second attention feature;
performing multi-head attention operation on the second attention feature and the region position feature through the region mutual attention layer to obtain a third attention feature;
determining the first to-be-determined feature according to the third attention feature.
Optionally, the determining module 602 is configured to:
performing attention operation on the second fusion feature and the image feature through the first fusion module to obtain a second undetermined feature;
determining the second to-be-determined feature through other fusion modules except the first fusion module in the multiple fusion modules according to the second to-be-determined feature and the image feature;
and determining the second target feature through other fusion modules except the first fusion module in the plurality of fusion modules according to the second feature to be determined and the second image feature.
Optionally, the determining module 602 is configured to:
performing attention operation on the second fusion feature through the self-attention layer in the first fusion module to obtain a first target attention feature;
performing multi-head attention operation on the image feature and the first target attention feature through the image mutual attention layer in the first fusion module to obtain a second target attention feature;
determining, by the regional prediction layer in the first fusion module, a predicted regional image feature from the second target attention feature;
performing multi-head attention operation on the image feature, the second target attention feature and the predicted region image feature through a region mutual attention layer in the first fusion module to obtain a third target attention feature;
determining the second candidate feature from the third target attention feature.
Optionally, the area prediction layer is a multi-layer perceptron network, and the determining module is configured to:
determining the target probability of each unit region belonging to the region of the expression object according to the full-text features in the second target attention features through the multilayer perceptron network;
and taking the image feature corresponding to the unit area with the target probability greater than or equal to a preset probability threshold value as the image feature of the prediction area.
Optionally, the image processing apparatus further comprises a model training module 603 configured to:
acquiring a plurality of pre-training data sets with different granularities, wherein each pre-training data set comprises a plurality of groups of training data, each group of training data comprises a sample image, a reference expression generation sample region and a reference expression text sample corresponding to the reference expression generation sample region, and each reference expression text sample comprises a preset mask and text marking data of the preset mask;
pre-training a preset initial model by taking the pre-training data sets with different granularities as training data to obtain an image processing model to be determined;
and acquiring a target training data set of target granularity, and carrying out fine training on the to-be-determined image processing model by taking the target training data set as training data to obtain the target image processing model.
Optionally, the model training module 603 is configured to:
sequentially inputting each group of training data in a plurality of pre-training data sets with different granularities into the preset initial model to obtain predicted text data and predicted boundary data corresponding to the training data;
calculating a first loss value through a first loss function according to the predicted text data and the text marking data of the preset mask;
calculating a second loss value through a second loss function according to the prediction boundary data and the reference expression generation sample region, and determining a third loss value of a third loss function according to the annotated area mask and the predicted area mask;
determining a fourth loss value through a fourth loss function according to the second loss value and the third loss value;
and performing iterative training on the preset initial model according to the first loss value and the fourth loss value to obtain the pending image processing model.
According to the technical scheme, the transform decoder is expanded by replacing a vanella transform decoder layer with a fusion module, so that the difference between the generation of the indicative expression and the understanding of the indicative expression is closed, and a pseudo input region (a region output by a region prediction layer) is generated in the task of generating the indicative expression, so that the same representation space is shared between the generation of the indicative expression and the understanding of the indicative expression in a unified manner, thereby effectively realizing the unified modeling of the task of generating the indicative expression and the task of understanding the indicative expression, and achieving the effect of improving the integration degree of the model while ensuring the accuracy of the recognition result.
Referring now to FIG. 7, shown is a block diagram of an electronic device 700 suitable for use in implementing embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a fixed terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 7 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 7, electronic device 700 may include a processing means (e.g., central processing unit, graphics processor, etc.) 701 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM) 702 or a program loaded from storage 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data necessary for the operation of the electronic apparatus 700 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other by a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
Generally, the following devices may be connected to the I/O interface 705: input devices 706 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 707 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 708, including, for example, magnetic tape, hard disk, etc.; and a communication device 709. The communication means 709 may allow the electronic device 700 to communicate wirelessly or by wire with other devices to exchange data. While fig. 7 illustrates an electronic device 700 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may be alternatively implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such embodiments, the computer program may be downloaded and installed from a network via the communication means 709, or may be installed from the storage means 708, or may be installed from the ROM 702. The computer program, when executed by the processing device 701, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium of the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some implementations, the clients may communicate using any currently known or future developed network Protocol, such as HTTP (HyperText Transfer Protocol), and may interconnect with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: acquiring target detection data, wherein the target detection data comprises an image to be detected and image description information of the image to be detected, and the image description information is appointed position information of an appointed reaching generation area in the image to be detected or description text of an appointed reaching object in the image to be detected;
and inputting the target detection data into a target image processing model to obtain an image processing result output by the target image processing model, wherein the target image processing model is used for outputting a reference expression text of the image corresponding to the reference expression generation area under the condition that the image description information is the specified position information, and outputting a target position of the reference expression object in the image to be detected under the condition that the image description information is the description text.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present disclosure may be implemented by software or hardware. The name of a module does not in some cases constitute a limitation on the module itself, and for example, an acquisition module may also be described as a "module that acquires target detection data".
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), system on a chip (SOCs), complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The 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, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
In accordance with one or more embodiments of the present disclosure, example 1 provides an image processing method, the method comprising:
acquiring target detection data, wherein the target detection data comprises an image to be detected and image description information of the image to be detected, and the image description information is appointed position information of an appointed expression generating area in the image to be detected or description text of an appointed expression object in the image to be detected;
and inputting the target detection data into a target image processing model to obtain an image processing result output by the target image processing model, wherein the target image processing model is used for outputting a reference expression text of the image corresponding to the reference expression generation area under the condition that the image description information is the specified position information, and outputting a target position of the reference expression object in the image to be detected under the condition that the image description information is the description text.
Example 2 provides the method of example 1, the target image processing model comprising a visual encoder, a text encoder, a fusion encoder, a position detection network, and a text prediction network, an output of the visual encoder coupled to an input of the fusion encoder, an output of the text encoder coupled to an input of the fusion encoder, an output of the fusion encoder coupled to an input of the position detection network, an output of the fusion encoder further coupled to an input of the text prediction network;
the inputting the target detection data into a target image processing model to obtain an image processing result output by the target image processing model includes:
under the condition that the image description information is the designated position information, inputting the image to be detected and the designated position information into the visual encoder so as to obtain image characteristics output by the visual encoder and area position characteristics of the reference expression generation area;
acquiring a preset initial mask text, and inputting the initial mask text into the text encoder to obtain mask text characteristics output by the text encoder;
performing feature fusion on the image feature, the region position feature and the mask text feature through the fusion encoder to obtain a first target feature;
and generating a reference expression text of the image corresponding to the reference expression generation area according to the first target feature through the text prediction network.
Example 3 provides the method of example 2, the determining, by the text prediction network, the reference expression text of the image corresponding to the reference expression generation region according to the first target feature, including:
determining a first word referring to an expression text according to the first target feature through the text prediction network;
updating the initial mask text according to the first word;
and determining other words in the reference expression text according to the updated initial mask text, the image features and the region position features to obtain the reference expression text.
Example 4 provides the method of example 2, wherein inputting the target detection data into a target image processing model to obtain an image processing result output by the target image processing model, further comprises:
under the condition that the image description information is the description text, inputting the image to be detected into the visual encoder to obtain the image characteristics output by the visual encoder, and inputting the description text into the text encoder to obtain the description text characteristics output by the text encoder;
inputting the image feature and the description text feature into the fusion encoder to obtain a second target feature output by the fusion encoder;
and inputting the second target characteristic into the position detection network to acquire the target position of the expression object output by the position detection network in the image to be detected.
Example 5 provides the method of example 4, the fused encoder including a plurality of decoding layers and a plurality of fusion modules, the plurality of decoding layers being sequentially connected in series, and the plurality of fusion modules being sequentially connected in series, an input of a first decoding layer of the plurality of decoding layers serving as an input of the fused encoder, an output of a last decoding layer of the plurality of decoding layers being coupled to an input of the first fusion module, an output of a last fusion module of the plurality of fusion modules being an output of the fused encoder;
the performing feature fusion on the image feature, the region position feature and the mask text feature by the fusion encoder to obtain a first target feature includes:
under the condition that the image description information is the designated position information, fusing the region position feature and the mask text feature through the plurality of decoding layers to obtain a first fusion feature;
performing attention operation on the first fusion feature and the region position feature through the first fusion module to obtain a first to-be-determined feature;
and determining the first target feature through other fusion modules except the first fusion module in the plurality of fusion modules according to the first to-be-determined feature and the region position feature.
Example 6 provides the method of example 5, the determining, by a fusion module other than the first fusion module of the plurality of fusion modules, the first target feature according to the first to-be-determined feature and the region-location feature, including:
performing attention operation on the specified undetermined feature and the region position feature output by the previous fusion module aiming at each fusion module except the first fusion module in the multiple fusion modules to obtain a target undetermined feature output by the current fusion module;
and taking the target undetermined characteristic output by the last fusion module as the first target characteristic.
Example 7 provides the method of example 5, wherein inputting the image feature and the descriptive text feature into the fusion encoder to obtain a second target feature output by the fusion encoder, comprises:
under the condition that the image description information is the description text, fusing the image features and the description text features through the plurality of decoding layers to obtain second fusion features;
and fusing the second fusion characteristic and the image characteristic through the plurality of fusion modules to obtain the second target characteristic.
Example 8 provides the method of example 7, the fusion module including a self-attention layer, an image mutual attention layer, a region mutual attention layer, and a region prediction layer, an input of the self-attention layer being an input of the fusion module, an output of the self-attention layer being coupled with an input of the image mutual attention layer, an output of the image mutual attention layer being coupled with an input of the region prediction layer, an output of the image mutual attention layer also being coupled with an input of the region mutual attention layer, an output of the region prediction layer being coupled with an input of the region mutual attention layer, an output of the region mutual attention layer being an output of the fusion module;
the performing, by the first fusion module, attention to the first fusion feature and the region location feature to obtain a first to-be-determined feature includes:
acquiring a first attention feature corresponding to the first fusion feature through the self-attention layer;
performing multi-head attention operation on the first attention feature and the image feature through the image mutual attention layer to obtain a second attention feature;
performing multi-head attention operation on the second attention feature and the region position feature through the region mutual attention layer to obtain a third attention feature;
determining the first to-be-determined feature according to the third attention feature.
Example 9 provides the method of example 8, wherein fusing, by the plurality of fusion modules, the second fused feature and the image feature to obtain the second target feature comprises:
performing attention operation on the second fusion feature and the image feature through the first fusion module to obtain a second undetermined feature;
determining the second to-be-determined feature through other fusion modules except the first fusion module in the multiple fusion modules according to the second to-be-determined feature and the image feature;
and determining the second target feature through other fusion modules except the first fusion module in the plurality of fusion modules according to the second to-be-determined feature and the second image feature.
Example 10 provides the method of example 9, wherein performing, by the first fusion module, attention on the second fused feature and the image feature to obtain a second pending feature comprises:
performing attention operation on the second fusion feature through the self-attention layer in the first fusion module to obtain a first target attention feature;
performing multi-head attention operation on the image feature and the first target attention feature through the image mutual attention layer in the first fusion module to obtain a second target attention feature;
determining, by the regional prediction layer in the first fusion module, a predicted regional image feature from the second target attention feature;
performing multi-head attention operation on the image features, the second target attention features and the predicted region image features through a region mutual attention layer in the first fusion module to obtain third target attention features;
determining the second candidate feature from the third target attention feature.
Example 11 provides the method of example 10, wherein the regional prediction layer is a multi-layer perceptron network, and determining, by the regional prediction layer in the first fusion module, a predicted regional image feature from the second target attention feature comprises:
determining the target probability of each unit region belonging to the region of the expression object according to the full-text features in the second target attention features through the multilayer perceptron network;
and taking the image characteristics corresponding to the unit area with the target probability greater than or equal to a preset probability threshold value as the image characteristics of the prediction area.
Example 12 provides the method of any one of examples 1-11, the target image processing model trained by:
acquiring a plurality of pre-training data sets with different granularities, wherein each pre-training data set comprises a plurality of groups of training data, each group of training data comprises a sample image, a reference expression generation sample region and a reference expression text sample corresponding to the reference expression generation sample region, and each reference expression text sample comprises a preset mask and text marking data of the preset mask;
pre-training a preset initial model by taking the pre-training data sets with different granularities as training data to obtain an image processing model to be determined;
and acquiring a target training data set of target granularity, and carrying out fine training on the to-be-determined image processing model by taking the target training data set as training data to obtain the target image processing model.
Example 13 provides the method of example 12, where the pre-training is performed on a preset initial model with the pre-training data sets of different granularities as training data to obtain a pending image processing model, and the method includes:
sequentially inputting each group of training data in a plurality of pre-training data sets with different granularities into the preset initial model to obtain predicted text data and predicted boundary data corresponding to the training data;
calculating a first loss value through a first loss function according to the predicted text data and the text marking data of the preset mask;
calculating a second loss value through a second loss function according to the prediction boundary data and the reference expression generation sample region, and determining a third loss value of a third loss function according to the annotated area mask and the predicted area mask;
determining a fourth loss value through a fourth loss function according to the second loss value and the third loss value;
and performing iterative training on the preset initial model according to the first loss value and the fourth loss value to obtain the pending image processing model.
Example 14 provides, in accordance with one or more embodiments of the present disclosure, an image processing apparatus comprising:
the acquisition module is configured to acquire target detection data, wherein the target detection data comprises an image to be detected and image description information of the image to be detected, and the image description information is appointed position information of an expression generation area in the image to be detected or description text of an expression object in the image to be detected;
and the determining module is configured to input the target detection data into a target image processing model to obtain an image processing result output by the target image processing model, wherein the target image processing model is used for outputting a reference expression text of the image corresponding to the reference expression generation region in the case that the image description information is the specified position information, and outputting a target position of the reference expression object in the image to be detected in the case that the image description information is the description text.
Example 15 provides a computer readable medium having stored thereon a computer program that, when executed by a processing apparatus, performs the steps of the method of any of examples 1-13, in accordance with one or more embodiments of the present disclosure.
Example 16 provides, in accordance with one or more embodiments of the present disclosure, an electronic device, comprising:
a storage device having a computer program stored thereon;
processing means for executing the computer program in the storage means to carry out the steps of the method of any of examples 1-13.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other combinations of features described above or equivalents thereof without departing from the spirit of the disclosure. For example, the above features and the technical features disclosed in the present disclosure (but not limited to) having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims. With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.

Claims (16)

1. An image processing method, characterized in that the method comprises:
acquiring target detection data, wherein the target detection data comprises an image to be detected and image description information of the image to be detected, and the image description information is appointed position information of an appointed reaching generation area in the image to be detected or description text of an appointed reaching object in the image to be detected;
and inputting the target detection data into a target image processing model to obtain an image processing result output by the target image processing model, wherein the target image processing model is used for outputting a reference expression text of the image corresponding to the reference expression generation area under the condition that the image description information is the specified position information, and outputting a target position of the reference expression object in the image to be detected under the condition that the image description information is the description text.
2. The method of claim 1, wherein the target image processing model comprises a visual encoder, a text encoder, a fusion encoder, a position detection network, and a text prediction network, an output of the visual encoder being coupled to an input of the fusion encoder, an output of the text encoder being coupled to an input of the fusion encoder, an output of the fusion encoder being coupled to an input of the position detection network, an output of the fusion encoder being further coupled to an input of the text prediction network;
the inputting the target detection data into a target image processing model to obtain an image processing result output by the target image processing model includes:
under the condition that the image description information is the designated position information, inputting the image to be detected and the designated position information into the visual encoder so as to obtain image characteristics output by the visual encoder and area position characteristics of the reference expression generation area;
acquiring a preset initial mask text, and inputting the initial mask text into the text encoder to obtain mask text characteristics output by the text encoder;
performing feature fusion on the image feature, the region position feature and the mask text feature through the fusion encoder to obtain a first target feature;
and generating a reference expression text of the image corresponding to the reference expression generation area according to the first target feature through the text prediction network.
3. The method according to claim 2, wherein the determining, by the text prediction network, the reference expression text of the image corresponding to the reference expression generation area according to the first target feature comprises:
determining a first word referring to an expression text according to the first target feature through the text prediction network;
updating the initial mask text according to the first word;
and determining other words in the reference expression text according to the updated initial mask text, the image features and the region position features to obtain the reference expression text.
4. The method of claim 2, wherein inputting the target detection data into a target image processing model to obtain an image processing result output by the target image processing model, further comprises:
under the condition that the image description information is the description text, inputting the image to be detected into the visual encoder to obtain the image characteristics output by the visual encoder, and inputting the description text into the text encoder to obtain the description text characteristics output by the text encoder;
inputting the image feature and the description text feature into the fusion encoder to obtain a second target feature output by the fusion encoder;
and inputting the second target characteristic into the position detection network to acquire the target position of the expression object output by the position detection network in the image to be detected.
5. The method of claim 4, wherein the merging encoder comprises a plurality of decoding layers and a plurality of merging modules, the decoding layers are sequentially connected in series, the merging modules are sequentially connected in series, an input end of a first decoding layer of the decoding layers serves as an input end of the merging encoder, an output end of a last decoding layer of the decoding layers is coupled with an input end of the first merging module, and an output end of a last merging module of the merging modules serves as an output end of the merging encoder;
the performing feature fusion on the image feature, the region position feature and the mask text feature by the fusion encoder to obtain a first target feature includes:
under the condition that the image description information is the designated position information, fusing the region position feature and the mask text feature through the plurality of decoding layers to obtain a first fusion feature;
performing attention operation on the first fusion feature and the region position feature through the first fusion module to obtain a first to-be-determined feature;
and determining the first target feature through other fusion modules except the first fusion module in the plurality of fusion modules according to the first to-be-determined feature and the region position feature.
6. The method according to claim 5, wherein the determining the first target feature by a fusion module other than the first fusion module of the plurality of fusion modules according to the first to-be-determined feature and the region-location feature comprises:
performing attention operation on the specified undetermined feature and the region position feature output by the previous fusion module aiming at each fusion module except the first fusion module in the multiple fusion modules to obtain a target undetermined feature output by the current fusion module;
and taking the target undetermined characteristic output by the last fusion module as the first target characteristic.
7. The method of claim 5, wherein inputting the image feature and the descriptive text feature into the fusion encoder to obtain a second target feature output by the fusion encoder comprises:
under the condition that the image description information is the description text, fusing the image features and the description text features through the plurality of decoding layers to obtain second fusion features;
and fusing the second fusion characteristic and the image characteristic through the plurality of fusion modules to obtain the second target characteristic.
8. The method according to claim 7, wherein the fusion module comprises a self-attention layer, an image mutual attention layer, a region mutual attention layer, and a region prediction layer, wherein an input of the self-attention layer serves as an input of the fusion module, an output of the self-attention layer is coupled to an input of the image mutual attention layer, an output of the image mutual attention layer is coupled to an input of the region prediction layer, an output of the image mutual attention layer is further coupled to an input of the region mutual attention layer, an output of the region prediction layer is coupled to an input of the region mutual attention layer, and an output of the region mutual attention layer serves as an output of the fusion module;
the performing, by the first fusion module, attention operation on the first fusion feature and the region position feature to obtain a first predetermined feature includes:
acquiring a first attention feature corresponding to the first fusion feature through the self-attention layer;
performing multi-head attention operation on the first attention feature and the image feature through the image mutual attention layer to obtain a second attention feature;
performing multi-head attention operation on the second attention feature and the region position feature through the region mutual attention layer to obtain a third attention feature;
determining the first to-be-determined feature according to the third attention feature.
9. The method of claim 8, wherein said fusing, by the plurality of fusion modules, the second fused feature and the image feature to obtain the second target feature comprises:
performing attention operation on the second fusion feature and the image feature through the first fusion module to obtain a second undetermined feature;
determining the second to-be-determined feature through other fusion modules except the first fusion module in the multiple fusion modules according to the second to-be-determined feature and the image feature;
and determining the second target feature through other fusion modules except the first fusion module in the plurality of fusion modules according to the second to-be-determined feature and the second image feature.
10. The method of claim 9, wherein said performing, by said first fusion module, attention to said second fused feature and said image feature to obtain a second pending feature comprises:
performing attention operation on the second fusion feature through the self-attention layer in the first fusion module to obtain a first target attention feature;
performing multi-head attention operation on the image feature and the first target attention feature through the image mutual attention layer in the first fusion module to obtain a second target attention feature;
determining, by the regional prediction layer in the first fusion module, a predicted regional image feature from the second target attention feature;
performing multi-head attention operation on the image features, the second target attention features and the predicted region image features through a region mutual attention layer in the first fusion module to obtain third target attention features;
determining the second candidate feature from the third target attention feature.
11. The method according to claim 10, wherein the regional prediction layer is a multi-layer perceptron network, and said determining, by the regional prediction layer in the first fusion module, a predicted regional image feature from the second target attention feature comprises:
determining the target probability of each unit region belonging to the region where the reference expression object is located according to the full-text features in the second target attention features through the multilayer perceptron network;
and taking the image feature corresponding to the unit area with the target probability greater than or equal to a preset probability threshold value as the image feature of the prediction area.
12. The method of any of claims 1-11, wherein the target image processing model is trained by:
acquiring a plurality of pre-training data sets with different granularities, wherein each pre-training data set comprises a plurality of groups of training data, each group of training data comprises a sample image, a reference expression generation sample region and a reference expression text sample corresponding to the reference expression generation sample region, and each reference expression text sample comprises a preset mask and text marking data of the preset mask;
pre-training a preset initial model by taking the pre-training data sets with different granularities as training data to obtain an image processing model to be determined;
and acquiring a target training data set of a target granularity, and carrying out fine training on the to-be-determined image processing model by taking the target training data set as training data to obtain the target image processing model.
13. The method according to claim 12, wherein the pre-training a preset initial model with the pre-training data sets of different granularities as training data to obtain a pending image processing model comprises:
sequentially inputting each group of training data in a plurality of pre-training data sets with different granularities into the preset initial model to obtain predicted text data and predicted boundary data corresponding to the training data;
calculating a first loss value through a first loss function according to the predicted text data and the text marking data of the preset mask;
calculating a second loss value through a second loss function according to the prediction boundary data and the reference expression generation sample region, and determining a third loss value of a third loss function according to the annotated area mask and the predicted area mask;
determining a fourth loss value through a fourth loss function according to the second loss value and the third loss value;
and performing iterative training on the preset initial model according to the first loss value and the fourth loss value to obtain the pending image processing model.
14. An image processing apparatus, characterized in that the apparatus comprises:
the acquisition module is configured to acquire target detection data, wherein the target detection data comprises an image to be detected and image description information of the image to be detected, and the image description information is appointed position information of an expression generation area in the image to be detected or description text of an expression object in the image to be detected;
and the determining module is configured to input the target detection data into a target image processing model to obtain an image processing result output by the target image processing model, wherein the target image processing model is used for outputting a reference expression text of the image corresponding to the reference expression generation region in the case that the image description information is the specified position information, and outputting a target position of the reference expression object in the image to be detected in the case that the image description information is the description text.
15. A computer-readable medium, on which a computer program is stored, which program, when being executed by processing means, is adapted to carry out the steps of the method of any one of claims 1 to 13.
16. An electronic device, comprising:
a storage device having a computer program stored thereon;
processing means for executing the computer program in the storage means to carry out the steps of the method according to any one of claims 1 to 13.
CN202211204451.8A 2022-09-29 2022-09-29 Image processing method, device, readable medium and electronic equipment Pending CN115578570A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211204451.8A CN115578570A (en) 2022-09-29 2022-09-29 Image processing method, device, readable medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211204451.8A CN115578570A (en) 2022-09-29 2022-09-29 Image processing method, device, readable medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN115578570A true CN115578570A (en) 2023-01-06

Family

ID=84582985

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211204451.8A Pending CN115578570A (en) 2022-09-29 2022-09-29 Image processing method, device, readable medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN115578570A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115830039A (en) * 2023-02-09 2023-03-21 阿里巴巴(中国)有限公司 Image processing method and device
CN116543076A (en) * 2023-07-06 2023-08-04 腾讯科技(深圳)有限公司 Image processing method, device, electronic equipment and storage medium

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115830039A (en) * 2023-02-09 2023-03-21 阿里巴巴(中国)有限公司 Image processing method and device
CN115830039B (en) * 2023-02-09 2023-05-23 阿里巴巴(中国)有限公司 Image processing method and device
CN116543076A (en) * 2023-07-06 2023-08-04 腾讯科技(深圳)有限公司 Image processing method, device, electronic equipment and storage medium
CN116543076B (en) * 2023-07-06 2024-04-05 腾讯科技(深圳)有限公司 Image processing method, device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN115578570A (en) Image processing method, device, readable medium and electronic equipment
CN111915480B (en) Method, apparatus, device and computer readable medium for generating feature extraction network
CN113947147B (en) Training method, positioning method and related device of target map model
CN113313064A (en) Character recognition method and device, readable medium and electronic equipment
CN112883968B (en) Image character recognition method, device, medium and electronic equipment
CN113449070A (en) Multimodal data retrieval method, device, medium and electronic equipment
CN112883967B (en) Image character recognition method, device, medium and electronic equipment
JP2022078310A (en) Image classification model generation method, device, electronic apparatus, storage medium, computer program, roadside device and cloud control platform
CN116310582A (en) Classification model training method, image classification method, device, medium and equipment
CN115908640A (en) Method and device for generating image, readable medium and electronic equipment
CN112712036A (en) Traffic sign recognition method and device, electronic equipment and computer storage medium
CN115294501A (en) Video identification method, video identification model training method, medium and electronic device
CN112330788A (en) Image processing method, image processing device, readable medium and electronic equipment
CN116166271A (en) Code generation method and device, storage medium and electronic equipment
CN112883966B (en) Image character recognition method, device, medium and electronic equipment
CN114067327A (en) Text recognition method and device, readable medium and electronic equipment
CN115375657A (en) Method for training polyp detection model, detection method, device, medium, and apparatus
CN115984868A (en) Text processing method, device, medium and equipment
CN116258911A (en) Training method, device, equipment and storage medium for image classification model
CN115640815A (en) Translation method, translation device, readable medium and electronic equipment
CN115375655A (en) Training method, detection method, device, medium and equipment of polyp detection model
CN115249361A (en) Instructional text positioning model training, apparatus, device, and medium
CN114724164A (en) Text recognition method, device, medium and equipment
CN114463768A (en) Form recognition method and device, readable medium and electronic equipment
CN114004229A (en) Text recognition method and device, readable medium and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination