WO2025218370A1 - 数据处理方法、模型训练方法、装置、设备、介质及程序产品 - Google Patents

数据处理方法、模型训练方法、装置、设备、介质及程序产品

Info

Publication number
WO2025218370A1
WO2025218370A1 PCT/CN2025/080393 CN2025080393W WO2025218370A1 WO 2025218370 A1 WO2025218370 A1 WO 2025218370A1 CN 2025080393 W CN2025080393 W CN 2025080393W WO 2025218370 A1 WO2025218370 A1 WO 2025218370A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
sample
sub
feature
target
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
PCT/CN2025/080393
Other languages
English (en)
French (fr)
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.)
Tencent Technology (Shenzhen) Co Ltd
Original Assignee
Tencent Technology (Shenzhen) 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 Tencent Technology (Shenzhen) Co Ltd filed Critical Tencent Technology (Shenzhen) Co Ltd
Publication of WO2025218370A1 publication Critical patent/WO2025218370A1/zh
Anticipated expiration legal-status Critical
Pending legal-status Critical Current

Links

Classifications

    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00—Arrangements for image or video recognition or understanding
    • G06V10/70—Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/77—Processing 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/80—Fusion, i.e. combining data from various sources at the sensor level, preprocessing level, feature extraction level or classification level
    • G06V10/806—Fusion, i.e. combining data from various sources at the sensor level, preprocessing level, feature extraction level or classification level of extracted features
    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T9/00—Image coding
    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00—Arrangements for image or video recognition or understanding
    • G06V10/40—Extraction of image or video features
    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00—Arrangements for image or video recognition or understanding
    • G06V10/70—Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/77—Processing 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/774—Generating sets of training patterns; Bootstrap methods, e.g. bagging or boosting
    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00—Arrangements for image or video recognition or understanding
    • G06V10/70—Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/77—Processing 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/80—Fusion, i.e. combining data from various sources at the sensor level, preprocessing level, feature extraction level or classification level

Definitions

  • the embodiments of the present application relate to the field of computer technology, and in particular to a data processing method, a model training method, an apparatus, a device, a medium, and a program product.
  • Artificial intelligence can be used to realize interactive tasks with users. For example, a user can provide an image and put forward requirements for the image. The artificial intelligence model can then process the image according to the user's needs.
  • the embodiments of the present application provide a data processing method, model training method, apparatus, device, medium, and program product that can improve the adaptability of the data processing method.
  • the technical solution is as follows:
  • an embodiment of the present application provides a data processing method, performed by an electronic device, the method comprising:
  • each sub-image For each sub-image, encoding the sub-image by using the image encoding and decoding model to obtain a first image feature of the sub-image, and fusing the first image feature with the first position feature to obtain a second image feature of the sub-image;
  • the third image feature is decoded by the image encoding and decoding model to obtain a second image.
  • an embodiment of the present application provides a model training method performed by an electronic device, the method comprising:
  • each first sample sub-image For each first sample sub-image, encoding the first sample sub-image using the image encoding and decoding model to obtain a first sample image feature of the first sample sub-image, and fusing the first sample image feature with the first sample position feature to obtain a second sample image feature of the first sample sub-image;
  • the initial processing model is trained to obtain a task processing model for processing the target task.
  • an embodiment of the present application provides a data processing device, the device comprising:
  • An acquisition module configured to acquire a first image to be processed in a target task
  • an image processing module configured to divide the first image into a plurality of sub-images and obtain a first position feature of each sub-image in the first image, wherein the resolution of each sub-image is equal to a target resolution of images that can be processed by the trained image encoding and decoding model;
  • an encoding module configured to encode each sub-image using the image encoding and decoding model to obtain a first image feature of the sub-image, and fuse the first image feature with the first position feature to obtain a second image feature of the sub-image;
  • a feature processing module configured to process the second image features of the plurality of sub-images using a trained task processing model to obtain third image features
  • a decoding module is used to decode the third image feature through the image encoding and decoding model to obtain a second image.
  • an embodiment of the present application provides a model training device, the device comprising:
  • an acquisition module configured to acquire a first sample image; based on a target task, process the first sample image to obtain a target sample image, and obtain target sample image features of the target sample image;
  • an image processing module configured to divide the first sample image into a plurality of first sample sub-images, and obtain a first sample position feature of each first sample sub-image in the first sample image, wherein the resolution of each first sample sub-image is equal to a target resolution of images that can be processed by the trained image encoding and decoding model;
  • an encoding module configured to encode each first sample sub-image using the image encoding and decoding model to obtain a first sample image feature of the first sample sub-image, and fuse the first sample image feature with the first sample position feature to obtain a second sample image feature of the first sample sub-image;
  • a feature processing module configured to process the second sample image features of the plurality of first sample sub-images using an initial processing model to obtain third sample image features
  • the first training module is used to train the initial processing model based on the third sample image feature and the target sample image feature to obtain a task processing model for processing the target task.
  • an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor to implement the operations performed by the data processing method or model training method described in the above aspects.
  • an embodiment of the present application provides a computer-readable storage medium, which stores at least one computer program, and the at least one computer program is loaded and executed by a processor to implement the operations performed by the data processing method or model training method described in the above aspects.
  • an embodiment of the present application provides a computer program product, including a computer program, which is loaded and executed by a processor to implement the operations performed by the data processing method or model training method described in the above aspects.
  • FIG1 is a schematic diagram of an implementation environment provided by an embodiment of the present application.
  • FIG2 is a flow chart of a data processing method provided in an embodiment of the present application.
  • FIG3A is a flowchart of another data processing method provided in an embodiment of the present application.
  • FIG3B is a schematic diagram of the architecture of a data processing model provided in an embodiment of the present application.
  • FIG4 is a flow chart of another data processing method provided in an embodiment of the present application.
  • FIG5 is a schematic diagram of a multimodal data sequence provided in an embodiment of the present application.
  • FIG6 is a schematic diagram of a data processing method provided in an embodiment of the present application.
  • FIG7 is a schematic diagram of an artificial intelligence-based interaction method provided in an embodiment of the present application.
  • FIG8 is a flow chart of a model training method provided in an embodiment of the present application.
  • FIG9 is a flowchart of a training method for a task processing model provided in an embodiment of the present application.
  • FIG10 is a flowchart of another method for training a task processing model according to an embodiment of the present application.
  • FIG11 is a flowchart of a method for training an image encoding and decoding model provided in an embodiment of the present application
  • FIG12 is a schematic diagram of a training method for an image encoding and decoding model provided in an embodiment of the present application.
  • FIG13 is a comparison diagram of reconstruction results of an image encoding and decoding model provided in an embodiment of the present application.
  • FIG14 is a flowchart of a pre-training method for an initial processing model provided in an embodiment of the present application.
  • FIG15 is a comparison diagram of data processing results provided in an embodiment of the present application.
  • FIG16 is a schematic structural diagram of a data processing device provided in an embodiment of the present application.
  • FIG17 is a schematic structural diagram of a model training device provided in an embodiment of the present application.
  • FIG18 is a schematic structural diagram of another model training device provided in an embodiment of the present application.
  • FIG19 is a schematic structural diagram of a terminal provided in an embodiment of the present application.
  • FIG20 is a schematic diagram of the structure of a server provided in an embodiment of the present application.
  • first may be referred to as a second image
  • second image may be referred to as a first image without departing from the scope of this application.
  • At least one refers to one or more than one.
  • the at least one image can be one image, two images, three images, or any other integer greater than or equal to one.
  • Multiple refers to two or more than two.
  • the multiple images can be two images, three images, or any other integer greater than or equal to two.
  • ach refers to each of the at least one.
  • ach image refers to each image in the multiple images. If the multiple images are three images, “each image” refers to each of the three images.
  • the information including but not limited to user device information, user personal information, etc.
  • data including but not limited to data used for analysis, stored data, displayed data, etc.
  • signals including but not limited to signals transmitted between user terminals and other devices, etc.
  • the electronic device is a computer device, for example, a terminal or a server.
  • the server is an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.
  • the terminal is a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, smart voice interaction device, smart home appliance and car terminal, etc., but is not limited to this.
  • the computer program involved in the embodiments of the present application can be deployed and executed on an electronic device, or on multiple electronic devices located at one location, or on multiple electronic devices distributed at multiple locations and interconnected through a communication network.
  • Multiple electronic devices distributed at multiple locations and interconnected through a communication network can constitute a blockchain system.
  • Figure 1 is a schematic diagram of an implementation environment provided by an embodiment of the present application.
  • the implementation environment includes a terminal 101 and a server 102.
  • the terminal 101 and the server 102 are connected via a wireless or wired network.
  • the server 102 uses the model training method provided in the embodiment of the present application to train the image encoding and decoding model and the task processing model, and stores the trained image encoding and decoding model and the task processing model.
  • the image encoding and decoding model is used to encode and decode images
  • the task processing model is used to generate features related to the target task.
  • terminal 101 sends a target task carrying a first image to server 102.
  • Server 102 receives the target task, encodes the first image using the image encoding and decoding model to obtain image features, processes the image features using the task processing model to obtain processed image features, and then decodes the processed image features using the image encoding and decoding model to obtain a second image.
  • the second image is the result of processing the first image according to the target task.
  • Server 102 returns the second image to terminal 101, which displays the second image to the user.
  • the server 102 sends the image coding model and the task processing model to the terminal 101.
  • the terminal 101 encodes the first image through the image coding model for the target task carrying the first image to obtain image features, processes the image features through the task processing model to obtain processed image features, and then decodes the processed image features through the image coding model to obtain a second image.
  • the terminal 101 is installed with a target application served by the server 102.
  • the server 102 sends the image coding and decoding model and the task processing model to the target application.
  • the terminal 101 can process the images and data required for processing in the target task in the target application through the image coding and decoding model and the task processing model to obtain the processing results.
  • FIG2 is a flow chart of a data processing method provided by an embodiment of the present application, which is executed by an electronic device, which may be the terminal 101 or the server 102 in FIG1 .
  • the method includes:
  • the first image is an image that needs to be processed in the target task, and the target task includes a task of processing the first image.
  • the target task can be any type of task, such as an image editing task, a slideshow generation task, etc.
  • the target task can include recognizing content in a first image, removing an object in the first image, or performing a cropping operation on the first image.
  • the embodiments of the present application do not limit the specific content of the target task.
  • the electronic device divides the first image based on the target resolution corresponding to the image coding and decoding model to obtain a plurality of sub-images, and the resolution of each sub-image is equal to the target resolution.
  • the resolution of the first image can be any resolution
  • the image coding and decoding model corresponds to a target resolution, which refers to the resolution of the image that can be processed by the image coding and decoding model, that is, the image coding and decoding model can only process images with a resolution equal to the target resolution.
  • the image coding model cannot directly process the first image.
  • the electronic device divides the first image based on the target resolution, that is, segments the first image, to obtain multiple sub-images, so that the resolution of each sub-image is equal to the target resolution.
  • the subsequent image coding model can encode and decode on a sub-image basis, so even if the resolution of the first image does not match the target resolution corresponding to the image coding model, the first image can still be processed.
  • sub-images are derived from the first image, their first image features contain the content of the sub-image within the first image, but do not contain information about the sub-image's location within the first image. Therefore, to preserve the location information of each sub-image within the first image, the electronic device also obtains a first position feature for each sub-image, which indicates the sub-image's location within the first image.
  • each sub-image encodes the sub-image using an image encoding and decoding model to obtain a first image feature of the sub-image, and fuse the first image feature with the first position feature to obtain a second image feature of the sub-image.
  • the image encoding and decoding model is used to encode and decode an image.
  • the image encoding and decoding model includes an image encoding network and an image decoding network.
  • the image encoding network is used to encode the image to obtain image features; the image decoding network is used to decode the image features to obtain the image.
  • the electronic device After the electronic device divides and obtains multiple sub-images, for any sub-image, the electronic device inputs the sub-image into the image coding network in the image coding and decoding model, and the image coding network encodes the sub-image and outputs the first image feature of the sub-image.
  • the electronic device fuses the sub-image's first image feature with its first position feature to obtain a second image feature for the sub-image.
  • This second image feature contains both the content of the sub-image within the first image and its position within the first image. Therefore, the second image features of multiple sub-images can fully represent the features of the entire first image, avoiding the problem of position information loss caused by image segmentation.
  • the task processing model is used to generate features related to the target task. For example, if the target task involves deblurring an image, the task processing model can generate features for the deblurred image. For another example, if the target task involves style transfer, the task processing model can generate features for the style-transferred image.
  • the electronic device After obtaining the second image features of each sub-image, the electronic device inputs the second image features of multiple sub-images into the task processing model, and the task processing model processes the second image features of the multiple sub-images, such as performing deep feature extraction, feature intersection, feature mapping, etc.
  • the task processing model outputs the third image feature, which is the feature of the second image required to be generated for the target task.
  • the electronic device After acquiring the third image feature, the electronic device inputs it into the image decoding network in the image encoding and decoding model.
  • the image decoding network then outputs a decoded second image.
  • This second image is the processing result required for the target task, that is, the image obtained by processing the first image according to the target task.
  • the method provided in the embodiment of the present application divides the image into multiple sub-images with a resolution equal to the target resolution when the image to be processed in the target task does not match the target resolution corresponding to the image coding and decoding model, so that the sub-images can be directly encoded by the image coding and decoding model.
  • the position features of the sub-images are fused into the image features of the sub-images, thereby retaining the position information of each sub-image in the complete image.
  • the image features of each sub-image are processed by the task processing model, and the processed image features are decoded to obtain a second image, which is the processing result of the target task. Therefore, by dividing the image and retaining the position information, the image coding and decoding model can be applied to images of any resolution, thereby improving the adaptability of the data processing method.
  • the electronic device when the resolution of the first image is greater than the target resolution, the electronic device can not only encode the multiple sub-images obtained by dividing the first image, but also encode the first image after scaling it to the target resolution.
  • the electronic device can not only encode the multiple sub-images obtained by dividing the first image, but also encode the first image after scaling it to the target resolution.
  • FIG3A is a flowchart of another data processing method provided by an embodiment of the present application, which is executed by an electronic device, which may be the terminal 101 or the server 102 in FIG1 .
  • the method includes:
  • the electronic device receives a processing request for a target task, the processing request for the target task carrying the first image, the processing request for the target task being used to instruct processing the first image according to the target task.
  • the first image can be an image of any resolution.
  • the image encoding and decoding model can only process images with a resolution equal to the target resolution. If the resolution of the first image is greater than the target resolution, the image encoding and decoding model cannot directly process the first image. Therefore, before scaling the first image, in step 302, the first image is divided into sub-images with a resolution equal to the target resolution. This allows the method described in the embodiments of the present application to process images of any size and aspect ratio.
  • the electronic device determines multiple division strategies, which include a first number of divisions, a second number of divisions, and a division ratio; based on the aspect ratio of the first image, determines a target division strategy among the multiple division strategies, and the division ratio in the target division strategy is closest to the aspect ratio; based on the target division strategy and the target resolution, divides the first image to obtain multiple sub-images.
  • the first number of divisions refers to the number of divisions of the image in the length direction
  • the second number of divisions refers to the number of divisions of the image in the width direction
  • the division ratio refers to the ratio between the first number of divisions and the second number of divisions.
  • multiple division strategies include Division Strategy 1, Division Strategy 2, and Division Strategy 3.
  • the division ratio in Division Strategy 1 is 5:1
  • the division ratio in Division Strategy 2 is 4:3, and the division ratio in Division Strategy 3 is 16:9.
  • the aspect ratio of the first image is 16:9. Therefore, the division ratio in Division Strategy 3 is closest to the aspect ratio of the first image, and therefore Division Strategy 3 is determined as the target division strategy.
  • the first image can be divided according to the first division number, the second division number and the target resolution in the target division strategy, thereby obtaining a plurality of sub-images.
  • multiple division strategies to be selected are provided.
  • the division strategy that is most suitable for the aspect ratio of the first image is selected as the target division strategy, and then the division is performed based on the target division strategy.
  • the electronic device divides the first image based on the target division strategy and the target resolution to obtain multiple sub-images, including: generating a target size based on the target division strategy and the target resolution; upsampling the first image based on the target size to obtain a first intermediate image; and dividing the first intermediate image according to the target division strategy to obtain multiple sub-images.
  • the number of first partitions is Nh
  • the number of second partitions is Nw
  • the target resolution is Ht ⁇ Wt
  • the target size includes length and width.
  • the target size length is equal to Nh*Ht
  • the target size width is equal to Nw*Wt.
  • the first image is upsampled to a first intermediate image such that the length of the first intermediate image is equal to the target size length Nh*Ht, and the width is equal to the target size width Nw*Wt.
  • the first intermediate image is partitioned into Nh parts in the length direction and Nw parts in the width direction, thereby obtaining multiple sub-images.
  • a target size is first generated based on a target division strategy and a target resolution.
  • the target size is the size required to divide a sub-image of the target resolution according to the division strategy.
  • the first image is upsampled to a first intermediate image of the target size, which can ensure that the resolution of each divided sub-image is equal to the target resolution.
  • For each sub-image encode the sub-image using an image encoding and decoding model to obtain a first image feature of the sub-image, and fuse the first image feature with the first position feature to obtain a second image feature of the sub-image.
  • the image encoding and decoding model includes an image encoding network and an image decoding network.
  • the image encoding network can be VAE (Variational AutoEncoder), ViT (Visual Tokenizer), etc.
  • VAE Variational AutoEncoder
  • ViT Virtual Tokenizer
  • the embodiment of the present application does not limit the type of the image encoding network.
  • the electronic device inputs the sub-image into the image coding network in the image coding and decoding model, and the image coding network encodes the sub-image and outputs the first image feature of the sub-image, where the first image feature refers to the image feature of the sub-image.
  • the first position feature of each sub-image is added to the respective first image features to obtain the second image feature of each sub-image, so that the second image includes both the content of the sub-image itself and the position information of the sub-image in the complete first image.
  • the electronic device obtains a first position feature of each sub-image in the first image, including: determining, for each sub-image, coordinate information of the sub-image in the first image; and mapping the coordinate information based on mapping parameters to obtain the first position feature of the sub-image, where the mapping parameters are obtained through training.
  • the mapping process refers to multiplying the mapping parameters by the coordinate information.
  • the mapping parameters include left mapping parameters, right mapping parameters, upper mapping parameters, and lower mapping parameters.
  • the coordinate information includes normalized horizontal and vertical coordinates.
  • the electronic device can use the following formula to determine the first position feature:
  • mapping parameters are all vectors.
  • the sub-image includes multiple image blocks, which are the smallest units in the image, for example, image blocks are pixels, etc.
  • the first position feature of the sub-image includes the position feature of each image block in the sub-image.
  • the electronic device determines the coordinate information of each image block in the sub-image in the first image, maps the coordinate information of each image block based on the mapping parameters, and obtains the position feature of each image block.
  • the first image feature of the sub-image includes the image feature of each image block, and the electronic device fuses the image feature and the position feature of each image block in the sub-image to obtain the image feature of each image block, and fuses the image features of multiple image blocks in the sub-image to obtain the second image feature of the sub-image.
  • the coordinate information of the sub-image in the first image refers to the coordinate information of the center point of the sub-image in the first image.
  • the first image in addition to encoding the sub-image, can also be reduced to a second intermediate image with a target resolution, and then the second intermediate image can be encoded. This is beneficial for retaining the global visual context information of the first image and improving the accuracy of subsequent processing based on image features.
  • the image coding network Since the resolution of the second intermediate image is equal to the target resolution, the image coding network is able to process the second intermediate image.
  • the electronic device inputs the second intermediate image into an image coding network, and the image coding network encodes the second intermediate image and outputs image features of the second intermediate image.
  • the electronic device After obtaining the second image features of each sub-image and the image features of the second intermediate image, the electronic device inputs the second image features of the multiple sub-images and the image features of the second intermediate image into the task processing model.
  • the task processing model processes the second image features of the multiple sub-images and the image features of the second intermediate image, such as performing deep feature extraction, feature intersection, feature mapping, etc.
  • the task processing model outputs the third image features.
  • the task processing model is an LLM (Large Language Models) or a multimodal model, etc.
  • LLM Large Language Models
  • the embodiments of the present application do not limit the type of task processing model.
  • the image encoding and decoding model includes an image decoding network
  • the electronic device decodes the third image feature through the image encoding and decoding model to obtain the second image, including: performing feature conversion on the first image through the image decoding network to obtain a query feature; performing feature conversion on the third image feature through the image decoding network to obtain a key feature and a value feature; fusing the query feature, key feature and value feature to obtain a fused feature; and decoding the fused feature through the image decoding network to obtain the second image.
  • the image decoding network includes at least one cross-attention layer, for example, the image decoding network includes four cross-attention layers.
  • the electronic device inputs the first image along with the noise vector into the image decoding network, and the image decoding network performs feature conversion on the first image and the noise vector, and uses the features obtained by the feature conversion as the query features in the attention mechanism.
  • the electronic device inputs the third image feature into the image decoding network, and the image decoding network performs feature conversion on the third image feature, and uses the features obtained by the feature conversion as the key features and value features in the attention mechanism.
  • the image decoding network includes a conversion matrix, which is used to perform the above-mentioned feature conversion, that is, to convert the input features into query features, key features, and value features in the attention mechanism.
  • the first image when decoding the third image feature, is introduced as a reference through steps 304-306, so that in the process of decoding the third image feature into the second image, the fine-grained information in the first image can be learned, avoiding the loss of the original content in the first image, which is conducive to improving the quality and effect of the generated second image and realizing fine-grained image generation.
  • the image coding and decoding model can decode a fine-grained image; if no reference image is introduced, that is, the method described in Figure 2 is adopted, the image coding and decoding model can decode a coarse-grained image, thereby improving flexibility and realizing the generation of multi-granularity images.
  • the third image features may be uniformly pooled, and the pooled third image features may be decoded through an image decoding network to obtain a second image.
  • the embodiment of the present application is described by taking the image coding and decoding model and the task processing model as two different models as examples.
  • the image coding and decoding model and the task processing model can also be regarded as different parts of an overall model.
  • the overall model is called a data processing model.
  • the data processing model 310 includes an image coding network 311, a task processing model 312, and an image decoding network 313, wherein the image coding network 311 and the image decoding network 313 constitute an image coding and decoding model, and the image coding network 311 and the image decoding network 313 are respectively connected to the task processing model 312.
  • multiple sub-images of a first image are input into the image encoding network 311, which outputs first image features.
  • the first image features are fused with the first position features to obtain second image features, which serve as input to the task processing model 312.
  • the task processing model 312 then outputs third image features, which are then input into the image decoding network 313, ultimately outputting the second image.
  • the target task can also be a multimodal task.
  • the data to be processed in the target task also includes non-image data.
  • the detailed process of the data processing method is shown in the embodiment shown in Figure 4 below.
  • Figure 4 is a flowchart of another data processing method provided by an embodiment of the present application.
  • the embodiment of the present application is executed by an electronic device, which can be the terminal 101 or server 102 in Figure 1. Referring to Figure 4, the method includes:
  • the target task is a multimodal task, which refers to a task of processing multiple types of data.
  • the first non-image data refers to other data besides images.
  • the first non-image data can be text, video or audio, etc., and the embodiment of the present application does not limit this.
  • the first non-image data is the first text.
  • the first image and the first text can be an image description pair, structured image-text data, interleaved image-text data, OCR (Optical Character Recognition) data, etc.
  • An image description pair refers to an image and text describing the image content; structured image-text data refers to an image and text that provides a structured description of the image; interleaved image-text data refers to an image and text interleaved with text; and OCR data refers to an image and text obtained by recognizing text within the image.
  • Figure 5 is a schematic diagram of a multimodal data sequence provided in an embodiment of the present application.
  • the data to be processed in the multimodal task is a multimodal data sequence, which includes at least one image and at least one text.
  • the multimodal data sequence includes image 501, text 502, and image 503.
  • each sub-image encode the sub-image using an image encoding and decoding model to obtain a first image feature of the sub-image, and fuse the first image feature with the first position feature to obtain a second image feature of the sub-image.
  • step 402 to step 403 is the same as the process of step 302 to step 303 above, and will not be repeated here.
  • the electronic device extracts features from the first non-image data using a non-image encoding and decoding model to obtain first data features.
  • the non-image encoding and decoding model is used to process non-image data. For example, if the first non-image data is text, the non-image encoding and decoding model is a text encoding and decoding model. If the first non-image data is audio, the non-image encoding and decoding model is an audio encoding and decoding model.
  • the non-image encoding and decoding model includes a non-image encoding network and a non-image decoding network. The electronic device extracts features from the first non-image data using the non-image encoding network to obtain first data features.
  • the first non-image data is first text
  • the first data feature is a text feature, which may be an embedding vector, etc.
  • the electronic device maps each word in the first text to its corresponding embedding vector by querying a dictionary, where the dictionary includes a correspondence between multiple words and their embedding vectors.
  • the electronic device After obtaining the second image features of each sub-image and the first data features of the first non-image data, the electronic device inputs the second image features and first data features of multiple sub-images into the task processing model.
  • the task processing model processes the input features, such as deep feature extraction, feature intersection, feature mapping, etc., and outputs the third image feature and the second data feature.
  • the third image feature is the feature of the second image required to be generated for the target task
  • the second data feature is the feature of the non-image data required to be generated for the target task.
  • the first non-image data is text
  • the text includes coordinate information of an object in the first image.
  • the electronic device converts the coordinate information into a second position feature, fuses the first data feature with the second position feature to obtain a third data feature, and processes the second image features and the third data features of the multiple sub-images using the task processing model to obtain the third image feature and the second data feature.
  • the coordinate information is converted into a second position feature, which can represent the position of the object in the image.
  • the electronic device obtains a plurality of preset candidate position markers, each of which indicates a different position in the image. Based on the coordinate information, the electronic device determines a target position marker from the plurality of candidate position markers, where the position in the image indicated by the target position marker is the same as the position in the image indicated by the coordinate information. The electronic device uses the target position marker as the second position feature and adds the second position feature to the first data feature.
  • the electronic device before inputting the second image features of the multiple sub-images and the first data features of the first non-image data into the task processing model, the electronic device adds an image start marker before the second image features of the multiple sub-images and an image end marker after the second image features of the multiple sub-images to indicate the beginning and end of the image features, thereby distinguishing the image features from the data features.
  • the image start marker is "IMG”
  • the image end marker is "/IMG”.
  • step 406 is the same as that of step 307 above, and will not be described again here.
  • the electronic device decodes the second data feature using a non-image encoding and decoding model to obtain second non-image data.
  • the non-image encoding and decoding model is configured to process the non-image data.
  • the non-image encoding and decoding model includes a non-image encoding network and a non-image decoding network. The electronic device decodes the second data feature using the non-image decoding network to obtain the second non-image data.
  • the first non-image data is a first text
  • the second non-image data is a second text
  • the second data feature is a text feature, which may be an embedding vector, etc.
  • the electronic device maps the text feature to its corresponding word by querying a dictionary, thereby obtaining the second text.
  • the dictionary includes a correspondence between multiple words and their embedding vectors.
  • the task processing model can process the characteristics of multimodal data, improve the processing capability of the task processing model, and enable the task processing model to be applicable to various types of data in various scenarios, further improving the adaptability of the data processing method.
  • FIG6 is a schematic diagram of a data processing method provided in an embodiment of the present application.
  • the data to be processed in the target task includes a first image and a first text.
  • the first image is divided and scaled to obtain an image sequence 601.
  • Image sequence 601 includes sub-images 6012-6015 obtained by the division and a second intermediate image 6011 obtained by the reduction.
  • the first text is " ⁇ (or in English, Lucky likes playing in the park)".
  • Each image 6011-6015 in image sequence 601 is encoded by an image coding network (not shown) in an image coding and decoding model to obtain image features 602. After encoding the first text, text features 603 are obtained.
  • the electronic device also randomly generates image features 604, adds an image start marker "IMG” before image features 602 and 604, respectively, adds an image end marker “/IMG” after image features 602 and 604, respectively, and adds a start marker "BOI” before the entire input feature.
  • the electronic device inputs the aforementioned features and tags into the task processing model, which outputs predicted image features 605 and text features 606.
  • the electronic device then inputs these image features 605 into the image decoding network within the image encoding and decoding model, which outputs a second image 607.
  • the electronic device decodes these text features 606 to obtain a second text.
  • These second image 607 and second text are the results of processing the first image and text according to the target task.
  • FIG 7 is a schematic diagram of an artificial intelligence-based interaction method provided by an embodiment of the present application.
  • the above-mentioned image encoding and decoding model and task processing model can realize the functions of the AI assistant, and users can interact with the AI assistant.
  • target task 701 the user inputs image 711 and the text "Show me a photo of the room after decoration", and the AI assistant outputs image 721 and the text "This is the photo provided for you.”
  • the user inputs image 712 and the text “Can you draw a colorful anime character based on the sketch?”
  • the AI assistant outputs image 722 and the text "This is the anime character I created for you.”
  • target task 703 the user inputs image 713 and the text "Can you create an illustration for this novel?”
  • the AI assistant outputs image 723 and the text "Of course, please enjoy this illustration.”
  • target task 704 the user inputs image 714 and the text "Can you turn this photo into a watercolor painting?”
  • the AI assistant outputs image 724 and the text
  • Figure 8 is a flow chart of a model training method provided in an embodiment of the present application.
  • the embodiment of the present application is performed by an electronic device, which can be the terminal 101 or the server 102 in Figure 1. Referring to Figure 8, the method includes:
  • the first sample image is a sample image to be processed in the target task.
  • the process of step 801 is the same as that of step 301 above, and will not be described in detail here.
  • the target sample image refers to the result of processing the first sample image according to the target task. For example, if the target task is to transfer the style of the first sample image to an anime style, then the target sample image refers to the image obtained by transferring the style of the first sample image to anime style. For example, if the target task is to remove an object from the first sample image, then the target sample image refers to the image obtained after removing the object from the first sample image.
  • the electronic device obtains a target sample image feature of the target sample image, including:
  • the image feature of the target sub-image and the second sample position feature are fused to obtain the target sample image feature of the target sub-image.
  • the process of the electronic device obtaining the target sample image features of each target sub-image in the target sample image is similar to the process of obtaining the second image features of each sub-image in the first image in the above embodiment, and will not be repeated here.
  • the training process of the image coding and decoding model is decoupled from the training process of the task processing model.
  • the embodiment shown in Figure 8 is the process of training the task processing model.
  • the image coding and decoding model refers to the trained model.
  • the training process of the image coding and decoding model is shown in the embodiment shown in Figure 11 below and is not explained here.
  • each first sample sub-image encodes the first sample sub-image using an image encoding and decoding model to obtain a first sample image feature of the first sample sub-image, and fuse the first sample image feature with the first sample position feature to obtain a second sample image feature of the first sample sub-image.
  • step 803 to step 804 is the same as the process of step 302 to step 303 above, and will not be repeated here.
  • the initial processing model is used to process features, such as deep feature extraction, feature intersection, feature mapping, etc.
  • the initial processing model is a pre-trained model.
  • the pre-training process of the initial processing model is described in the embodiment shown in FIG14 below and will not be described here.
  • the initial processing model is trained to obtain a task processing model for processing the target task.
  • the target sample image features are the result of processing the first sample image according to the target task, and the goal of the initial processing model is to obtain the target sample image features. That is, the closer the third sample image features generated by the initial processing model are to the target sample image features, the more accurate the training process of the initial processing model. Therefore, the electronic device trains the initial processing model based on the third sample image features and the target sample image features to obtain a task processing model, so that the image features output by the task processing model tend to the target sample image features.
  • the electronic device determines a loss parameter based on the third sample image features and the target sample image features, and trains the initial processing model based on the loss parameter to obtain a task processing model.
  • the loss parameter may be a cross entropy loss or a mean square error loss, etc., which is not limited in the embodiments of the present application.
  • the method provided in the embodiment of the present application divides the image into multiple sub-images with a resolution equal to the target resolution when the image to be processed in the target task does not match the target resolution corresponding to the image coding and decoding model, so that the sub-images can be directly encoded by the image coding and decoding model.
  • the position features of the sub-images are fused into the image features of the sub-images, thereby retaining the position information of each sub-image in the complete image.
  • the image features of each sub-image are processed by the initial processing model, and the model is trained based on the processed image features and the image features to be generated to obtain a task processing model for processing the target task. Therefore, by dividing the image and retaining the position information, the task processing model can be applied to images of any resolution, thereby improving the adaptability of the data processing method.
  • FIG9 is a flowchart of a method for training a task processing model according to an embodiment of the present application.
  • the method is performed by an electronic device, which may be the terminal 101 or the server 102 in FIG1 .
  • the method includes:
  • the target task is a multimodal task, which refers to a task of processing multiple types of data.
  • the first sample non-image data refers to other data besides images.
  • the first sample non-image data can be text, video or audio, etc., and the embodiment of the present application does not limit this.
  • step 901 is the same as that of step 401 above, and will not be repeated here.
  • the target sample image refers to the result of processing the first sample image according to the target task.
  • each first sample sub-image encodes the first sample sub-image using an image encoding and decoding model to obtain a first sample image feature of the first sample sub-image, and fuse the first sample image feature with the first sample position feature to obtain a second sample image feature of the first sample sub-image.
  • step 903 to step 904 is the same as the process of step 803 to step 804 above, and will not be repeated here.
  • step 905 is the same as that of step 404 above, and will not be repeated here.
  • the electronic device when the electronic device predicts the second sample data feature through the initial processing model, it obtains it in the manner of predicting the subsequent feature according to the preceding feature.
  • the first sample non-image data is the first sample text
  • the first sample data feature is the first sample text feature, which includes the first sample text feature of each sample word in the first sample text.
  • the electronic device sequentially inputs the second sample image features of multiple first sub-images and the first sample text features of multiple sample words into the initial processing model.
  • the initial processing model determines the second sample text feature of the first predicted word based on the feature preceding the first sample text feature of the first sample word, and determines the second sample text feature of the second predicted word based on the feature preceding the first sample text feature of the second sample word, and so on, until the second sample text features of all predicted words are output to constitute the second sample data feature. If the initial processing model is sufficiently accurate, then the second sample text features of the multiple predicted words predicted by the initial processing model should tend to the first sample text features of the multiple sample words.
  • the initial processing model is trained to obtain a task processing model.
  • the goal of the initial processing model is to generate target sample image features and first sample data features, that is, the closer the third sample image features generated by the initial processing model are to the target sample image features, and the closer the second sample data features generated by the initial processing model are to the first sample data features, the more accurate the model is.
  • the electronic device trains the initial processing model based on the third sample image features and the target sample image features, as well as the second sample data features and the first sample data features, to obtain a task processing model, so that the image features generated by the task processing model tend to the target sample image features, and the generated data features tend to the first sample data features.
  • the electronic device determines a first loss parameter based on the third sample image features and the target sample image features; determines a second loss parameter based on the second sample data features and the first sample data features; fuses the first loss parameter and the second loss parameter to obtain a fused loss parameter; and trains the initial processing model based on the fused loss parameter to obtain a task processing model.
  • the above loss parameters can be cross entropy loss or mean square error loss, etc., which are not limited in the embodiments of the present application.
  • FIG10 is a flowchart of another training method for a task processing model provided by an embodiment of the present application.
  • the data to be processed in the target task includes a first sample image and a first sample text.
  • the first sample image is divided and scaled to obtain an image sequence 1001.
  • Image sequence 1001 includes sub-images 10012-10015 obtained by division and a reduced image 10011.
  • the first sample text is " ⁇ (or Lucky likes playing in the park)".
  • Images 10011-10015 in image sequence 1001 are encoded by an image coding network (not shown) in an image coding and decoding model to obtain image features 1002.
  • the first text is encoded to obtain text features 1003.
  • the electronic device also randomly generates image feature 1004, adds an image start tag "IMG” in front of image feature 1002 and image feature 1004 respectively, adds an image end tag “/IMG” after image feature 1002 and image feature 1004 respectively, and adds a start tag "BOI” in front of the entire input feature.
  • the electronic device inputs the aforementioned features and labels into the initial processing model, which then outputs predicted image features 1005 and text features 1006.
  • the electronic device also obtains image features 1007 of the target sample image, determines a first loss parameter based on image features 1005 and 1007, and determines a second loss parameter based on text features 1006 and 1003.
  • the initial processing model is trained based on the first and second loss parameters to obtain a task processing model.
  • FIG11 is a flowchart of a method for training an image encoding and decoding model provided in an embodiment of the present application.
  • the embodiment of the present application is performed by an electronic device, which may be the terminal 101 or the server 102 in FIG1 .
  • the method includes:
  • the second sample image may be an image of any field, any type, and any resolution, and the embodiment of the present application does not limit the second sample image.
  • each second sample sub-image encode the second sample sub-image using the initial image encoding and decoding model to obtain a fourth sample image feature of the second sample sub-image, and fuse the fourth sample image feature with the third sample position feature to obtain a fifth sample image feature of the second sample sub-image.
  • the electronic device obtains a third sample position feature of each second sample sub-image in the second sample image, including:
  • the coordinate information is mapped based on preset mapping parameters to obtain the third sample position feature of the second sample sub-image.
  • step 1105 the initial image coding model and the preset mapping parameters are trained based on the difference between the third sample image and the second sample image.
  • the initial image encoding and decoding model includes an initial image encoding network and an initial image decoding network.
  • the initial image encoding network can be an initialized VAE or ViT, and the initial image decoding network includes multiple initialized cross-attention layers.
  • the preset mapping parameters refer to initial values of the left mapping parameter, the right mapping parameter, the upper mapping parameter, and the lower mapping parameter.
  • the electronic device obtains a reference sample image, and the reference sample image and the second sample image have part of the same content, that is, the two have the same content and different content;
  • the reference sample image is feature converted through the initial image coding and decoding model to obtain a sample query feature;
  • the fifth sample image feature of multiple second sample sub-images is feature converted through the initial image coding and decoding model to obtain a sample key feature and a sample value feature;
  • the sample query feature, the sample key feature and the sample value feature are fused to obtain a sample fusion feature;
  • the sample fusion feature is decoded through the initial image coding and decoding model to obtain a third sample image.
  • the reference sample image is an image obtained by adding a third dog to the second sample image.
  • the reference sample image is an image obtained by adding a bouquet of flowers to the second sample image.
  • the training objective of the image coding model is to reconstruct the second sample image. That is, the closer the third sample image generated by the image coding model is to the second sample image, the more accurate the model is. Therefore, the electronic device trains the initial image coding model based on the third sample image and the second sample image so that the image generated by the trained image coding model approaches the second sample image.
  • the electronic device determines a loss parameter based on the third sample image and the second sample image, and trains the initial image codec model based on the loss parameter to obtain a trained image codec model.
  • the loss parameter may be a cross entropy loss or a mean square error loss, etc., which is not limited in the embodiments of the present application.
  • this image codec model can be divided into two stages.
  • the initial image codec model is used to directly decode image features without introducing a reference image.
  • the initial image codec model is used to decode image features based on the reference image.
  • FIG12 is a schematic diagram of a training method for an image coding and decoding model provided in an embodiment of the present application.
  • the initial image coding and decoding model includes an image coding network 1210 and an image decoding network 1220 .
  • the original image A is encoded and decoded by the image encoding network 1210 and the image decoding network 1220, respectively, to obtain a reconstructed image B.
  • the image encoding network 1210 and the image decoding network 1220 are then trained based on the differences between the reconstructed image B and the original image A.
  • the differences here primarily refer to differences in semantic consistency.
  • noise is also input to the image decoding network 1220.
  • the original image C1 is encoded and decoded by the image encoding network 1210 and the image decoding network 1220, respectively.
  • the reference image C2 is introduced during decoding, resulting in a reconstructed image D.
  • the image encoding network 1210 and the image decoding network 1220 are then trained based on the differences between the reconstructed image D and the original image C1.
  • the differences in this case refer to differences in fine-grained semantic consistency.
  • the image decoding network 1220 also receives the reference image C2 and noise as input.
  • Figure 13 is a comparison diagram of the reconstruction results of an image encoding and decoding model provided by an embodiment of the present application.
  • the original image A1 is reconstructed using related technologies to obtain a reconstructed image B1.
  • the original image A1 is reconstructed using the method of the embodiment of the present application without introducing a reference image to obtain a reconstructed image B2.
  • the original image A1 is reconstructed using the method of the embodiment of the present application with the introduction of the reference image A2 to obtain a reconstructed image B3.
  • the image B3 reconstructed using the method of the embodiment of the present application with the introduction of the reference image is closer to the original image A1, and the reconstruction effect is better.
  • the embodiments of Figures 8 and 9 above train a task processing model based on the initial processing model, thereby obtaining a task processing model specifically used to perform a specific target task.
  • the initial processing model can be a pre-trained model.
  • the pre-training process of the initial processing model is similar to the training process of the task processing model. The difference is that the training samples used in the training process of the task processing model are data under the target task, while the training samples used in the pre-training process of the initial processing model can be data under any scenario.
  • the pre-training process of the initial processing model is shown in the embodiment shown in Figure 14 below.
  • FIG14 is a flowchart of a pre-training method for an initial processing model provided in an embodiment of the present application.
  • the embodiment of the present application is performed by an electronic device, which may be the terminal 101 or the server 102 in FIG1 .
  • the method includes:
  • the fifth sample image is an associated image of the fourth sample image.
  • the fourth sample image and the fifth sample image belong to the same graphic data, and the fifth sample image is the context of the fourth sample image.
  • the fifth sample image and the fourth sample image may have a similarity that reaches a preset threshold, etc., which is not limited in this embodiment of the present application.
  • the process of the electronic device acquiring the sample image features of the fifth sample image is the same as the process of acquiring the target sample image features of the target sample image in the above steps, and will not be repeated here.
  • each fourth sample sub-image encode the fourth sample sub-image using an image encoding and decoding model to obtain a sixth sample image feature of the fourth sample sub-image, and fuse the sixth sample image feature with the fourth sample position feature to obtain a seventh sample image feature of the fourth sample sub-image.
  • step 1402 to step 1405 is the same as the process of step 803 to step 806 above, and will not be repeated here.
  • Figure 15 is a comparison chart of data processing results provided by an embodiment of the present application.
  • the target task is to process the image based on the requirements described in the text when text and image are given.
  • images generated by processing text and images in different target tasks using related technologies 1-4 and the method of the embodiment of the present application are respectively given.
  • the image generated by the method of the embodiment of the present application is more in line with the processing requirements described in the text in the target task. While improving the adaptability of the data processing method, the embodiment of the present application can also improve the effect of the data.
  • FIG16 is a schematic diagram of the structure of a data processing device provided in an embodiment of the present application.
  • the data processing device 1600 includes:
  • An acquisition module 1601 is configured to acquire a first image to be processed in a target task
  • An image processing module 1602 is configured to divide the first image into a plurality of sub-images and obtain a first position feature of each sub-image in the first image, wherein the resolution of each sub-image is equal to a target resolution of images that can be processed by the trained image encoding and decoding model;
  • the encoding module 1603 is configured to encode each sub-image using the image encoding and decoding model to obtain a first image feature of the sub-image, and fuse the first image feature with the first position feature to obtain a second image feature of the sub-image;
  • a feature processing module 1604 is configured to process the second image features of the plurality of sub-images using a trained task processing model to obtain third image features;
  • the decoding module 1605 is configured to decode the third image feature using the image encoding and decoding model to obtain a second image.
  • the image processing module 1602 is configured to:
  • the division strategies including a first number of divisions, a second number of divisions, and a division ratio, wherein the first number of divisions refers to the number of divisions of the image in the length direction, the second number of divisions refers to the number of divisions of the image in the width direction, and the division ratio refers to the ratio between the first number of divisions and the second number of divisions;
  • the first image is segmented to obtain the multiple sub-images.
  • the image processing module 1602 is configured to:
  • the first intermediate image is divided according to the target division strategy to obtain the multiple sub-images.
  • the image processing module 1602 is configured to:
  • the coordinate information is mapped based on mapping parameters to obtain a first position feature of the sub-image, wherein the mapping parameters are obtained through training.
  • the image coding model includes an image coding network, an image processing module 1602 , and is further configured to reduce the first image to a second intermediate image, wherein the resolution of the second intermediate image is equal to the target resolution;
  • the encoding module 1603 is further configured to encode the second intermediate image through the image encoding network to obtain image features of the second intermediate image;
  • the feature processing module 1604 is configured to process the second image features of the plurality of sub-images and the image features of the second intermediate image using the task processing model to obtain the third image features.
  • the image encoding and decoding model includes an image decoding network, a decoding module 1606 , configured to:
  • the fusion features are decoded by the image decoding model to obtain the second image.
  • the target task is a multimodal task, and the data to be processed in the multimodal task further includes first non-image data;
  • the feature processing module 1604 is configured to process the second image features of the plurality of sub-images and the first data features of the first non-image data through the task processing model to obtain the third image features and the second data features.
  • the decoding module 1606 is further configured to decode the second data feature to obtain second non-image data.
  • the first non-image data is text, and the text includes coordinate information of an object in the first image; the feature processing module 1604 is configured to:
  • the second image features and the third data features of the multiple sub-images are processed by the task processing model to obtain the third image features and the second data features.
  • the data processing device provided in the above embodiment is merely an example of the division of the above functional modules.
  • the above functions can be assigned to different functional modules as needed, that is, the internal structure of the electronic device can be divided into different functional modules to complete all or part of the functions described above.
  • the data processing device provided in the above embodiment and the data processing method embodiment are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
  • FIG17 is a schematic diagram of the structure of a model training device provided in an embodiment of the present application.
  • the model training device 1700 includes:
  • the acquisition module 1701 is configured to acquire a first sample image; based on a target task, process the first sample image to obtain a target sample image, and obtain target sample image features of the target sample image;
  • An image processing module 1702 is configured to divide the first sample image into a plurality of first sample sub-images, and obtain a first sample position feature of each first sample sub-image in the first sample image, wherein the resolution of each first sample sub-image is equal to the target resolution of images that can be processed by the trained image encoding and decoding model;
  • the encoding module 1703 is configured to encode each first sample sub-image using the image encoding and decoding model to obtain a first sample image feature of the first sample sub-image, and fuse the first sample image feature with the first sample position feature to obtain a second sample image feature of the first sample sub-image;
  • a feature processing module 1704 is configured to process the second sample image features of the plurality of first sample sub-images using an initial processing model to obtain third sample image features;
  • the first training module 1705 is used to train the initial processing model based on the third sample image feature and the target sample image feature to obtain a task processing model for processing the target task.
  • the acquisition module 1701 is configured to:
  • the image feature of the target sub-image and the second sample position feature are fused to obtain the target sample image feature of the target sub-image.
  • the acquisition module 1701 is further configured to acquire a second sample image
  • the image processing module 1702 is further configured to divide the second sample image to obtain a plurality of second sample sub-images, and obtain a third sample position feature of each second sample sub-image in the second sample image, wherein the resolution of each second sample sub-image is equal to the target resolution;
  • the encoding module 1703 is further configured to encode each second sample sub-image using the initial image encoding and decoding model to obtain a fourth sample image feature of the second sample sub-image, and fuse the fourth sample image feature with the third sample position feature to obtain a fifth sample image feature of the second sample sub-image.
  • the model training device 1800 further includes:
  • a decoding module 1706 configured to decode the fifth sample image feature of the plurality of second sample sub-images using the initial image coding and decoding model to obtain a third sample image
  • the second training module 1707 is configured to train the initial image coding and decoding model based on the third sample image and the second sample image to obtain the trained image coding and decoding model.
  • the decoding module 1706 is configured to:
  • the sample fusion feature is decoded by the initial image encoding and decoding model to obtain the third sample image.
  • the acquisition module 1701 is configured to:
  • the second training module 1707 is used to:
  • the initial image coding model and the preset mapping parameters are trained.
  • the initial processing model is obtained through pre-training, and the acquisition module 1701 is further configured to acquire a fourth sample image and acquire sample image features of a fifth sample image, wherein the fifth sample image is an image associated with the fourth sample image in terms of content.
  • the image processing module 1702 is further configured to divide the fourth sample image to obtain a plurality of fourth sample sub-images, and obtain a fourth sample position feature of each fourth sample sub-image in the fourth sample image, wherein the resolution of each fourth sample sub-image is equal to the target resolution;
  • the encoding module 1703 is further configured to encode each fourth sample sub-image using the image encoding and decoding model to obtain a sixth sample image feature of the fourth sample sub-image, and fuse the sixth sample image feature with the fourth sample position feature to obtain a seventh sample image feature of the fourth sample sub-image;
  • the feature processing module 1704 is further configured to process the seventh sample image feature of the plurality of fourth sample sub-images using the initialized initial processing model to obtain an eighth sample image feature;
  • the model training device 1800 further includes:
  • the third training module 1708 is configured to pre-train the initial processing model based on the eighth sample image feature and the sample image feature of the fifth sample image.
  • the target task is a multimodal task
  • the data to be processed in the multimodal task includes the first sample image and the first sample non-image data
  • the feature processing module 1704 is configured to:
  • the first training module 1705 is used to:
  • the initial processing model is trained to obtain the task processing model.
  • model training device provided in the above embodiment is only illustrated by the division of the above functional modules.
  • the above functions can be assigned to different functional modules as needed, that is, the internal structure of the electronic device can be divided into different functional modules to complete all or part of the functions described above.
  • the model training device provided in the above embodiment and the model training method embodiment are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
  • An embodiment of the present application also provides an electronic device, which includes a processor and a memory, wherein the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor to implement the operations performed in the data processing method of the above embodiment.
  • the electronic device is provided as a terminal.
  • FIG19 shows a schematic structural diagram of a terminal 1900 provided in an exemplary embodiment of the present application.
  • the terminal 1900 includes a processor 1901 and a memory 1902 .
  • the processor 1901 may include one or more processing cores, such as a quad-core processor, an octa-core processor, etc.
  • the processor 1901 may be implemented in at least one hardware form selected from the group consisting of DSP (Digital Signal Processing), FPGA (Field Programmable Gate Array), and PLA (Programmable Logic Array).
  • the processor 1901 may also include a main processor and a coprocessor.
  • the main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state.
  • the processor 1901 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen.
  • the processor 1901 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
  • AI Artificial Intelligence
  • Memory 1902 may include one or more computer-readable storage media, which may be non-transitory. Memory 1902 may also include high-speed random access memory, and non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in memory 1902 is used to store at least one computer program, which is used by processor 1901 to implement the data processing method or model training method provided in the method embodiment of the present application.
  • terminal 1900 may optionally include a peripheral device interface 1903 and at least one peripheral device.
  • the processor 1901, memory 1902, and peripheral device interface 1903 may be connected via a bus or signal lines.
  • Each peripheral device may be connected to peripheral device interface 1903 via a bus, signal lines, or circuit boards.
  • the peripheral device includes at least one of a radio frequency circuit 1904, a display screen 1905, a camera assembly 1906, an audio circuit 1907, and a power supply 1908.
  • the peripheral device interface 1903 can be used to connect at least one I/O (Input/Output)-related peripheral device to the processor 1901 and the memory 1902.
  • the processor 1901, the memory 1902, and the peripheral device interface 1903 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1901, the memory 1902, and the peripheral device interface 1903 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.
  • the RF circuit 1904 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals.
  • the RF circuit 1904 communicates with communication networks and other communication devices via electromagnetic signals.
  • the RF circuit 1904 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals.
  • the RF circuit 1904 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, and the like.
  • the RF circuit 1904 can communicate with other devices via at least one wireless communication protocol.
  • Such wireless communication protocols include, but are not limited to, metropolitan area networks, various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks, and/or WiFi (Wireless Fidelity) networks.
  • the RF circuit 1904 may also include circuits related to NFC (Near Field Communication), which is not limited in this application.
  • Display screen 1905 is used to display a UI (User Interface).
  • This UI may include graphics, text, icons, videos, or any combination thereof.
  • display screen 1905 is a touch screen display, it is also capable of collecting touch signals on or above the surface of display screen 1905.
  • This touch signal can be input as a control signal to processor 1901 for processing.
  • display screen 1905 can also be used to provide virtual buttons and/or a virtual keyboard, also known as soft buttons and/or a soft keyboard.
  • display screen 1905 there can be one display screen 1905, disposed on the front panel of terminal 1900; in other embodiments, there can be at least two display screens 1905, disposed on different surfaces of terminal 1900 or in a foldable design; in still other embodiments, display screen 1905 can be a flexible display, disposed on a curved or foldable surface of terminal 1900. Display screen 1905 can even be configured as a non-rectangular irregular shape, i.e., a special-shaped screen.
  • the display screen 1905 can be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
  • the camera component 1906 is used to capture images or videos.
  • the camera component 1906 includes a front camera and a rear camera.
  • the front camera is set on the front panel of the terminal 1900, and the rear camera is set on the back of the terminal 1900.
  • there are at least two rear cameras which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions.
  • the camera component 1906 may also include a flash.
  • the flash can be a single-color temperature flash or a dual-color temperature flash.
  • the dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation under different color temperatures.
  • the audio circuit 1907 may include a microphone and a speaker.
  • the microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals that are input into the processor 1901 for processing, or input into the radio frequency circuit 1904 to achieve voice communication. For the purpose of stereo sound collection or noise reduction, there may be multiple microphones, each located in different parts of the terminal 1900.
  • the microphone may also be an array microphone or an omnidirectional collection microphone.
  • the speaker is used to convert electrical signals from the processor 1901 or the radio frequency circuit 1904 into sound waves.
  • the speaker may be a traditional thin film speaker or a piezoelectric ceramic speaker.
  • the speaker When the speaker is a piezoelectric ceramic speaker, it can not only convert electrical signals into sound waves audible to humans, but also convert electrical signals into sound waves inaudible to humans for purposes such as distance measurement.
  • the audio circuit 1907 may also include a headphone jack.
  • Power supply 1908 is used to power various components in terminal 1900.
  • Power supply 1908 can be AC power, DC power, disposable batteries, or rechargeable batteries.
  • the rechargeable battery can support wired charging or wireless charging.
  • the rechargeable battery can also be used to support fast charging technology.
  • FIG19 does not constitute a limitation on the terminal 1900 , and may include more or fewer components than shown in the figure, or combine certain components, or adopt a different component arrangement.
  • the electronic device is provided as a server.
  • Figure 20 is a schematic diagram of the structure of a server provided in an embodiment of the present application.
  • the server 2000 may have relatively large differences due to different configurations or performances, and may include one or more processors (Central Processing Units, CPU) 2001 and one or more memories 2002, wherein the memory 2002 stores at least one computer program, and the at least one computer program is loaded and executed by the processor 2001 to implement the methods provided in the above-mentioned various method embodiments.
  • the server may also have components such as a wired or wireless network interface, a keyboard, and an input and output interface for input and output.
  • the server may also include other components for implementing device functions, which will not be described in detail here.
  • An embodiment of the present application also provides a computer-readable storage medium, which stores at least one computer program, and the at least one computer program is loaded and executed by a processor to implement the operations performed by the data processing method or model training method of the above embodiment.
  • An embodiment of the present application also provides a computer program product, including a computer program, which is loaded and executed by a processor to implement the operations performed by the data processing method or model training method of the above embodiment.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Artificial Intelligence (AREA)
  • Health & Medical Sciences (AREA)
  • Computing Systems (AREA)
  • Databases & Information Systems (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Informatics (AREA)
  • Software Systems (AREA)
  • Image Analysis (AREA)

Abstract

本申请实施例公开了一种数据处理方法、模型训练方法、装置、设备、介质及程序产品。该方法包括:获取目标任务中待处理的第一图像;对所述第一图像进行划分,得到多个子图像,并获取每个子图像在所述第一图像中的第一位置特征;对于每个子图像,通过所述图像编解码模型,对该子图像进行编码,得到该子图像的第一图像特征,并将所述第一图像特征和所述第一位置特征进行融合,得到该子图像的第二图像特征;通过训练后的任务处理模型,对所述多个子图像的所述第二图像特征进行处理,得到第三图像特征;及,通过所述图像编解码模型,对所述第三图像特征进行解码,得到第二图像。

Description

数据处理方法、模型训练方法、装置、设备、介质及程序产品
本申请要求于2024年4月18日提交中国专利局、申请号为202410474106.9、申请名称为“数据处理方法、模型训练方法、装置、设备及介质”的中国专利申请的优先权。
技术领域
本申请实施例涉及计算机技术领域,特别涉及一种数据处理方法、模型训练方法、装置、设备、介质及程序产品。
发明背景
随着人工智能技术的不断发展,人工智能模型的应用也越来越广泛,利用人工智能可以实现与用户的交互任务,例如用户可以提供一张图像,并提出针对该图像的需求,人工智能模型即可根据用户的需求对该图像进行处理等。
但是,在不同领域中图像的尺寸是变化多样的,导致人工智能模型难以适应不同领域下的数据处理需求,因此数据处理方法的适应性较差。
发明内容
本申请实施例提供了一种数据处理方法、模型训练方法、装置、设备、介质及程序产品,能够提高数据处理方法的适应性。所述技术方案如下:
一方面,本申请实施例提供了一种数据处理方法,由电子设备执行,所述方法包括:
获取目标任务中待处理的第一图像;
对所述第一图像进行划分,得到多个子图像,并获取每个子图像在所述第一图像中的第一位置特征,其中,每个子图像的分辨率与训练后的图像编解码模型所能处理图像的目标分辨率相等;
对于每个子图像,通过所述图像编解码模型,对该子图像进行编码,得到该子图像的第一图像特征,并将所述第一图像特征和所述第一位置特征进行融合,得到该子图像的第二图像特征;
通过训练后的任务处理模型,对所述多个子图像的所述第二图像特征进行处理,得到第三图像特征;及,
通过所述图像编解码模型,对所述第三图像特征进行解码,得到第二图像。
另一方面,本申请实施例提供了一种模型训练方法,由电子设备执行,所述方法包括:
获取第一样本图像;
基于目标任务,对所述第一样本图像进行处理,得到目标样本图像,并获取所述目标样本图像的目标样本图像特征;
对所述第一样本图像进行划分,得到多个第一样本子图像,并获取每个第一样本子图像在所述第一样本图像中的第一样本位置特征,其中,每个第一样本子图像的分辨率与训练后的图像编解码模型所能处理图像的目标分辨率相等;
对于每个第一样本子图像,通过所述图像编解码模型,对该第一样本子图像进行编码,得到该第一样本子图像的第一样本图像特征,并将所述第一样本图像特征和所述第一样本位置特征进行融合,得到该第一样本子图像的第二样本图像特征;
通过初始处理模型,对所述多个第一样本子图像的所述第二样本图像特征进行处理,得到第三样本图像特征;及,
基于所述第三样本图像特征与所述目标样本图像特征,对所述初始处理模型进行训练,得到用于处理所述目标任务的任务处理模型。
另一方面,本申请实施例提供了一种数据处理装置,所述装置包括:
获取模块,用于获取目标任务中待处理的第一图像;
图像处理模块,用于对所述第一图像进行划分,得到多个子图像,并获取每个子图像在所述第一图像中的第一位置特征,其中,每个子图像的分辨率与训练后的图像编解码模型所能处理图像的目标分辨率相等;
编码模块,用于对于每个子图像,通过所述图像编解码模型,对该子图像进行编码,得到该子图像的第一图像特征,并将所述第一图像特征和所述第一位置特征进行融合,得到该子图像的第二图像特征;
特征处理模块,用于通过训练后的任务处理模型,对所述多个子图像的所述第二图像特征进行处理,得到第三图像特征;及,
解码模块,用于通过所述图像编解码模型,对所述第三图像特征进行解码,得到第二图像。
另一方面,本申请实施例提供了一种模型训练装置,所述装置包括:
获取模块,用于获取第一样本图像;基于目标任务,对所述第一样本图像进行处理,得到目标样本图像,并获取所述目标样本图像的目标样本图像特征;
图像处理模块,用于对所述第一样本图像进行划分,得到多个第一样本子图像,并获取每个第一样本子图像在所述第一样本图像中的第一样本位置特征,其中,每个第一样本子图像的分辨率与训练后的图像编解码模型所能处理图像的目标分辨率相等;
编码模块,用于对于每个第一样本子图像,通过所述图像编解码模型,对该第一样本子图像进行编码,得到该第一样本子图像的第一样本图像特征,并将所述第一样本图像特征和所述第一样本位置特征进行融合,得到该第一样本子图像的第二样本图像特征;
特征处理模块,用于通过初始处理模型,对所述多个第一样本子图像的所述第二样本图像特征进行处理,得到第三样本图像特征;及,
第一训练模块,用于基于所述第三样本图像特征与所述目标样本图像特征,对所述初始处理模型进行训练,得到用于处理所述目标任务的任务处理模型。
另一方面,本申请实施例提供了一种电子设备,所述电子设备包括处理器和存储器,所述存储器中存储有至少一条计算机程序,所述至少一条计算机程序由所述处理器加载并执行,以实现如上述方面所述的数据处理方法或模型训练方法所执行的操作。
另一方面,本申请实施例提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有至少一条计算机程序,所述至少一条计算机程序由处理器加载并执行,以实现如上述方面所述的数据处理方法或模型训练方法所执行的操作。
另一方面,本申请实施例提供了一种计算机程序产品,包括计算机程序,所述计算机程序由处理器加载并执行,以实现如上述方面所述的数据处理方法或模型训练方法所执行的操作。
附图简要说明
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请实施例的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本申请实施例提供的一种实施环境的示意图;
图2是本申请实施例提供的一种数据处理方法的流程图;
图3A是本申请实施例提供的另一种数据处理方法的流程图;
图3B是本申请实施例提供的数据处理模型的架构示意图;
图4是本申请实施例提供的另一种数据处理方法的流程图;
图5是本申请实施例提供的一种多模态数据序列的示意图;
图6是本申请实施例提供的一种数据处理方法的示意图;
图7是本申请实施例提供的一种基于人工智能的交互方法的示意图;
图8是本申请实施例提供的一种模型训练方法的流程图;
图9是本申请实施例提供的一种任务处理模型的训练方法的流程图;
图10是本申请实施例提供的另一种任务处理模型的训练方法的流程图;
图11是本申请实施例提供的一种图像编解码模型的训练方法的流程图;
图12是本申请实施例提供的一种图像编解码模型的训练方法的示意图;
图13是本申请实施例提供的一种图像编解码模型的重建结果的对比图;
图14是本申请实施例提供的一种初始处理模型的预训练方法的流程图;
图15是本申请实施例提供的一种数据处理结果的对比图;
图16是本申请实施例提供的一种数据处理装置的结构示意图;
图17是本申请实施例提供的一种模型训练装置的结构示意图;
图18是本申请实施例提供的另一种模型训练装置的结构示意图;
图19是本申请实施例提供的一种终端的结构示意图;
图20是本申请实施例提供的一种服务器的结构示意图。。
实施方式
为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施方式作进一步地详细描述。
可以理解,本申请所使用的术语“第一”、“第二”等可在本文中用于描述各种概念,但除非特别说明,这些概念不受这些术语限制。这些术语仅用于将一个概念与另一个概念区分。举例来说,在不脱离本申请的范围的情况下,可以将第一图像称为第二图像,且类似地,可将第二图像称为第一图像。
其中,至少一个是指一个或者一个以上,例如,至少一个图像可以是一个图像、两个图像、三个图像等任一大于等于一的整数个图像。多个是指两个或者两个以上,例如,多个图像可以是两个图像、三个图像等任一大于等于二的整数个图像。每个是指至少一个中的每一个,例如,每个图像是指多个图像中的每一个图像,若多个图像为3个图像,则每个图像是指3个图像中的每一个图像。
需要说明的是,本申请所涉及的信息(包括但不限于用户设备信息、用户个人信息等)、数据(包括但不限于用于分析的数据、存储的数据、展示的数据等)以及信号(包括但不限于用户终端与其他设备之间传输的信号等),均为经用户或相关方面充分授权的,且相关数据的收集、使用和处理需要遵守相关国家和地区的相关法律法规和标准。
本申请实施例提供的数据处理方法及模型训练方法,能够由电子设备执行。在一些实施例中,该电子设备为计算机设备,例如,终端或服务器。在一些实施例中,该服务器是独立的物理服务器,或者,是多个物理服务器构成的服务器集群或者分布式系统,或者,是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、CDN(Content Delivery Network,内容分发网络)、以及大数据和人工智能平台等基础云计算服务的云服务器。在一些实施例中,该终端是智能手机、平板电脑、笔记本电脑、台式计算机、智能音箱、智能手表、智能语音交互设备、智能家电及车载终端等,但并不局限于此。
在一些实施例中,本申请实施例所涉及的计算机程序可被部署在一个电子设备上执行,或者在位于一个地点的多个电子设备上执行,又或者,在分布在多个地点且通过通信网络互连的多个电子设备上执行,分布在多个地点且通过通信网络互连的多个电子设备能够组成区块链系统。
在一些实施例中,图1是本申请实施例提供的一种实施环境的示意图。参见图1,该实施环境包括终端101和服务器102。终端101和服务器102之间通过无线或者有线网络连接。
其中,服务器102采用本申请实施例提供的模型训练方法,训练图像编解码模型和任务处理模型,存储训练后的图像编解码模型和任务处理模型。其中,图像编解码模型用于对图像进行编码和解码,任务处理模型用于生成目标任务相关的特征。
在一些实施例中,终端101向服务器102发送携带第一图像的目标任务,服务器102接收该目标任务,通过该图像编解码模型对第一图像进行编码,得到图像特征,通过该任务处理模型对该图像特征进行处理,得到处理后的图像特征,再通过该图像编解码模型对处理后的图像特征进行解码,得到第二图像,该第二图像即为按照该目标任务对该第一图像进行处理的结果。服务器102将该第二图像返回给终端101,由终端101向用户展示该第二图像。
在另一些实施例中,服务器102将该图像编解码模型和任务处理模型发送给终端101,终端101针对携带第一图像的目标任务,通过该图像编解码模型对第一图像进行编码,得到图像特征,通过该任务处理模型对该图像特征进行处理,得到处理后的图像特征,再通过该图像编解码模型对处理后的图像特征进行解码,得到第二图像。
在一些实施例中,终端101安装有由服务器102提供服务的目标应用,服务器102将该图像编解码模型和任务处理模型下发至该目标应用,终端101可在该目标应用中,通过图像编解码模型和任务处理模型,对目标任务中所需处理的图像和数据进行处理,得到处理结果。
图2是本申请实施例提供的一种数据处理方法的流程图,本申请实施例由电子设备执行,该电子设备可以是图1中的终端101或者服务器102。参见图2,该方法包括:
201、获取目标任务中待处理的第一图像。
其中,第一图像为目标任务中所需处理的图像,该目标任务包括对该第一图像进行处理的任务。
本申请实施例中,目标任务可以为任意类型的任务,例如图像编辑任务、幻灯片生成任务等。以目标任务为图像编辑任务为例,该目标任务可以包括对第一图像中的内容进行识别、将第一图像中的某一物体去除、对第一图像进行抠图等,本申请实施例对目标任务的具体内容不做限定。
202、对第一图像进行划分,得到多个子图像,并获取每个子图像在第一图像中的第一位置特征,其中,每个子图像的分辨率与训练后的图像编解码模型所能处理图像的目标分辨率相等。
其中,电子设备基于图像编解码模型对应的目标分辨率,对第一图像进行划分,得到多个子图像,每个子图像的分辨率与目标分辨率相等。
本申请实施例中,第一图像的分辨率可以为任意分辨率,而图像编解码模型对应有目标分辨率,该目标分辨率是指该图像编解码模型所能处理的图像的分辨率,也即是图像编解码模型仅能够处理分辨率等于该目标分辨率的图像。
在第一图像的分辨率大于该目标分辨率的情况下,图像编解码模型无法直接对该第一图像进行处理。此时,电子设备基于该目标分辨率,对该第一图像进行划分,也即是对该第一图像进行分割,从而得到多个子图像,以使每个子图像的分辨率均等于该目标分辨率。那么,后续图像编解码模型即可以子图像为单位进行编解码,因此即使第一图像的分辨率与图像编解码模型对应的目标分辨率不匹配,也能够实现对第一图像进行处理。
由于子图像是从第一图像中划分得到的,虽然子图像的第一图像特征中包含了第一图像中该子图像中的内容,但是并不包含该子图像在第一图像中的位置信息。因此,为了保留各个子图像在第一图像中的位置信息,电子设备还获取每个子图像的第一位置特征,该第一位置特征表示子图像在第一图像中的位置。
203、对于每个子图像,通过图像编解码模型,对该子图像进行编码,得到该子图像的第一图像特征,并将第一图像特征和第一位置特征进行融合,得到该子图像的第二图像特征。
本申请实施例中,该图像编解码模型用于对图像进行编解码。在一些实施例中,该图像编解码模型包括图像编码网络和图像解码网络,该图像编码网络用于对图像进行编码,得到图像特征;该图像解码网络用于对图像特征进行解码,得到图像。
电子设备在分割得到多个子图像后,对于任一子图像,电子设备将该子图像输入该图像编解码模型中的图像编码网络,由图像编码网络对该子图像进行编码,输出该子图像的第一图像特征。
进而,对于每个子图像,电子设备将该子图像的第一图像特征和该子图像的第一位置特征进行融合,得到该子图像的第二图像特征,该第二图像特征既包含了第一图像中该子图像中的内容,还包含了该子图像在第一图像中的位置信息。因此,多个子图像的第二图像特征能够充分表示整个第一图像的特征,从而避免由于划分图像导致位置信息丢失的问题。
204、通过训练后的任务处理模型,对多个子图像的所述第二图像特征进行处理,得到第三图像特征。
其中,任务处理模型用于生成目标任务相关的特征。例如,目标任务包括对图像进行去模糊,则该任务处理模型能够生成被去模糊后的图像特征。再例如,目标任务包括对图像进行风格迁移,则该任务处理模型能够生成风格迁移后的图像特征。
电子设备在获取到每个子图像的第二图像特征后,将多个子图像的第二图像特征输入至该任务处理模型,由任务处理模型对该多个子图像的第二图像特征进行处理,例如进行深层特征提取、特征交叉、特征映射等,任务处理模型输出第三图像特征,该第三图像特征即为目标任务重所需生成的第二图像的特征。
205、通过图像编解码模型,对第三图像特征进行解码,得到第二图像。
电子设备在获取到第三图像特征后,将该第三图像特征输入至该图像编解码模型中的图像解码网络,由图像解码网络输出解码得到的第二图像。该第二图像是目标任务所需的处理结果,也即是按照目标任务对第一图像进行处理后的图像。
本申请实施例提供的方法,在目标任务中所需处理的图像与图像编解码模型对应的目标分辨率不匹配的情况下,将图像划分成分辨率等于该目标分辨率的多个子图像,以便通过图像编解码模型直接对子图像进行编码。并且,还将子图像的位置特征融合至子图像的图像特征中,从而保留各个子图像在完整图像中的位置信息。进而,通过任务处理模型对各个子图像的图像特征进行处理,将处理后的图像特征进行解码,即可得到第二图像,也即是目标任务的处理结果。因此,通过对图像进行划分并保留位置信息,能够使得图像编解码模型适用于任意分辨率的图像,提高了数据处理方法的适应性。
在上述实施例的基础上,当第一图像的分辨率大于目标分辨率时,电子设备除了对第一图像划分得到的多个子图像进行编码之外,还可以将第一图像缩放至目标分辨率后进行编码,详细过程参见下述图3A所示的实施例。
图3A是本申请实施例提供的另一种数据处理方法的流程图,本申请实施例由电子设备执行,该电子设备可以是图1中的终端101或者服务器102。参见图3A,该方法包括:
301、获取目标任务中待处理的第一图像。
在一些实施例中,电子设备接收目标任务的处理请求,该目标任务的处理请求携带该第一图像,该目标任务的处理请求用于指示按照目标任务对该第一图像进行处理。本申请实施例中,该第一图像可以为任意分辨率的图像。
302、对第一图像进行划分,得到多个子图像,并获取每个子图像在第一图像中的第一位置特征,其中,每个子图像的分辨率与训练后的图像编解码模型所能处理图像的目标分辨率相等。
图像编解码模型仅能够处理分辨率等于该目标分辨率的图像。在第一图像的分辨率大于该目标分辨率的情况下,图像编解码模型无法直接对该第一图像进行处理。因此,在对第一图像进行缩放之前,先在步骤302,将第一图像划分成分辨率等于目标分辨率的子图像,使得本申请实施例中所述的方法,能够对任意大小和纵横比的图像进行处理。
在一些实施例中,电子设备确定多个划分策略,划分策略包括第一划分份数、第二划分份数和划分比例;基于第一图像的长宽比例,在多个划分策略中确定目标划分策略,目标划分策略中的划分比例与长宽比例最接近;基于目标划分策略和目标分辨率,对第一图像进行划分,得到多个子图像。
其中,第一划分份数是指对图像在长度方向上的划分份数,第二划分份数是指对图像在宽度方向上的划分份数,划分比例是指第一划分份数与第二划分份数之间的比例。例如多个划分策略包括划分策略1、划分策略2和划分策略3,划分策略1中的划分比例为5:1,划分策略2中的划分比例为4:3,划分策略3中的划分比例为16:9。第一图像的长宽比例为16:9,那么划分策略3中的划分比例与第一图像的长宽比例最接近,因此将划分策略3确定为目标划分策略。
在确定目标划分策略后,根据该目标划分策略中的第一划分份数、第二划分份数和该目标分辨率,即可对该第一图像进行划分,从而得到多个子图像。
本申请实施例中,提供了多个待选择的划分策略,根据划分策略中的划分比例,选择与第一图像的长宽比例最适配的划分策略作为目标划分策略,进而基于该目标划分策略进行划分即可,通过预先提供划分策略,有利于提高对图像进行划分的效率。
在一些实施例中,电子设备基于目标划分策略和目标分辨率,对第一图像进行划分,得到多个子图像,包括:基于目标划分策略和目标分辨率,生成目标尺寸;基于目标尺寸对第一图像进行上采样,得到第一中间图像;按照目标划分策略,对第一中间图像进行划分,得到多个子图像。
例如,目标划分策略中的第一划分份数为Nh,第二划分份数为Nw,目标分辨率为Ht×Wt,目标尺寸包括长度和宽度,则目标尺寸的长度等于Nh*Ht,目标尺寸的宽度等于Nw*Wt,将第一图像上采样为第一中间图像,使得第一中间图像的长度等于目标尺寸的长度Nh*Ht,宽度等于目标尺寸的宽度Nw*Wt。进而,按照该目标划分策略,对第一中间图像进行划分,也即是将第一中间图像在长度方向上划分为Nh份,在宽度方向上划分为Nw份,从而得到多个子图像。
本申请实施例中,先基于目标划分策略和目标分辨率生成目标尺寸,该目标尺寸即为能够根据该划分策略划分出目标分辨率的子图像所需的尺寸,进而将第一图像上采样为该目标尺寸的第一中间图像,能够保证划分出的每个子图像的分辨率均等于该目标分辨率。
303、对于每个子图像,通过图像编解码模型,对该子图像进行编码,得到该子图像的第一图像特征,并将第一图像特征和第一位置特征进行融合,得到该子图像的第二图像特征。
在一些实施例中,该图像编解码模型包括图像编码网络和图像解码网络,该图像编码网络可以为VAE(Variational AutoEncoder,变分自编码器)、ViT(Visual Tokenizer,视觉标记器)等,本申请实施例对该图像编码网络的类型不做限定。
对于任一子图像,电子设备将该子图像输入该图像编解码模型中的图像编码网络,由图像编码网络对该子图像进行编码,输出该子图像的第一图像特征,该第一图像特征是指该子图像的图像特征。
进一步,将各个子图像的第一位置特征添加至各自的第一图像特征中,得到各个子图像的第二图像特征,使得第二图像中既包括子图像本身的内容,还包括子图像在完整的第一图像中的位置信息。
在一些实施例中,电子设备获取每个子图像在第一图像中的第一位置特征,包括:对于任一子图像,确定该子图像在第一图像中的坐标信息;基于映射参数,对坐标信息进行映射,得到该子图像的第一位置特征,映射参数是通过训练得到的。具体的映射处理是指将映射参数与坐标信息相乘的操作。
在一些实施例中,映射参数包括左侧映射参数、右侧映射参数、上侧映射参数和下侧映射参数。坐标信息包括归一化后的横坐标和纵坐标,电子设备可以采用以下公式确定第一位置特征:
p=x_c·l+(1-x_c)·r+y_c·t+(1-y_c)·b
其中,p表示第一位置特征,x_c表示横坐标,y_c表示纵坐标,l表示左侧映射参数,r表示右侧映射参数,t表示上侧映射参数,b表示下侧映射参数。在一些实施例中,以上映射参数均为向量。
在一些实施例中,子图像包括多个图像块,该图像块为图像中的最小单位,例如图像块为像素点等。子图像的第一位置特征包括子图像中每个图像块的位置特征。那么对于任一子图像,电子设备确定该子图像中每个图像块在第一图像中的坐标信息,基于映射参数,对每个图像块的坐标信息进行映射,得到每个图像块的位置特征。子图像的第一图像特征包括每个图像块的图像特征,电子设备将子图像中每个图像块的图像特征和位置特征进行融合,得到每个图像块的图像特征,将子图像中多个图像块的图像特征进行融合,得到子图像的第二图像特征。
在一些实施例中,子图像在第一图像中的坐标信息是指子图像的中心点在第一图像中的坐标信息。
304、将第一图像缩小为第二中间图像,第二中间图像的分辨率等于目标分辨率。
本申请实施例中,除了对子图像进行编码之外,还可以将第一图像缩小为具备目标分辨率的第二中间图像,然后对该第二中间图像进行编码,有利于保留第一图像的全局视觉上下文信息,有利于提高后续基于图像特征进行处理的准确性。
305、通过图像编码网络,对第二中间图像进行编码,得到第二中间图像的图像特征。
由于第二中间图像的分辨率等于目标分辨率,因此图像编码网络能够对该第二中间图像进行处理。
电子设备将该第二中间图像输入图像编码网络,由图像编码网络对该第二中间图像进行编码,输出该第二中间图像的图像特征。
306、通过任务处理模型,对多个子图像的第二图像特征和第二中间图像的图像特征进行处理,得到第三图像特征。
电子设备在获取到每个子图像的第二图像特征以及第二中间图像的图像特征后,将多个子图像的第二图像特征和第二中间图像的图像特征输入至该任务处理模型,由任务处理模型对该多个子图像的第二图像特征和第二中间图像的图像特征进行处理,例如进行深层特征提取、特征交叉、特征映射等,任务处理模型输出第三图像特征。
在一些实施例中,该任务处理模型为LLM(Large Language Models,大语言模型)或者多模态模型等,本申请实施例对任务处理模型的类型不做限定。
307、通过图像编解码模型,对第三图像特征进行解码,得到第二图像。
在一些实施例中,该图像编解码模型包括图像解码网络,电子设备通过图像编解码模型,对第三图像特征进行解码,得到第二图像,包括:通过图像解码网络,对第一图像进行特征转换,得到查询特征;通过图像解码网络,对第三图像特征进行特征转换,得到键特征和值特征;对查询特征、键特征和值特征进行融合,得到融合特征;通过图像解码网络,对融合特征进行解码,得到第二图像。
在一些实施例中,该图像解码网络包括至少一个交叉注意力层,例如图像解码网络包括4个交叉注意力层。电子设备将第一图像随同噪声向量输入至该图像解码网络,该图像解码网络对第一图像和噪声向量进行特征转换,将特征转换得到的特征作为注意力机制中的查询特征。电子设备将第三图像特征输入至该图像解码网络,该图像解码网络对该第三图像特征进行特征转换,将特征转换得到的特征作为注意力机制中的键特征和值特征。在一些实施例中,图像解码网络中包括转换矩阵,转换矩阵用于执行上述特征转换,即将输入的特征,分别转换得到注意力机制中的查询特征、键特征和值特征。
本申请实施例中,在对第三图像特征进行解码时,通过步骤304-306,引入了第一图像作为参考,使得将第三图像特征解码为第二图像的过程中,能够学习到第一图像中的细粒度信息,避免丢失第一图像中的原始内容,有利于提高生成的第二图像的质量与效果,实现了细粒度的图像生成。
并且,如果引入参考图像,即采用图3A所述的方法,则可以使图像编解码模型解码出细粒度的图像;如果不引入参考图像,即采用图2所述的方法,则可以使图像编解码模型解码出粗粒度的图像,提高了灵活性,实现了多粒度图像的生成。
在一些实施例中,可以将第三图像特征进行均匀池化,通过图像解码网络,对池化后的第三图像特征进行解码,得到第二图像。
需要说明的是,本申请实施例以图像编解码模型和任务处理模型为两个不同的模型为例进行说明。在另一实施例中,图像编解码模型和任务处理模型还可以看作一个整体模型中的不同部分。在一些实施例中,该整体模型称为数据处理模型,如图3B所示,数据处理模型310包括图像编码网络311、任务处理模型312、图像解码网络313,其中,图像编码网络311和图像解码网络313构成了一个图像编解码模型,图像编码网络311和图像解码网络313分别与任务处理模型312连接。
具体地,以图2所示的方法为例,第一图像的多个子图像,输入到图像编码网络311中,输出第一图像特征;随后,第一图像特征与第一位置特征融合,得到第二图像特征,作为任务处理模型312的输入。然后,经由任务处理模型312,输出第三图像特征,然后输入到图像解码网络313中,最终输出第二图像。
在上述实施例的基础上,该目标任务还可以为多模态任务,目标任务待处理的数据除了图像之外,还包括非图像数据,则数据处理方法的详细过程参见下述图4所示的实施例。图4是本申请实施例提供的另一种数据处理方法的流程图,本申请实施例由电子设备执行,该电子设备可以是图1中的终端101或者服务器102。参见图4,该方法包括:
401、获取第一图像和第一非图像数据,第一图像和第一非图像数据均为目标任务中待处理的数据。
其中,目标任务为多模态任务,多模态任务是指对多种类型的数据进行处理的任务,该第一非图像数据是指除了图像之外的其他数据,例如第一非图像数据可以为文本、视频或者音频等,本申请实施例对此不做限定。
以目标任务为图文结合的多模态任务为例,则第一非图像数据为第一文本。则该第一图像和该第一文本可以为图像描述对、结构化的图像文本数据、交错的图像文本数据、OCR(Optical Character Recognition,光学字符识别)数据等。其中,图像描述对是指图像和用于描述该图像内容的文本,结构化的图像文本数据是指图像和对该图像进行结构化描述的文本,交错的图像文本数据是指图像与文本相互穿插,OCR数据是指图像和对图像中的文字进行识别得到的文本。
图5是本申请实施例提供的一种多模态数据序列的示意图,如图5所示,多模态任务中待处理的数据为多模态数据序列,该多模态数据序列中包括至少一个图像和至少一个文本,例如多模态数据序列中包括图像501、文本502和图像503等。
402、对第一图像进行划分,得到多个子图像,并获取每个子图像在第一图像中的第一位置特征,其中,每个子图像的分辨率与训练后的图像编解码模型所能处理图像的目标分辨率相等。
403、对于每个子图像,通过图像编解码模型,对该子图像进行编码,得到该子图像的第一图像特征,并将第一图像特征和第一位置特征进行融合,得到该子图像的第二图像特征。
该步骤402-步骤403的过程与上述步骤302-步骤303的过程同理,在此不再赘述。
404、对第一非图像数据进行特征提取,得到第一数据特征。
在一些实施例中,电子设备通过非图像的编解码模型,对该第一非图像数据进行特征提取,得到第一数据特征。其中,非图像的编解码模型用于对非图像数据进行处理。例如,第一非图像数据为文本,则该非图像编解码模型为文本编解码模型。第一非图像数据为音频,则该非图像编解码模型为音频编解码模型。在一些实施例中,非图像编解码模型包括非图像编码网络和非图像解码网络,电子设备通过非图像编码网络,对第一非图像数据进行特征提取,得到第一数据特征。
在一些实施例中,第一非图像数据为第一文本,第一数据特征为文本特征,该文本特征可以为嵌入向量等。在一些实施例中,电子设备通过查询词典来将第一文本中的各个词语映射至其对应的嵌入向量,该词典中包括多个词语及其嵌入向量的对应关系。
405、通过任务处理模型,对多个子图像的第二图像特征和第一非图像数据的第一数据特征进行处理,得到第三图像特征和第二数据特征。
电子设备在获取到每个子图像的第二图像特征以及第一非图像数据的第一数据特征后,将多个子图像的第二图像特征和第一数据特征输入至该任务处理模型,由任务处理模型对输入的特征进行处理,例如进行深层特征提取、特征交叉、特征映射等,并输出第三图像特征和第二数据特征,该第三图像特征即为目标任务所需生成的第二图像的特征,该第二数据特征即为目标任务所需生成的非图像数据的特征。
在一些实施例中,第一非图像数据为文本,文本包括第一图像中物体的坐标信息。电子设备将坐标信息转换为第二位置特征,将第一数据特征与第二位置特征进行融合,得到第三数据特征;通过任务处理模型,对多个子图像的第二图像特征和第三数据特征进行处理,得到第三图像特征和第二数据特征。
本申请实施例中,为了提高处理效果,在文本包括第一图像中物体的坐标信息的情况下,将坐标信息转换为第二位置特征,该第二位置特征能够表示图像中物体的位置。在一些实施例中,电子设备获取预设的多个候选位置标记,每个候选位置标记指示图像中不同的位置,电子设备基于该坐标信息,在多个候选位置标记中确定目标位置标记,该目标位置标记指示的图像中的位置与该坐标信息指示的图像中的位置相同,电子设备将该目标位置标记作为第二位置特征,将该第二位置特征添加至第一数据特征中。
在一些实施例中,电子设备在将多个子图像的第二图像特征和第一非图像数据的第一数据特征输入至任务处理模型之前,在多个子图像的第二图像特征的前面添加图像起始标记,在多个子图像的第二图像特征的后面添加图像结束标记,来表示图像特征的开始和结束,以便对图像特征和数据特征进行区分。例如,图像起始标记为“IMG”,图像结束标记为“/IMG”。
406、通过图像编解码模型,对第三图像特征进行解码,得到第二图像。
该步骤406的过程与上述步骤307的过程同理,在此不再赘述。
407、对第二数据特征进行解码,得到第二非图像数据。
在一些实施例中,电子设备通过非图的像编解码模型,对第二数据特征进行解码,得到第二非图像数据。其中,非图像编解码模型用于对非图像数据进行处理。在一些实施例中,非图像的编解码模型包括非图像编码网络和非图像解码网络,电子设备通过非图像解码网络,对第二数据特征进行解码,得到第二非图像数据。
在一些实施例中,第一非图像数据为第一文本,第二非图像数据为第二文本,第二数据特征为文本特征,该文本特征可以为嵌入向量等。在一些实施例中,电子设备通过查询词典来将文本特征映射至其对应的词语,从而得到第二文本,该词典中包括多个词语及其嵌入向量的对应关系。
基于上述实施例,任务处理模型能够对多模态数据的特征进行处理,提高了任务处理模型的处理能力,且使得任务处理模型能够适用于各种场景下的多种类型的数据,进一步提高了数据处理方法的适应性。
图6是本申请实施例提供的一种数据处理方法的示意图,如图6所示,目标任务中待处理的数据包括第一图像和第一文本。其中,第一图像经过划分和缩放后,得到图像序列601,图像序列601中包括划分得到的子图像6012-6015和缩小得到的第二中间图像6011,第一文本为“狗爱在公园玩(或者英文Lucky likes playing in the park)”。图像序列601中的各个图像6011-6015,经图像编解码模型中的图像编码网络(未示出)进行编码后,得到图像特征602。第一文本经编码后,得到文本特征603。电子设备还随机生成图像特征604,在图像特征602和图像特征604的前面分别添加图像起始标记“IMG”,在图像特征602和图像特征604的后面分别添加图像结束标记“/IMG”,在整个输入特征的前面添加起始标记“BOI”。
如图6所示,电子设备将上述各个特征和标记输入至任务处理模型,任务处理模型输出预测得到的图像特征605和文本特征606。电子设备将该图像特征605输入至图像编解码模型中的图像解码网络,图像解码网络输出第二图像607。电子设备将该文本特征606进行解码,还可以得到第二文本。则该第二图像607和第二文本即为按照目标任务对该第一图像和第一文本进行处理所得到的处理结果。
图7是本申请实施例提供的一种基于人工智能的交互方法的示意图,通过上述图像编解码模型和任务处理模型可实现AI助手的功能,用户即可与AI助手进行交互。如图7所示,在目标任务701中,用户输入图像711和文本“给我看看房间装饰后的照片”,AI助手输出图像721和文本“这是给您提供的照片”。在目标任务702中,用户输入图像712和文本“你能根据草图画出一个丰富多彩的动漫角色吗”,AI助手输出图像722和文本“这是我为您创造的动漫角色”。在目标任务703中,用户输入图像713和文本“你能为这本小说创作一幅插图吗”,AI助手输出图像723和文本“当然,请欣赏这幅插图”。在目标任务704中,用户输入图像714和文本“你能把这张照片变成水彩画吗”,AI助手输出图像724和文本“当然可以”。
上述实施例中所使用的任务处理模型的训练过程,可参见下述图8所示的实施例。图8是本申请实施例提供的一种模型训练方法的流程图,本申请实施例由电子设备执行,该电子设备可以是图1中的终端101或者服务器102。参见图8,该方法包括:
801、获取第一样本图像。
其中,第一样本图像为目标任务中所需处理的样本图像。该步骤801的过程与上述步骤301的过程同理,在此不再赘述。
802、基于目标任务,对第一样本图像进行处理,得到目标样本图像,并获取目标样本图像的目标样本图像特征。
其中,目标样本图像是指按照目标任务对第一样本图像进行处理的结果。例如,目标任务为将第一样本图像的风格迁移为动漫风格,则该目标样本图像是指将第一样本图像的风格迁移为动漫风格所得到的图像。例如,目标任务为将第一样本图像中的某一物体去除,则该目标样本图像是指将第一样本图像中的该物体去除后所得到的图像。
在一些实施例中,电子设备获取目标样本图像的目标样本图像特征,包括:
对所述目标样本图像进行划分,得到多个目标子图像,并获取每个目标子图像在所述目标样本图像中的第二样本位置特征,每个目标子图像的分辨率与所述目标分辨率相等;
对于每个目标子图像,
通过所述图像编解码模型,对该目标子图像进行编码,得到该目标子图像的图像特征;
将该目标子图像的图像特征和所述第二样本位置特征进行融合,得到该目标子图像的所述目标样本图像特征。
其中,电子设备获取该目标样本图像中每个目标子图像的目标样本图像特征的过程,与上述实施例中获取第一图像中每个子图像的第二图像特征的过程同理,在此不再赘述。
803、对第一样本图像进行划分,得到多个第一样本子图像,并获取每个第一样本子图像在第一样本图像中的第一样本位置特征,其中,每个第一样本子图像的分辨率与训练后的图像编解码模型所能处理图像的目标分辨率相等。
在一些实施例中,图像编解码模型的训练过程与任务处理模型的训练过程是解耦的,图8所示的实施例是对任务处理模型进行训练的过程,则在该实施例中,该图像编解码模型是指训练后的模型,该图像编解码模型的训练过程参见下述图11所示的实施例,在此暂不做说明。
804、对于每个第一样本子图像,通过图像编解码模型,对该第一样本子图像进行编码,得到该第一样本子图像的第一样本图像特征,并将第一样本图像特征和第一样本位置特征进行融合,得到该第一样本子图像的第二样本图像特征。
其中,该步骤803-步骤804的过程与上述步骤302-步骤303的过程同理,在此不再赘述。
805、通过初始处理模型,对多个第一样本子图像的第二样本图像特征进行处理,得到第三样本图像特征。
其中,该初始处理模型用于对特征进行处理,例如进行深层特征提取、特征交叉、特征映射等。
在一些实施例中,该初始处理模型为预训练后的模型,该初始处理模型的预训练过程参见下述图14所示的实施例,在此暂不作说明。
806、基于第三样本图像特征与目标样本图像特征,对初始处理模型进行训练,得到用于处理目标任务的任务处理模型。
本申请实施例中,目标样本图像特征是按照目标任务对第一样本图像进行处理所得到的结果,初始处理模型的目标就是获得该目标样本图像特征。也即是,初始处理模型生成的第三样本图像特征与该目标样本图像特征越接近,则该初始处理模型的训练过程越准确。因此,电子设备基于第三样本图像特征与目标样本图像特征,对初始处理模型进行训练,得到任务处理模型,以使任务处理模型输出的图像特征趋于该目标样本图像特征。
在一些实施例中,电子设备基于第三样本图像特征与目标样本图像特征,确定损失参数,基于损失参数,对初始处理模型进行训练,得到任务处理模型。该损失参数可以为交叉熵损失或者均方差损失等,本申请实施例对此不做限定。
本申请实施例提供的方法,在目标任务中所需处理的图像与图像编解码模型对应的目标分辨率不匹配的情况下,将图像划分成分辨率等于该目标分辨率的多个子图像,以便通过图像编解码模型直接对子图像进行编码。并且,还将子图像的位置特征融合至子图像的图像特征中,从而保留各个子图像在完整图像中的位置信息。进而,通过初始处理模型对各个子图像的图像特征进行处理,基于处理后的图像特征与所需生成的图像特征对模型进行训练,以得到用于处理目标任务的任务处理模型。因此,通过对图像进行划分并保留位置信息,能够使得任务处理模型适用于任意分辨率的图像,提高了数据处理方法的适应性。
图9是本申请实施例提供的一种任务处理模型的训练方法的流程图,本申请实施例由电子设备执行,该电子设备可以是图1中的终端101或者服务器102。参见图9,该方法包括:
901、获取第一样本图像和第一样本非图像数据,第一样本图像和第一样本非图像数据均为目标任务中待处理的数据。
其中,目标任务为多模态任务,多模态任务是指对多种类型的数据进行处理的任务,该第一样本非图像数据是指除了图像之外的其他数据,例如第一样本非图像数据可以为文本、视频或者音频等,本申请实施例对此不做限定。
该步骤901的过程与上述步骤401的过程同理,在此不再赘述。
902、基于目标任务,对第一样本图像进行处理,得到目标样本图像,并获取目标样本图像的目标样本图像特征。
其中,目标样本图像是指按照目标任务对第一样本图像进行处理的结果。
903、对第一样本图像进行划分,得到多个第一样本子图像,并获取每个第一样本子图像在第一样本图像中的第一样本位置特征,其中,每个第一样本子图像的分辨率与训练后的图像编解码模型所能处理图像的目标分辨率相等。
904、对于每个第一样本子图像,通过图像编解码模型,对该第一样本子图像进行编码,得到该第一样本子图像的第一样本图像特征,并将第一样本图像特征和第一样本位置特征进行融合,得到该第一样本子图像的第二样本图像特征。
该步骤903-步骤904的过程与上述步骤803-步骤804的过程同理,在此不再赘述。
905、对第一样本非图像数据进行特征提取,得到第一样本数据特征。
该步骤905的过程与上述步骤404的过程同理,在此不再赘述。
906、通过初始处理模型,对多个第一样本子图像的第二样本图像特征和第一样本数据特征进行处理,得到第三样本图像特征和第二样本数据特征。
在一些实施例中,电子设备在通过初始处理模型预测第二样本数据特征时,是按照前序特征预测后序特征的方式得到的。例如,第一样本非图像数据为第一样本文本,第一样本数据特征为第一样本文本特征,该第一样本文本特征包括第一样本文本中每个样本词语的第一样本文本特征。电子设备按照顺序依次将多个第一子图像的第二样本图像特征和多个样本词语的第一样本文本特征输入至初始处理模型,初始处理模型根据第1个样本词语的第一样本文本特征前面的特征,确定第1个预测词语的第二样本文本特征,根据第2个样本词语的第一样本文本特征前面的特征,确定第2个预测词语的第二样本文本特征,以此类推,直至输出所有预测词语的第二样本文本特征,构成第二样本数据特征。如果初始处理模型足够准确,那么初始处理模型预测得到的多个预测词语的第二样本文本特征,应趋于该多个样本词语的第一样本文本特征。
907、基于第三样本图像特征、目标样本图像特征、第二样本数据特征以及第一样本数据特征,对初始处理模型进行训练,得到任务处理模型。
本申请实施例中,初始处理模型的目标是生成目标样本图像特征和第一样本数据特征,也即是,初始处理模型生成的第三样本图像特征与该目标样本图像特征越接近,且初始处理模型生成的第二样本数据特征与第一样本数据特征越接近,则该模型越准确。
因此,电子设备基于第三样本图像特征与目标样本图像特征,以及第二样本数据特征与第一样本数据特征,对初始处理模型进行训练,得到任务处理模型,以使任务处理模型生成的图像特征趋于该目标样本图像特征,生成的数据特征趋于该第一样本数据特征。
在一些实施例中,电子设备基于第三样本图像特征与目标样本图像特征,确定第一损失参数;基于第二样本数据特征与第一样本数据特征,确定第二损失参数;将第一损失参数和第二损失参数进行融合,得到融合损失参数;基于融合损失参数,对初始处理模型进行训练,得到任务处理模型。以上损失参数可以为交叉熵损失或者均方差损失等,本申请实施例对此不做限定。
图10是本申请实施例提供的另一种任务处理模型的训练方法的流程图,如图10所示,目标任务中待处理的数据包括第一样本图像和第一样本文本。其中,第一样本图像经过划分和缩放后,得到图像序列1001,图像序列1001中包括划分得到的子图像10012-10015和缩小得到的图像10011,第一样本文本为“狗爱在公园玩(或者英文Lucky likes playing in the park)”。图像序列1001中的各个图像10011-10015,经图像编解码模型中的图像编码网络(未示出)进行编码后,得到图像特征1002。第一文本经编码后,得到文本特征1003。电子设备还随机生成图像特征1004,在图像特征1002和图像特征1004的前面分别添加图像起始标记“IMG”,在图像特征1002和图像特征1004的后面分别添加图像结束标记“/IMG”,在整个输入特征的前面添加起始标记“BOI”。
如图10所示,电子设备将上述各个特征和标记输入至初始处理模型,初始处理模型输出预测得到的图像特征1005和文本特征1006。电子设备还获取目标样本图像的图像特征1007,电子设备基于图像特征1005和图像特征1007确定第一损失参数,基于文本特征1006和文本特征1003确定第二损失参数,基于该第一损失参数和第二损失参数,对初始处理模型进行训练,以得到任务处理模型。
图11是本申请实施例提供的一种图像编解码模型的训练方法的流程图,本申请实施例由电子设备执行,该电子设备可以是图1中的终端101或者服务器102。参见图11,该方法包括:
1101、获取第二样本图像。
其中,该第二样本图像可以为任意领域、任意类型、任意分辨率的图像,本申请实施例对该第二样本图像不做限定。
1102、对第二样本图像进行划分,得到多个第二样本子图像,并获取每个第二样本子图像在第二样本图像中的第三样本位置特征,其中,每个第二样本子图像的分辨率与目标分辨率相等。
1103、对于每个第二样本子图像,通过初始的图像编解码模型,对该第二样本子图像进行编码,得到该第二样本子图像的第四样本图像特征,并将第四样本图像特征和第三样本位置特征进行融合,得到该第二样本子图像的第五样本图像特征。
在一些实施例中,电子设备获取每个第二样本子图像在第二样本图像中的第三样本位置特征,包括:
对于任一第二样本子图像,
确定该第二样本子图像在所述第二样本图像中的坐标信息;
基于预设的映射参数,对所述坐标信息进行映射,得到该第二样本子图像的所述第三样本位置特征。
后续在步骤1105中,基于第三样本图像与第二样本图像之间的差异,对初始的图像编解码模型和预设的映射参数进行训练。
其中,初始的图像编解码模型包括初始的图像编码网络和初始的图像解码网络,初始的图像编码网络可以是初始化的VAE或者ViT,初始的图像解码网络包括多个初始化的交叉注意力层。
预设的映射参数是指左侧映射参数、右侧映射参数、上侧映射参数和下侧映射参数的初始值。
其中,上述步骤1102-步骤1103的过程与上述步骤302-步骤303的过程同理,在此不再赘述。
1104、通过初始的图像编解码模型,对多个第二样本子图像的第五样本图像特征进行解码,得到第三样本图像。
在一些实施例中,电子设备获取参考样本图像,参考样本图像与第二样本图像有一部分内容是相同的,即二者存在相同内容和不同内容;通过初始的图像编解码模型,对参考样本图像进行特征转换,得到样本查询特征;通过初始的图像编解码模型,对多个第二样本子图像的第五样本图像特征进行特征转换,得到样本键特征和样本值特征;对样本查询特征、样本键特征和样本值特征进行融合,得到样本融合特征;通过初始的图像编解码模型,对样本融合特征进行解码,得到第三样本图像。
例如,该第二样本图像中包括两只狗,该参考样本图像为在该第二样本图像的基础上添加了第三只狗所得到的图像。或者,该第二样本图像中包括三个人,该参考样本图像为在该第二样本图像的基础上添加了一束鲜花所得到的图像等。
1105、基于第三样本图像与第二样本图像,对初始的图像编解码模型进行训练,得到训练后的图像编解码模型。
本申请实施例中,图像编解码模型的训练目标是重建出第二样本图像,也即是,图像编解码模型生成的第三样本图像与该第二样本图像越接近,则该模型越准确。因此,电子设备基于第三样本图像与第二样本图像,对初始的图像编解码模型进行训练,以使训练后的图像编解码模型生成的图像趋于该第二样本图像。
在一些实施例中,电子设备基于第三样本图像与第二样本图像,确定损失参数,基于损失参数,对初始的图像编解码模型进行训练,得到训练后的图像编解码模型。该损失参数可以为交叉熵损失或者均方差损失等,本申请实施例对此不做限定。
需要说明的是,该图像编解码模型的训练过程可分为两个阶段,在第一个阶段中,在解码时,通过初始的图像编解码模型,直接对图像特征进行解码,无需引入参考图像。在第二个阶段中,在解码时,通过初始的图像编解码模型,基于参考图像对图像特征进行解码。
图12是本申请实施例提供的一种图像编解码模型的训练方法的示意图,如图12所示,初始的图像编解码模型包括图像编码网络1210和图像解码网络1220。
在第一阶段中,通过图像编码网络1210和图像解码网络1220对原始图像A分别进行编码和解码,最后得到重建图像B。然后,基于重建图像B与原始图像A之间的差异,对图像编码网络1210和图像解码网络1220进行训练。此时的差异主要是指语义一致性上的不同,在图像解码网络1220时,除了输入图像特征,还输入了噪声。
在第二阶段中,通过图像编码网络1210和图像解码网络1220对原始图像C1分别进行编码和解码,同时在解码时引入参考图像C2,最后得到重建图像D。然后,基于重建图像D与原始图像C1之间的差异,对图像编码网络1210和图像解码网络1220进行训练。此时的差异是指细粒度的语义一致性上的不同,在图像解码网络1220时,除了输入图像特征,还输入了参考图像C2以及噪声。
图13是本申请实施例提供的一种图像编解码模型的重建结果的对比图,如图13所示,采用相关技术对原始图像A1进行重建得到重建图像B1,采用本申请实施例的方法且不引入参考图像的情况下,对原始图像A1进行重建得到重建图像B2,采用本申请实施例的方法且引入参考图像A2的情况下,对原始图像A1进行重建得到重建图像B3。从图13中可以看出,采用本申请实施例的方法且引入参考图像时重建得到的图像B3与原始图像A1更接近,重建效果更佳。
上述图8和图9的实施例是在初始处理模型的基础上训练得到任务处理模型,从而得到专门用于执行特定目标任务的任务处理模型。而该初始处理模型可以为预训练得到的模型,初始处理模型的预训练过程与任务处理模型的训练过程同理,不同之处在于,任务处理模型的训练过程所使用的训练样本为目标任务下的数据,而初始处理模型的预训练过程所使用的训练样本可以为任意场景下的数据。其中,该初始处理模型的预训练过程参见下述图14所示的实施例。
图14是本申请实施例提供的一种初始处理模型的预训练方法的流程图,本申请实施例由电子设备执行,该电子设备可以是图1中的终端101或者服务器102。参见图14,该方法包括:
1401、获取第四样本图像,并获取第五样本图像的样本图像特征,第五样本图像是与第四样本图像在内容上相关联的图像。
该第五样本图像为第四样本图像的关联图像,例如第四样本图像和第五样本图像属于同一个图文数据,该第五样本图像为第四样本图像的下文。或者,该第五样本图像与该第四样本图像的相似度达到预设阈值等,本申请实施例对此不做限定。
其中,电子设备获取第五样本图像的样本图像特征的过程与上述步骤中获取目标样本图像的目标样本图像特征的过程同理,在此不再赘述。
1402、对第四样本图像进行划分,得到多个第四样本子图像,并获取每个第四样本子图像在第四样本图像中的第四样本位置特征,其中,每个第四样本子图像的分辨率与目标分辨率相等。
1403、对于每个第四样本子图像,通过图像编解码模型,对该第四样本子图像进行编码,得到该第四样本子图像的第六样本图像特征,并将第六样本图像特征和第四样本位置特征进行融合,得到该第四样本子图像的第七样本图像特征。
1404、通过初始化的初始处理模型,对多个第四样本子图像的第七样本图像特征进行处理,得到第八样本图像特征。
1405、基于第八样本图像特征与第五样本图像的样本图像特征,对初始处理模型进行预训练。
该步骤1402-步骤1405的过程与上述步骤803-步骤806的过程同理,在此不再赘述。
图15是本申请实施例提供的一种数据处理结果的对比图,目标任务为在给出文本和图像的情况下,基于文本所描述的需求对图像进行处理。如图15所示,分别给出了采用相关技术1-4和采用本申请实施例的方法,对不同目标任务中的文本和图像进行处理所生成的图像。从图15中看出,与各个相关技术相比,采用本申请实施例的方法所生成的图像更加符合目标任务中的文本所描述的处理需求,本申请实施例在提高数据处理方法的适应性的同时,还能够提高数据的效果。
图16是本申请实施例提供的一种数据处理装置的结构示意图。参见图16,该数据处理装置1600包括:
获取模块1601,用于获取目标任务中待处理的第一图像;
图像处理模块1602,用于对所述第一图像进行划分,得到多个子图像,并获取每个子图像在所述第一图像中的第一位置特征,其中,每个子图像的分辨率与训练后的图像编解码模型所能处理图像的目标分辨率相等;
编码模块1603,用于对于每个子图像,通过所述图像编解码模型,对该子图像进行编码,得到该子图像的第一图像特征,并将所述第一图像特征和所述第一位置特征进行融合,得到该子图像的第二图像特征;
特征处理模块1604,用于通过训练后的任务处理模型,对所述多个子图像的所述第二图像特征进行处理,得到第三图像特征;及,
解码模块1605,用于通过所述图像编解码模型,对所述第三图像特征进行解码,得到第二图像。
在一些实施例中,参见图16,图像处理模块1602,用于:
确定多个划分策略,所述划分策略包括第一划分份数、第二划分份数和划分比例,所述第一划分份数是指对图像在长度方向上的划分份数,所述第二划分份数是指对图像在宽度方向上的划分份数,所述划分比例是指所述第一划分份数与所述第二划分份数之间的比例;
基于所述第一图像的长宽比例,在所述多个划分策略中确定目标划分策略,所述目标划分策略中的划分比例与所述长宽比例最接近;
基于所述目标划分策略和所述目标分辨率,对所述第一图像进行划分,得到所述多个子图像。
在一些实施例中,参见图16,图像处理模块1602,用于:
基于所述目标划分策略和所述目标分辨率,生成目标尺寸;
基于所述目标尺寸对所述第一图像进行上采样,得到第一中间图像;
按照所述目标划分策略,对所述第一中间图像进行划分,得到所述多个子图像。
在一些实施例中,参见图16,图像处理模块1602,用于:
对于任一子图像,
确定该子图像在所述第一图像中的坐标信息;
基于映射参数,对所述坐标信息进行映射,得到该子图像的第一位置特征,所述映射参数是通过训练得到的。
在一些实施例中,参见图16,所述图像编解码模型包括图像编码网络,图像处理模块1602,还用于将所述第一图像缩小为第二中间图像,所述第二中间图像的分辨率等于所述目标分辨率;
编码模块1603,还用于通过所述图像编码网络,对所述第二中间图像进行编码,得到所述第二中间图像的图像特征;
特征处理模块1604,用于通过所述任务处理模型,对所述多个子图像的所述第二图像特征和所述第二中间图像的图像特征进行处理,得到所述第三图像特征。
在一些实施例中,参见图16,所述图像编解码模型包括图像解码网络,解码模块1606,用于:
通过所述图像解码网络,对所述第一图像进行特征转换,得到查询特征;
通过所述图像解码网络,对所述第三图像特征进行特征转换,得到键特征和值特征;
对所述查询特征、所述键特征和所述值特征进行融合,得到融合特征;
通过所述图像解码模型,对所述融合特征进行解码,得到所述第二图像。
在一些实施例中,参见图16,所述目标任务为多模态任务,所述多模态任务中待处理的数据还包括第一非图像数据;
特征处理模块1604,用于通过所述任务处理模型,对所述多个子图像的所述第二图像特征和所述第一非图像数据的第一数据特征进行处理,得到所述第三图像特征和第二数据特征。
在一些实施例中,参见图16,解码模块1606,还用于对第二数据特征进行解码,得到第二非图像数据。
在一些实施例中,参见图16,第一非图像数据为文本,文本包括第一图像中物体的坐标信息;特征处理模块1604,用于:
将所述坐标信息转换为第二位置特征,将所述第一数据特征与所述第二位置特征进行融合,得到第三数据特征;
通过所述任务处理模型,对所述多个子图像的所述第二图像特征和所述第三数据特征进行处理,得到所述第三图像特征和所述第二数据特征。
需要说明的是:上述实施例提供的数据处理装置,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将电子设备的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的数据处理装置与数据处理方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。
图17是本申请实施例提供的一种模型训练装置的结构示意图。参见图17,模型训练装置1700包括:
获取模块1701,用于获取第一样本图像;基于目标任务,对所述第一样本图像进行处理,得到目标样本图像,并获取所述目标样本图像的目标样本图像特征;
图像处理模块1702,用于对所述第一样本图像进行划分,得到多个第一样本子图像,并获取每个第一样本子图像在所述第一样本图像中的第一样本位置特征,其中,每个第一样本子图像的分辨率与训练后的图像编解码模型所能处理图像的目标分辨率相等;
编码模块1703,用于对于每个第一样本子图像,通过所述图像编解码模型,对该第一样本子图像进行编码,得到该第一样本子图像的第一样本图像特征,并将所述第一样本图像特征和所述第一样本位置特征进行融合,得到该第一样本子图像的第二样本图像特征;
特征处理模块1704,用于通过初始处理模型,对所述多个第一样本子图像的所述第二样本图像特征进行处理,得到第三样本图像特征;及,
第一训练模块1705,用于基于所述第三样本图像特征与所述目标样本图像特征,对所述初始处理模型进行训练,得到用于处理所述目标任务的任务处理模型。
在一些实施例中,参见图18,在模型训练装置1800中,获取模块1701,用于:
对所述目标样本图像进行划分,得到多个目标子图像,并获取每个目标子图像在所述目标样本图像中的第二样本位置特征,每个目标子图像的分辨率与所述目标分辨率相等;
对于每个目标子图像,
通过所述图像编解码模型,对该目标子图像进行编码,得到该目标子图像的图像特征;
将该目标子图像的图像特征和所述第二样本位置特征进行融合,得到该目标子图像的所述目标样本图像特征。
在一些实施例中,参见图18,
获取模块1701,还用于获取第二样本图像;
图像处理模块1702,还用于对所述第二样本图像进行划分,得到多个第二样本子图像,并获取每个第二样本子图像在所述第二样本图像中的第三样本位置特征,其中,每个第二样本子图像的分辨率与所述目标分辨率相等;
编码模块1703,还用于对于每个第二样本子图像,通过初始的图像编解码模型,对该第二样本子图像进行编码,得到该第二样本子图像的第四样本图像特征,并将所述第四样本图像特征和所述第三样本位置特征进行融合,得到该第二样本子图像的第五样本图像特征;
模型训练装置1800还包括:
解码模块1706,用于通过所述初始的图像编解码模型,对所述多个第二样本子图像的所述第五样本图像特征进行解码,得到第三样本图像;
第二训练模块1707,用于基于所述第三样本图像与所述第二样本图像,对所述初始的图像编解码模型进行训练,得到训练后的所述图像编解码模型。
在一些实施例中,参见图18,解码模块1706,用于:
获取参考样本图像,所述参考样本图像与所述第二样本图像有一部分内容是相同的;
通过所述初始的图像编解码模型,对所述参考样本图像进行特征转换,得到样本查询特征;
通过所述初始的图像编解码模型,对所述多个第二样本子图像的所述第五样本图像特征进行特征转换,得到样本键特征和样本值特征;
对所述样本查询特征、所述样本键特征和所述样本值特征进行融合,得到样本融合特征;
通过所述初始的图像编解码模型,对所述样本融合特征进行解码,得到所述第三样本图像。
在一些实施例中,参见图18,获取模块1701,用于:
对于任一第二样本子图像,
确定该第二样本子图像在所述第二样本图像中的坐标信息;
基于预设的映射参数,对所述坐标信息进行映射,得到该第二样本子图像的所述第三样本位置特征;
第二训练模块1707,用于:
基于所述第三样本图像与所述第二样本图像之间的差异,对所述初始的图像编解码模型和所述预设的映射参数进行训练。
在一些实施例中,参见图18,初始处理模型为预训练得到的,获取模块1701,还用于获取第四样本图像,并获取第五样本图像的样本图像特征,所述第五样本图像是与所述第四样本图像在内容上相关联的图像;
图像处理模块1702,还用于对所述第四样本图像进行划分,得到多个第四样本子图像,并获取每个第四样本子图像在所述第四样本图像中的第四样本位置特征,其中,每个第四样本子图像的分辨率与所述目标分辨率相等;
编码模块1703,还用于对于每个第四样本子图像,通过所述图像编解码模型,对该第四样本子图像进行编码,得到该第四样本子图像的第六样本图像特征,并将所述第六样本图像特征和所述第四样本位置特征进行融合,得到该第四样本子图像的第七样本图像特征;
特征处理模块1704,还用于通过初始化的所述初始处理模型,对所述多个第四样本子图像的所述第七样本图像特征进行处理,得到第八样本图像特征;
模型训练装置1800还包括:
第三训练模块1708,用于基于所述第八样本图像特征与所述第五样本图像的样本图像特征,对所述初始处理模型进行预训练。
在一些实施例中,参见图18,所述目标任务为多模态任务,所述多模态任务中待处理的数据包括所述第一样本图像以及第一样本非图像数据;特征处理模块1704,用于:
通过所述初始处理模型,对所述多个第一样本子图像的所述第二样本图像特征和所述第一样本非图像数据的第一样本数据特征进行处理,得到所述第三样本图像特征和第二样本数据特征;
第一训练模块1705,用于:
基于所述第三样本图像特征、所述目标样本图像特征、所述第二样本数据特征以及所述第一样本数据特征,对所述初始处理模型进行训练,得到所述任务处理模型。
需要说明的是:上述实施例提供的模型训练装置,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将电子设备的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的模型训练装置与模型训练方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。
本申请实施例还提供了一种电子设备,该电子设备包括处理器和存储器,存储器中存储有至少一条计算机程序,该至少一条计算机程序由处理器加载并执行,以实现上述实施例的数据处理方法中所执行的操作。
在一些实施例中,该电子设备提供为终端。图19示出了本申请一个示例性实施例提供的终端1900的结构示意图。
终端1900包括有:处理器1901和存储器1902。
处理器1901可以包括一个或多个处理核心,比如4核心处理器、8核心处理器等。处理器1901可以采用DSP(Digital Signal Processing,数字信号处理)、FPGA(Field Programmable Gate Array,现场可编程门阵列)、PLA(Programmable Logic Array,可编程逻辑阵列)中的至少一种硬件形式来实现。处理器1901也可以包括主处理器和协处理器,主处理器是用于对在唤醒状态下的数据进行处理的处理器,也称CPU(Central Processing Unit,中央处理器);协处理器是用于对在待机状态下的数据进行处理的低功耗处理器。在一些实施例中,处理器1901可以集成有GPU(Graphics Processing Unit,图像处理的交互器),GPU用于负责显示屏所需要显示的内容的渲染和绘制。一些实施例中,处理器1901还可以包括AI(Artificial Intelligence,人工智能)处理器,该AI处理器用于处理有关机器学习的计算操作。
存储器1902可以包括一个或多个计算机可读存储介质,该计算机可读存储介质可以是非暂态的。存储器1902还可包括高速随机存取存储器,以及非易失性存储器,比如一个或多个磁盘存储设备、闪存存储设备。在一些实施例中,存储器1902中的非暂态的计算机可读存储介质用于存储至少一条计算机程序,该至少一条计算机程序用于被处理器1901所具有以实现本申请中方法实施例提供的数据处理方法或模型训练方法。
在一些实施例中,终端1900还可选包括有:外围设备接口1903和至少一个外围设备。处理器1901、存储器1902和外围设备接口1903之间可以通过总线或信号线相连。各个外围设备可以通过总线、信号线或电路板与外围设备接口1903相连。在一些实施例中,外围设备包括:射频电路1904、显示屏1905、摄像头组件1906、音频电路1907和电源1908中的至少一种。
外围设备接口1903可被用于将I/O(Input/Output,输入/输出)相关的至少一个外围设备连接到处理器1901和存储器1902。在一些实施例中,处理器1901、存储器1902和外围设备接口1903被集成在同一芯片或电路板上;在一些其他实施例中,处理器1901、存储器1902和外围设备接口1903中的任意一个或两个可以在单独的芯片或电路板上实现,本实施例对此不加以限定。
射频电路1904用于接收和发射RF(Radio Frequency,射频)信号,也称电磁信号。射频电路1904通过电磁信号与通信网络以及其他通信设备进行通信。射频电路1904将电信号转换为电磁信号进行发送,或者,将接收到的电磁信号转换为电信号。在一些实施例中,射频电路1904包括:天线系统、RF收发器、一个或多个放大器、调谐器、振荡器、数字信号处理器、编解码芯片组、用户身份模块卡等等。射频电路1904可以通过至少一种无线通信协议来与其它设备进行通信。该无线通信协议包括但不限于:城域网、各代移动通信网络(2G、3G、4G及5G)、无线局域网和/或WiFi(Wireless Fidelity,无线保真)网络。在一些实施例中,射频电路1904还可以包括NFC(Near Field Communication,近距离无线通信)有关的电路,本申请对此不加以限定。
显示屏1905用于显示UI(User Interface,用户界面)。该UI可以包括图形、文本、图标、视频及其它们的任意组合。当显示屏1905是触摸显示屏时,显示屏1905还具有采集在显示屏1905的表面或表面上方的触摸信号的能力。该触摸信号可以作为控制信号输入至处理器1901进行处理。此时,显示屏1905还可以用于提供虚拟按钮和/或虚拟键盘,也称软按钮和/或软键盘。在一些实施例中,显示屏1905可以为一个,设置在终端1900的前面板;在另一些实施例中,显示屏1905可以为至少两个,分别设置在终端1900的不同表面或呈折叠设计;在另一些实施例中,显示屏1905可以是柔性显示屏,设置在终端1900的弯曲表面上或折叠面上。甚至,显示屏1905还可以设置成非矩形的不规则图形,也即异形屏。显示屏1905可以采用LCD(Liquid Crystal Display,液晶显示屏)、OLED(Organic Light-Emitting Diode,有机发光二极管)等材质制备。
摄像头组件1906用于采集图像或视频。在一些实施例中,摄像头组件1906包括前置摄像头和后置摄像头。前置摄像头设置在终端1900的前面板,后置摄像头设置在终端1900的背面。在一些实施例中,后置摄像头为至少两个,分别为主摄像头、景深摄像头、广角摄像头、长焦摄像头中的任意一种,以实现主摄像头和景深摄像头融合实现背景虚化功能、主摄像头和广角摄像头融合实现全景拍摄以及VR(Virtual Reality,虚拟现实)拍摄功能或者其它融合拍摄功能。在一些实施例中,摄像头组件1906还可以包括闪光灯。闪光灯可以是单色温闪光灯,也可以是双色温闪光灯。双色温闪光灯是指暖光闪光灯和冷光闪光灯的组合,可以用于不同色温下的光线补偿。
音频电路1907可以包括麦克风和扬声器。麦克风用于采集用户及环境的声波,并将声波转换为电信号输入至处理器1901进行处理,或者输入至射频电路1904以实现语音通信。出于立体声采集或降噪的目的,麦克风可以为多个,分别设置在终端1900的不同部位。麦克风还可以是阵列麦克风或全向采集型麦克风。扬声器则用于将来自处理器1901或射频电路1904的电信号转换为声波。扬声器可以是传统的薄膜扬声器,也可以是压电陶瓷扬声器。当扬声器是压电陶瓷扬声器时,不仅可以将电信号转换为人类可听见的声波,也可以将电信号转换为人类听不见的声波以进行测距等用途。在一些实施例中,音频电路1907还可以包括耳机插孔。
电源1908用于为终端1900中的各个组件进行供电。电源1908可以是交流电、直流电、一次性电池或可充电电池。当电源1908包括可充电电池时,该可充电电池可以支持有线充电或无线充电。该可充电电池还可以用于支持快充技术。
本领域技术人员可以理解,图19中示出的结构并不构成对终端1900的限定,可以包括比图示更多或更少的组件,或者组合某些组件,或者采用不同的组件布置。
在一些实施例中,该电子设备提供为服务器。图20是本申请实施例提供的一种服务器的结构示意图,该服务器2000可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上处理器(Central Processing Units,CPU)2001和一个或一个以上的存储器2002,其中,所述存储器2002中存储有至少一条计算机程序,所述至少一条计算机程序由所述处理器2001加载并执行以实现上述各个方法实施例提供的方法。当然,该服务器还可以具有有线或无线网络接口、键盘以及输入输出接口等部件,以便进行输入输出,该服务器还可以包括其他用于实现设备功能的部件,在此不做赘述。
本申请实施例还提供了一种计算机可读存储介质,该计算机可读存储介质中存储有至少一条计算机程序,该至少一条计算机程序由处理器加载并执行,以实现上述实施例的数据处理方法或模型训练方法所执行的操作。
本申请实施例还提供了一种计算机程序产品,包括计算机程序,所述计算机程序由处理器加载并执行,以实现如上述实施例的数据处理方法或模型训练方法所执行的操作。
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。
以上所述仅为本申请实施例的可选实施例,并不用以限制本申请实施例,凡在本申请实施例的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。

Claims (21)

  1. 一种数据处理方法,由电子设备执行,所述方法包括:
    获取目标任务中待处理的第一图像;
    对所述第一图像进行划分,得到多个子图像,并获取每个子图像在所述第一图像中的第一位置特征,其中,每个子图像的分辨率与训练后的图像编解码模型所能处理图像的目标分辨率相等;
    对于每个子图像,通过所述图像编解码模型,对该子图像进行编码,得到该子图像的第一图像特征,并将所述第一图像特征和所述第一位置特征进行融合,得到该子图像的第二图像特征;
    通过训练后的任务处理模型,对所述多个子图像的所述第二图像特征进行处理,得到第三图像特征;及,
    通过所述图像编解码模型,对所述第三图像特征进行解码,得到第二图像。
  2. 根据权利要求1所述的方法,其中,所述对所述第一图像进行划分,得到多个子图像,包括:
    确定多个划分策略,所述划分策略包括第一划分份数、第二划分份数和划分比例,所述第一划分份数是指对图像在长度方向上的划分份数,所述第二划分份数是指对图像在宽度方向上的划分份数,所述划分比例是指所述第一划分份数与所述第二划分份数之间的比例;
    基于所述第一图像的长宽比例,在所述多个划分策略中确定目标划分策略,所述目标划分策略中的划分比例与所述长宽比例最接近;
    基于所述目标划分策略和所述目标分辨率,对所述第一图像进行划分,得到所述多个子图像。
  3. 根据权利要求2所述的方法,其中,所述基于所述目标划分策略和所述目标分辨率,对所述第一图像进行划分,得到所述多个子图像,包括:
    基于所述目标划分策略和所述目标分辨率,生成目标尺寸;
    基于所述目标尺寸对所述第一图像进行上采样,得到第一中间图像;
    按照所述目标划分策略,对所述第一中间图像进行划分,得到所述多个子图像。
  4. 根据权利要求1-3中任一项所述的方法,其中,所述获取每个子图像在所述第一图像中的第一位置特征,包括:
    对于任一子图像,
    确定该子图像在所述第一图像中的坐标信息;
    基于映射参数,对所述坐标信息进行映射,得到该子图像的第一位置特征,所述映射参数是通过训练得到的。
  5. 根据权利要求1-4中任一项所述的方法,其中,所述图像编解码模型包括图像编码网络,所述方法还包括:
    将所述第一图像缩小为第二中间图像,所述第二中间图像的分辨率等于所述目标分辨率;
    通过所述图像编码网络,对所述第二中间图像进行编码,得到所述第二中间图像的图像特征;
    所述通过训练后的任务处理模型,对所述多个子图像的所述第二图像特征进行处理,得到第三图像特征,包括:
    通过所述任务处理模型,对所述多个子图像的所述第二图像特征和所述第二中间图像的图像特征进行处理,得到所述第三图像特征。
  6. 根据权利要求1-5中任一项所述的方法,其中,所述图像编解码模型包括图像解码网络,所述通过所述图像编解码模型,对所述第三图像特征进行解码,得到第二图像,包括:
    通过所述图像解码网络,对所述第一图像进行特征转换,得到查询特征;
    通过所述图像解码网络,对所述第三图像特征进行特征转换,得到键特征和值特征;
    对所述查询特征、所述键特征和所述值特征进行融合,得到融合特征;
    通过所述图像解码模型,对所述融合特征进行解码,得到所述第二图像。
  7. 根据权利要求1-6中任一项所述的方法,其中,所述目标任务为多模态任务,所述多模态任务中待处理的数据还包括第一非图像数据;所述通过训练后的任务处理模型,对所述多个子图像的所述第二图像特征进行处理,得到第三图像特征,包括:
    通过所述任务处理模型,对所述多个子图像的所述第二图像特征和所述第一非图像数据的第一数据特征进行处理,得到所述第三图像特征和第二数据特征。
  8. 根据权利要求7所述的方法,还包括:
    对所述第二数据特征进行解码,得到第二非图像数据。
  9. 根据权利要求7或者8所述的方法,其中,所述第一非图像数据为文本,所述文本包括所述第一图像中物体的坐标信息;所述通过所述任务处理模型,对所述多个子图像的所述第二图像特征和所述第一非图像数据的第一数据特征进行处理,得到所述第三图像特征和第二数据特征,包括:
    将所述坐标信息转换为第二位置特征,将所述第一数据特征与所述第二位置特征进行融合,得到第三数据特征;
    通过所述任务处理模型,对所述多个子图像的所述第二图像特征和所述第三数据特征进行处理,得到所述第三图像特征和所述第二数据特征。
  10. 一种模型训练方法,由电子设备执行,所述方法包括:
    获取第一样本图像;
    基于目标任务,对所述第一样本图像进行处理,得到目标样本图像,并获取所述目标样本图像的目标样本图像特征;
    对所述第一样本图像进行划分,得到多个第一样本子图像,并获取每个第一样本子图像在所述第一样本图像中的第一样本位置特征,其中,每个第一样本子图像的分辨率与训练后的图像编解码模型所能处理图像的目标分辨率相等;
    对于每个第一样本子图像,通过所述图像编解码模型,对该第一样本子图像进行编码,得到该第一样本子图像的第一样本图像特征,并将所述第一样本图像特征和所述第一样本位置特征进行融合,得到该第一样本子图像的第二样本图像特征;
    通过初始处理模型,对所述多个第一样本子图像的所述第二样本图像特征进行处理,得到第三样本图像特征;及,
    基于所述第三样本图像特征与所述目标样本图像特征,对所述初始处理模型进行训练,得到用于处理所述目标任务的任务处理模型。
  11. 根据权利要求10所述的方法,其中,所述获取所述目标样本图像的目标样本图像特征,包括:
    对所述目标样本图像进行划分,得到多个目标子图像,并获取每个目标子图像在所述目标样本图像中的第二样本位置特征,每个目标子图像的分辨率与所述目标分辨率相等;
    对于每个目标子图像,
    通过所述图像编解码模型,对该目标子图像进行编码,得到该目标子图像的图像特征;
    将该目标子图像的图像特征和所述第二样本位置特征进行融合,得到该目标子图像的所述目标样本图像特征。
  12. 根据权利要求10或者11所述的方法,其中,所述图像编解码模型的训练过程,包括:
    获取第二样本图像;
    对所述第二样本图像进行划分,得到多个第二样本子图像,并获取每个第二样本子图像在所述第二样本图像中的第三样本位置特征,其中,每个第二样本子图像的分辨率与所述目标分辨率相等;
    对于每个第二样本子图像,通过初始的图像编解码模型,对该第二样本子图像进行编码,得到该第二样本子图像的第四样本图像特征,并将所述第四样本图像特征和所述第三样本位置特征进行融合,得到该第二样本子图像的第五样本图像特征;
    通过所述初始的图像编解码模型,对所述多个第二样本子图像的所述第五样本图像特征进行解码,得到第三样本图像;
    基于所述第三样本图像与所述第二样本图像,对所述初始的图像编解码模型进行训练,得到训练后的所述图像编解码模型。
  13. 根据权利要求12所述的方法,其中,所述通过所述初始的图像编解码模型,对所述多个第二样本子图像的所述第五样本图像特征进行解码,得到第三样本图像,包括:
    获取参考样本图像,所述参考样本图像与所述第二样本图像有一部分内容是相同的;
    通过所述初始的图像编解码模型,对所述参考样本图像进行特征转换,得到样本查询特征;
    通过所述初始的图像编解码模型,对所述多个第二样本子图像的所述第五样本图像特征进行特征转换,得到样本键特征和样本值特征;
    对所述样本查询特征、所述样本键特征和所述样本值特征进行融合,得到样本融合特征;
    通过所述初始的图像编解码模型,对所述样本融合特征进行解码,得到所述第三样本图像。
  14. 根据权利要求12或者13所述的方法,其中,所述获取每个第二样本子图像在所述第二样本图像中的第三样本位置特征,包括:
    对于任一第二样本子图像,
    确定该第二样本子图像在所述第二样本图像中的坐标信息;
    基于预设的映射参数,对所述坐标信息进行映射,得到该第二样本子图像的所述第三样本位置特征;
    所述基于所述第三样本图像与所述第二样本图像,对所述初始的图像编解码模型进行训练,得到训练后的所述图像编解码模型,包括:
    基于所述第三样本图像与所述第二样本图像之间的差异,对所述初始的图像编解码模型和所述预设的映射参数进行训练。
  15. 根据权利要求10-14中任一项所述的方法,其中,所述初始处理模型为预训练得到的,所述初始处理模型的预训练过程,包括:
    获取第四样本图像,并获取第五样本图像的样本图像特征,所述第五样本图像是与所述第四样本图像在内容上相关联的图像;
    对所述第四样本图像进行划分,得到多个第四样本子图像,并获取每个第四样本子图像在所述第四样本图像中的第四样本位置特征,其中,每个第四样本子图像的分辨率与所述目标分辨率相等;
    对于每个第四样本子图像,通过所述图像编解码模型,对该第四样本子图像进行编码,得到该第四样本子图像的第六样本图像特征,并将所述第六样本图像特征和所述第四样本位置特征进行融合,得到该第四样本子图像的第七样本图像特征;
    通过初始化的所述初始处理模型,对所述多个第四样本子图像的所述第七样本图像特征进行处理,得到第八样本图像特征;
    基于所述第八样本图像特征与所述第五样本图像的样本图像特征,对所述初始处理模型进行预训练。
  16. 根据权利要求10-15中任一项所述的方法,其中,所述目标任务为多模态任务,所述多模态任务中待处理的数据包括所述第一样本图像以及第一样本非图像数据;所述通过初始处理模型,对所述多个第一样本子图像的所述第二样本图像特征进行处理,得到第三样本图像特征,包括:
    通过所述初始处理模型,对所述多个第一样本子图像的所述第二样本图像特征和所述第一样本非图像数据的第一样本数据特征进行处理,得到所述第三样本图像特征和第二样本数据特征;
    所述基于所述第三样本图像特征与所述目标样本图像特征,对所述初始处理模型进行训练,得到用于处理所述目标任务的任务处理模型,包括:
    基于所述第三样本图像特征、所述目标样本图像特征、所述第二样本数据特征以及所述第一样本数据特征,对所述初始处理模型进行训练,得到所述任务处理模型。
  17. 一种数据处理装置,包括:
    获取模块,用于获取目标任务中待处理的第一图像;
    图像处理模块,用于对所述第一图像进行划分,得到多个子图像,并获取每个子图像在所述第一图像中的第一位置特征,其中,每个子图像的分辨率与训练后的图像编解码模型所能处理图像的目标分辨率相等;
    编码模块,用于对于每个子图像,通过所述图像编解码模型,对该子图像进行编码,得到该子图像的第一图像特征,并将所述第一图像特征和所述第一位置特征进行融合,得到该子图像的第二图像特征;
    特征处理模块,用于通过训练后的任务处理模型,对所述多个子图像的所述第二图像特征进行处理,得到第三图像特征;及,
    解码模块,用于通过所述图像编解码模型,对所述第三图像特征进行解码,得到第二图像。
  18. 一种模型训练装置,包括:
    获取模块,用于获取第一样本图像;基于目标任务,对所述第一样本图像进行处理,得到目标样本图像,并获取所述目标样本图像的目标样本图像特征;
    图像处理模块,用于对所述第一样本图像进行划分,得到多个第一样本子图像,并获取每个第一样本子图像在所述第一样本图像中的第一样本位置特征,其中,每个第一样本子图像的分辨率与训练后的图像编解码模型所能处理图像的目标分辨率相等;
    编码模块,用于对于每个第一样本子图像,通过所述图像编解码模型,对该第一样本子图像进行编码,得到该第一样本子图像的第一样本图像特征,并将所述第一样本图像特征和所述第一样本位置特征进行融合,得到该第一样本子图像的第二样本图像特征;
    特征处理模块,用于通过初始处理模型,对所述多个第一样本子图像的所述第二样本图像特征进行处理,得到第三样本图像特征;及,
    第一训练模块,用于基于所述第三样本图像特征与所述目标样本图像特征,对所述初始处理模型进行训练,得到用于处理所述目标任务的任务处理模型。
  19. 一种电子设备,包括处理器和存储器,所述存储器中存储有至少一条计算机程序,所述至少一条计算机程序由所述处理器加载并执行,以实现如权利要求1至9中任一项所述的数据处理方法,或者实现如权利要求10至16中任一项所述的模型训练方法。
  20. 一种计算机可读存储介质,存储有至少一条计算机程序,所述至少一条计算机程序由处理器加载并执行,以实现如权利要求1至9中任一项所述的数据处理方法,或者实现如权利要求10至16中任一项所述的数据处理方法。
  21. 一种计算机程序产品,包括计算机程序,所述计算机程序由处理器加载并执行,以实现如权利要求1至9中任一项所述的数据处理方法,或者实现如权利要求10至16中任一项所述的模型训练方法。
PCT/CN2025/080393 2024-04-18 2025-03-04 数据处理方法、模型训练方法、装置、设备、介质及程序产品 Pending WO2025218370A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202410474106.9 2024-04-18
CN202410474106.9A CN120833536A (zh) 2024-04-18 2024-04-18 数据处理方法、模型训练方法、装置、设备及介质

Publications (1)

Publication Number Publication Date
WO2025218370A1 true WO2025218370A1 (zh) 2025-10-23

Family

ID=97395725

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2025/080393 Pending WO2025218370A1 (zh) 2024-04-18 2025-03-04 数据处理方法、模型训练方法、装置、设备、介质及程序产品

Country Status (2)

Country Link
CN (1) CN120833536A (zh)
WO (1) WO2025218370A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113780486A (zh) * 2021-11-15 2021-12-10 湖南师范大学 一种视觉问答的方法、装置及介质
CN114581671A (zh) * 2022-04-24 2022-06-03 湖南师范大学 一种图像的语义分割方法、装置及计算机可读存储介质
US20230061647A1 (en) * 2021-08-26 2023-03-02 International Business Machines Corporation Training visual language grounding models using separation loss
CN117391201A (zh) * 2023-12-08 2024-01-12 荣耀终端有限公司 问答方法、装置及电子设备

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20230061647A1 (en) * 2021-08-26 2023-03-02 International Business Machines Corporation Training visual language grounding models using separation loss
CN113780486A (zh) * 2021-11-15 2021-12-10 湖南师范大学 一种视觉问答的方法、装置及介质
CN114581671A (zh) * 2022-04-24 2022-06-03 湖南师范大学 一种图像的语义分割方法、装置及计算机可读存储介质
CN117391201A (zh) * 2023-12-08 2024-01-12 荣耀终端有限公司 问答方法、装置及电子设备

Also Published As

Publication number Publication date
CN120833536A (zh) 2025-10-24

Similar Documents

Publication Publication Date Title
CN113704531A (zh) 图像处理方法、装置、电子设备及计算机可读存储介质
CN112543347A (zh) 基于机器视觉编解码的视频超分辨率方法和系统
CN119417931B (zh) 图像生成方法、装置、计算机设备及存储介质
CN112785669A (zh) 一种虚拟形象合成方法、装置、设备及存储介质
CN116775915B (zh) 资源推荐方法、推荐预测模型训练方法、装置及设备
CN119128200B (zh) 图像转换方法、系统、计算机设备以及存储介质
CN115454554A (zh) 文本描述的生成方法、装置、终端及存储介质
CN113822084B (zh) 语句翻译方法、装置、计算机设备及存储介质
CN114510911B (zh) 文本处理方法、装置、计算机设备及存储介质
CN117520504B (zh) 回复信息生成方法、装置、计算机设备及存储介质
CN119831825A (zh) 图像处理方法、装置、设备及存储介质
CN116597293B (zh) 多模态场景识别方法、装置、计算机设备和存储介质
CN114419517B (zh) 视频帧处理方法、装置、计算机设备及存储介质
CN116883708B (zh) 图像分类方法、装置、电子设备及存储介质
CN117427339A (zh) 虚拟对象生成方法、装置、计算机设备及存储介质
CN115589488B (zh) 视频转码系统、方法、gpu以及电子设备和存储介质
CN118116384A (zh) 一种语音识别的方法、设备以及存储介质
CN117540789B (zh) 模型训练方法、面部表情迁移方法、装置、设备及介质
CN120013837A (zh) 图像编辑方法、装置及存储介质
CN120418793A (zh) 一种基于大语言模型的数据处理方法、装置及设备
CN116957929A (zh) 图像超分模型的训练、图像超分处理方法、装置及设备
CN116996739A (zh) 一种视频分割的方法、装置以及存储介质
CN120358394B (zh) 视频生成模型的训练方法、装置、电子设备及存储介质
CN119888257B (zh) 基于多模态大模型的建筑物矢量多边形轮廓提取方法
CN120833536A (zh) 数据处理方法、模型训练方法、装置、设备及介质

Legal Events

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

Ref document number: 25789240

Country of ref document: EP

Kind code of ref document: A1