A method for generating image title and related device
By screening and training image and text data sets, the generating electronic device can generate text captions of a specific style based on target images, solving the problem of limited types of captions in the existing technology and improving user experience and efficiency.
Patent Information
- Application Number
- CN202311057347.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-18
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2043-08-18
AI Technical Summary
When existing electronic devices generate image captions, the number and types of text captions are limited and cannot meet the personalized and diverse needs of users.
Obtain primary image and text data sets through training equipment, screen out high-quality image and text data sets, train the target image and text generation model, and generate text titles that conform to a specific style. The method includes obtaining an image data set, annotating text titles, screening high-quality image and text data pairs, training a style classification model and an image-text matching model, clustering text vectors, and fine-tuning the generation model to generate text titles of the target style.
It realizes the generation of text titles with specific styles based on target images, meets users' diverse and personalized needs for titles, improves user experience, and saves time and labor costs.
Smart Images

Figure CN117690130B
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image title generation method and related devices. Background Art
[0002] With the development of electronic devices such as smartphones, the function of taking pictures is becoming more and more powerful. More and more people use electronic devices to take pictures, and the number of photos in the gallery of electronic devices is increasing. In order to facilitate the query of photos, images are generally classified and stored using label information such as the location and time when the image was taken, and the image scene obtained by post-processing. Usually, a representative beautiful picture is selected as the album cover of a certain type of image, and a corresponding text title is added. At present, the number and types of text titles given by electronic devices to images are very limited, which cannot meet the personalized and diverse needs of users. Summary of the invention
[0003] The present application provides an image title generation method and related devices, which can generate a title with a specific style (such as a poetic style) according to a target image, so as to meet the user's demand for personalized title generation and improve the user experience.
[0004] In a first aspect, the present application provides an image title generation method, comprising: a training device obtains a primary image and text data set, the primary image and text data set includes multiple groups of training data pairs, and the training data pairs include images and text titles. The training device screens out a high-quality image and text data set from the primary image and text data set, wherein the high-quality image and text data set includes multiple groups of high-quality image and text data pairs, and the high-quality image and text data pair includes an image and a text title. The matching degree between the image and the text title in the high-quality image and text data pair is greater than a first matching degree threshold, and the style of the text title in the high-quality image and text data set is a target style. The training device trains a target image and text generation model through the high-quality image and text data set, and the target image and text generation model is used to generate a target text title corresponding to the input image according to the input image, and the style of the target text title is the target style.
[0005] Through the image title generation method provided by the present application, the training device can obtain a high-quality image and text dataset by screening the acquired data set, train the target style generation model through the high-quality image and text dataset, and generate a target text title in a target style for the target image through the target style generation model, thereby meeting the user's diverse and personalized needs for generated titles and improving the user experience.
[0006] In a possible implementation, a training device obtains a first image data set, which includes N images, where N is a positive integer greater than 1. The training device receives and responds to a first input from a user, and labels M images in the first image data set with text titles in multiple styles, where M is a positive integer less than N. The training device uses the M images and the text titles of the M images as a first image-text data set, and trains a first model through the first image-text data set. The training device generates text titles for L images in the image data set through the first model to obtain a second image-text data set, where the L images are not repeated with the M images, N=M+L, and L is a positive integer. The training device puts the first image-text data set and the second image-text data set into a primary image-text data set. In this way, a lot of time and labor costs are saved.
[0007] In a possible implementation, the training device crawls multiple sets of high-quality image-text data pairs from a web page using a web crawler technology as a third image-text data set, and puts the third image-text data set into the primary image-text data set. Optionally, the training device crawls multiple sets of high-quality image-text data pairs from a web page, and performs data cleaning and deduplication operations on the multiple sets of high-quality image-text data pairs as the third image-text data set. In this way, the content of the obtained third data set is not repeated, the data is not redundant, and the data is more accurate.
[0008] In a possible implementation, the training device obtains a second image data set, which includes a plurality of images. The training device generates a text title for each image in the second image data set through a text-image generation model to obtain a fourth text-image data set, and puts the fourth text-image data set into the primary text-image data set. In this way, a large number of training data sets can be quickly generated.
[0009] In a possible implementation, the training device may filter out a fifth image-text data set whose text title style is the target style from the primary image-text data set through a style classification model. The training device may filter out a plurality of high-quality image-text data pairs whose image-text matching degree of the image-text data pairs is greater than a first matching degree threshold from the fifth image-text data set through an image-text matching model, and use the plurality of high-quality image-text data pairs as the high-quality image-text data set.
[0010] In a possible implementation, the training device may further filter out a sixth image-text data set whose image-text matching degree is greater than a first matching degree threshold from the primary image-text data set through the image-text matching model. The training device may filter out a plurality of high-quality image-text data pairs whose text title style is the target style from the sixth image-text data set through the style classification model, and use the plurality of high-quality image-text data pairs as the high-quality image-text data set.
[0011] In a possible implementation, a training device obtains a text label data set, the text label data set includes multiple groups of text label pairs, the text label pairs include text titles and style labels, and the training device trains a style classification model using the text label data set.
[0012] In a possible implementation, a training device obtains a picture-text matching data set, the picture-text matching data set includes a plurality of picture-text matching pairs, the picture-text matching pairs include an image and a text title, and the matching degree between the image and the text title in the text matching pair is greater than a second matching degree threshold. The training device trains the picture-text matching model using the picture-text matching data set.
[0013] In this way, the training device can quickly filter out high-quality image and text data sets from the primary image and text data sets by training the classification style model and the image and text matching model.
[0014] In a possible implementation, the training device clusters a text vector set with the target style from a high-quality image and text data set through a clustering algorithm. When the training device trains the target image and text generation model through the high-quality image and text data set, the target image and text generation model is fine-tuned through the text vector set. In this way, the target text output by the target image and text generation model can be made more accurate.
[0015] In a possible implementation, the target style includes one or more of the following: Tang poetry, Song lyrics, Yuan opera, vernacular, English, modern poetry, classical Chinese, etc.
[0016] In a second aspect, the present application provides a training device comprising one or more processors and one or more memories; wherein the one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer program code, and the computer program code includes computer instructions, and when the one or more processors execute the computer instructions, the method in any possible implementation of the above-mentioned first aspect is executed.
[0017] In a third aspect, the present application provides another electronic device, comprising one or more functional modules, wherein the one or more functional modules are used to execute the method in any possible implementation of the first aspect above.
[0018] In a fourth aspect, the present application provides a chip system, comprising a processing circuit and an interface circuit, wherein the interface circuit is used to receive instructions and transmit them to the processing circuit, and the processing circuit is used to run the instructions to execute the method in any possible implementation of any of the above aspects.
[0019] In a fifth aspect, the present application provides a computer-readable storage medium comprising instructions, which, when executed on a processor of a training device, enables execution of a method in any possible implementation of the first aspect described above.
[0020] In a sixth aspect, an embodiment of the present application provides a computer program product, which, when executed on a computer, enables the computer to execute a method in any possible implementation of any of the above aspects. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0022] Figure 2A-2D A set of interface schematic diagrams provided for embodiments of the present application;
[0023] Figure 3A-3E Another set of interface schematic diagrams provided for embodiments of the present application;
[0024] Figure 4A-4G Another set of interface schematic diagrams provided for embodiments of the present application;
[0025] Figure 5 A schematic diagram of a title generation architecture provided in an embodiment of the present application;
[0026] Figure 6 A schematic diagram of a graphic data collection provided in an embodiment of the present application;
[0027] Figure 7 A schematic diagram of a method for screening graphic data provided in an embodiment of the present application;
[0028] Figure 8 A schematic diagram of a method for calculating image-text matching provided in an embodiment of the present application;
[0029] Fig. 9A A schematic diagram of a cluster analysis method provided in an embodiment of the present application;
[0030] Fig. 9B A schematic diagram of another cluster analysis method provided in an embodiment of the present application;
[0031] Fig.10 A schematic diagram of a model fine-tuning process provided in an embodiment of the present application;
[0032] Fig.11 A schematic diagram of another process of model fine-tuning provided in an embodiment of the present application;
[0033] Fig.12 A flowchart of a method for generating an image title provided in an embodiment of the present application;
[0034] Fig.13 A schematic diagram of the hardware structure of a training device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0035] The technical solutions in the embodiments of the present application will be described clearly and in detail below in conjunction with the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in the text is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0036] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more.
[0037] The following introduces the hardware structure of an electronic device provided in an embodiment of the present application.
[0038] Figure 1 A schematic structural diagram of an electronic device 100 provided in an embodiment of the present application is shown.
[0039] It should be understood that Figure 1 The electronic device 100 shown is only an example, and the electronic device 100 may have more Figure 1 More or fewer components may be shown, two or more components may be combined, or there may be a different configuration of components. Figure 1 The various components shown in the EMBODIMENTS 2000 may be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application specific integrated circuits.
[0040] The electronic device 100 may include: a processor 110, an external memory interface 120, an internal memory 121, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. Among them, the sensor module 180 may include a gyroscope sensor 180B, an acceleration sensor 180E, and a touch sensor 180K, etc.
[0041] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0042] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0043] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0044] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0045] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0046] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals.
[0047] The mobile communication module 150 can provide wireless communication solutions including 2G / 3G / 4G / 5G etc. applied on the electronic device 100 .
[0048] The modulation and demodulation processor may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing.
[0049] The wireless communication module 160 can provide wireless communication solutions for application in the electronic device 100, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication technology (NFC), infrared technology (IR), etc.
[0050] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, so that electronic device 100 can communicate with the network and other devices through wireless communication technology.
[0051] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0052] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel.
[0053] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.
[0054] The ISP is used to process data fed back by the camera 193 .
[0055] The camera 193 is used to capture still images or videos.
[0056] Digital signal processors are used to process digital signals. In addition to processing digital image signals, they can also process other digital signals.
[0057] Video codecs are used to compress or decompress digital video.
[0058] NPU is a neural-network (NN) computing processor. It can quickly process input information by drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, and can also continuously self-learn.
[0059] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100 .
[0060] The internal memory 121 may be used to store computer executable program codes, wherein the executable program codes include instructions.
[0061] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
[0062] The audio module 170 is used to convert digital audio information into analog audio signal output, and also used to convert analog audio input into digital audio signal. The audio module 170 can also be used to encode and decode audio signals.
[0063] The speaker 170A, also called a "horn", is used to convert audio electrical signals into sound signals.
[0064] The receiver 170B, also called a "handset", is used to convert audio electrical signals into sound signals.
[0065] Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals.
[0066] The earphone jack 170D is used to connect a wired earphone.
[0067] The gyro sensor 180B may be used to determine the motion posture of the electronic device 100 .
[0068] The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes).
[0069] The touch sensor 180K is also called a "touch panel". The touch sensor 180K can be set on the display screen 194. The touch sensor 180K and the display screen 194 form a touch screen, also called a "touch screen". The buttons 190 include a power button, a volume button, etc. The motor 191 can generate a vibration prompt. The SIM card interface 195 is used to connect a SIM card.
[0070] In the embodiment of the present application, the device type of the electronic device 100 can be a mobile phone, a tablet computer, a handheld computer, a desktop computer, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), as well as smart home devices such as smart large screens and smart speakers, wearable devices such as smart bracelets, smart watches, and smart glasses, extended reality (extended reality, XR) devices such as augmented reality (AR), virtual reality (VR), and mixed reality (MR), vehicle-mounted devices or smart city devices, and the like.
[0071] An embodiment of the present application provides a method for generating an image title. A training device obtains a primary image-text data set, which includes multiple sets of training data pairs, and the training data pairs include images and text titles. The training device screens out a high-quality image-text data set from the primary image-text data set, wherein the high-quality image-text data set includes multiple sets of high-quality image-text data pairs, and the high-quality image-text data pair includes an image and a text title, and the matching degree between the image and the text title in the high-quality image-text data pair is greater than a specified threshold, and the style of the text title in the high-quality image-text data set is a target style. The training device trains a target image-text generation model through the high-quality image-text data set, and the target image-text generation model is used to generate a target text title corresponding to the input image according to the input image, and the style of the target text title is the target style. This image title generation method saves a lot of time and labor costs, and meets the user's demand for generating personalized styles of titles.
[0072] In the following, a method for generating an image title according to an embodiment of the present application is specifically described in combination with an application scenario.
[0073] In some application scenarios, the electronic device 100 stores multiple images in the gallery. The electronic device 100 can classify the images according to the tag information of the images, and store the classified images in the corresponding storage paths of different albums. The electronic device 100 can select an image from the multiple images in the album as the cover image of the album, and generate a text title with a certain style (for example, a poetic style) based on the cover image. The electronic device 100 can display the cover image and the text title with a certain style on the album. Therefore, the user can judge the content of the images in the album according to the text title, while satisfying the user's needs for diversity and personalization of the generated text title, thereby improving the user experience.
[0074] For example, Figure 2A As shown, the electronic device 100 may display a home screen interface 210. The interface 210 displays a page with application icons, which includes multiple application icons (e.g., weather application icon, stock application icon, calculator application icon, setting application icon, mail application icon, gallery application icon 211, etc.).
[0075] The electronic device 100 may receive an input (eg, a click) from a user on the gallery application icon 211. In response to the input, the electronic device 100 may display a Figure 2B The photo interface 220 shown. The photo interface 220 includes one or more images. The photo interface 220 includes multiple controls (e.g., photo controls, album controls, moment controls 221, and discovery controls) below.
[0076] The electronic device 100 may receive an input (eg, a click) from a user on the moment control 221, and in response to the input, the electronic device 100 may display a Figure 2C The time interface 230 is shown.
[0077] like Figure 2CAs shown, the moment interface 230 may include one or more albums. Among them, a cover image and a text title, etc. may be displayed on each album. The one or more albums may include an album 231 and an album 235. A cover image 232 and a text title 233 may be displayed on the album 231, and the cover image 232 is an image in the album 231. The text title 233 may be a text title with a poetic style describing the cover image 232 of the album (for example, "Shadows of trees, koalas playing"). Optionally, the album 231 may also display a shooting date 234 of the cover image 232. A cover image 236 and a text title 237 may be displayed on the album 235, and the cover image 236 is an image in the album 235. The text title 237 may be a text title with a poetic style describing the cover image 236 of the album (for example, "Exquisite snacks, light fragrance"). Optionally, the photo album 235 may also display the shooting date 238 of the cover image 236 .
[0078] The electronic device 100 may receive an input (eg, a click) from a user on the photo album 231. In response to the input, the electronic device 100 may display the following information: Figure 2D Album interface 240 is shown.
[0079] like Figure 2D As shown, the album interface 240 may include an image playback area 241, a text title 242 (e.g., "Shadows of trees dancing, koalas playing"), and an image area 243. The image playback area 241 will play the images in the album in sequence. The text title 242 is a poetic text title generated based on the cover image of the album. The image area 243 includes multiple images.
[0080] In some application scenarios, the user can view images taken by the electronic device 100 and images obtained from other devices or the network in the gallery application of the electronic device 100. The electronic device 100 can edit the image selected by the user in the gallery in response to the user's input, triggering the generation of a text title with a certain style (for example, a poetic style) based on the image. In this way, it is convenient for the user to generate a text title with a certain style for the image he likes at any time, thereby improving the user experience.
[0081] For example, Figure 3A As shown, the photo interface 220 includes one or more images. The one or more images may include image 222. The electronic device 100 may receive an input (e.g., a click) from a user on image 222. In response to the input, the electronic device 100 may display a Figure 3B The image processing interface 310 is shown.
[0082] like Figure 3BAs shown, the image processing interface 310 includes an image 312 and one or more controls (eg, a share control, a favorite control, an edit control 311 , a delete control, etc.).
[0083] The electronic device 100 may receive an input (eg, a click) from a user on the edit control 311, and in response to the input, the electronic device 100 may display a Figure 3C An image editing interface 320 is shown.
[0084] like Figure 3C As shown, the image editing interface 320 may include an image 322, one or more controls (eg, a graffiti control, a title generation control 321, a labeling control, etc.), wherein the image 322 is an image to be processed selected by the user.
[0085] The electronic device 100 may receive an input (eg, a click) from a user on the title generation control 321. In response to the input, the electronic device 100 may display a title on the image editing interface 320. Figure 3D Wait prompt 331 is shown.
[0086] The waiting prompt 331 can be used to prompt the user that the electronic device 100 is generating a text title for the image 322. The waiting prompt 331 can be a text prompt, a voice prompt, etc., which is not limited here.
[0087] After completing the text title generation, the electronic device 100 cancels the display of the waiting prompt 331. The electronic device 100 can generate a text title 341 (for example, "Shadows of trees, koalas playing") corresponding to the image 332 according to the target image-text generation model, and display the text title 341 as shown in FIG. Figure 3E An image editing interface 320 is shown.
[0088] like Figure 3E As shown, the image editing interface 320 includes a text title 341 (e.g., "Shadows of trees dancing, koalas playing") and a save control 342. The text title 341 can be displayed at any position in the image 322, without limitation. The save control 342 can be used to trigger the electronic device 100 to save the edited image 322 (including generating the text title 341).
[0089] In some application scenarios, the electronic device 100 may be installed with an image editing application. The image editing application may generate a text title with a certain style (e.g., a poetic style) for an image. A user may select an image for which a text title with a certain style is desired to be generated in the image editing application, and a text title with a certain style is generated for the image.
[0090] For example, Figure 4AAs shown, the electronic device 100 may display a home screen interface 410. A page with application icons is displayed in the interface 410. The page includes multiple application icons, for example, an image editing application icon 411 and the like.
[0091] The electronic device 100 may receive an input (eg, a click) from a user on the image editing application icon 411, and in response to the input, the electronic device 100 may display a Figure 4B The image import interface 420 shown in FIG. The image import interface 420 includes an import image control 421. The electronic device 100 may receive a user input (e.g., a single click) on the import image control 421. In response to the input, the electronic device 100 may display a local image control 422 and a take a photo control 423 below the image import interface 420.
[0092] like Figure 4C As shown, the local image control 422 and the take a photo control 423 are displayed below the image import interface 420. The take a photo control 423 can trigger the electronic device 100 to take an image. The electronic device 100 can receive an input (such as a click) from the user on the local image control 422. In response to the input, the electronic device 100 can display the following information: Figure 4D An image adding interface 430 is shown.
[0093] like Figure 4D As shown, the image adding interface 430 includes an adding control 432, one or more images (e.g., image 431), and a selection control 433. Each image has a corresponding selection control. For example, image 431 corresponds to selection control 433, and the electronic device 100 can receive input from the user acting on the selection control 433 (e.g., single click), and in response to the input, the electronic device 100 can select the image 431. Optionally, the electronic device 100 can simultaneously receive input from the user acting on multiple selection controls (e.g., single machine), and in response to the input, the electronic device 100 can select multiple images.
[0094] The electronic device 100 may receive a user input (eg, a click, such as Figure 4E In response to the input, the electronic device 100 may display Figure 4F An image editing interface 440 is shown.
[0095] like Figure 4FAs shown, the image editing interface 440 includes an image 431 and one or more controls (e.g., a text title generation control 442). The image 431 is an image selected by a user and received by the electronic device 100. The electronic device 100 can receive an input (e.g., a click) from the user on the text title generation control 442. In response to the input, the electronic device 100 can generate a text title 451 corresponding to the image 431 according to the image 431 through the target image-text generation model, and display the text title 451 as shown in FIG. Figure 4G A text title generation interface 450 is shown.
[0096] like Figure 4G As shown, the text title generation interface 450 includes an image 431, an image 455, a text title 451, and one or more controls (e.g., a save control 453, a regenerate control 454, etc.). The image 431 is an image selected by the user received by the electronic device 100, and the user wants to generate a text title with a certain style. The text title 451 is a text title with a certain style that describes the image 431, and the position of the text title 451 in the image 431 is not limited. The image 431 and the text title 451 constitute the image 455. The save control 453 can trigger the electronic device 100 to save the image 455. The regenerate control 454 is used to trigger the electronic device 100 to regenerate the text title 451 with a certain style.
[0097] The following describes the process of the image title generation method in an embodiment of the present application.
[0098] Figure 5 A schematic diagram of an image title generation architecture provided by an embodiment of the present application is shown.
[0099] like Figure 5 As shown, the image caption generation architecture diagram may include four stages. Stage 1 is the image and text data set collection stage. Stage 2 is the image and text data set screening stage. Stage 3 is the model training stage. Stage 4 is the inference stage.
[0100] Phase 1: Collection of graphic and text datasets.
[0101] In the image and text data set collection phase, the training device can collect primary image and text data sets containing various styles. The primary image and text data sets can include one or more of the following: derived image and text data sets, crawled image and text data sets, and large language image and text data sets.
[0102] 1. How to obtain the derived image and text dataset:
[0103] The training device can obtain an image data set, wherein the image data set includes multiple images. The training device can receive user input and annotate a portion of the images in the image data set with text titles of various styles. The training device can determine the portion of images and the annotated text titles as an artificial image-text data set. The artificial image-text data set includes multiple groups of image-text data pairs, each group of image-text data pairs includes an image and a text title corresponding to the image.
[0104] The training device can train a contrastive language-image pre-training (CLIP) model 501 through an artificial image-text data set. The training device can generate text captions for another part of the images in the image data set that are not labeled with text captions through the trained CLIP model. The training device can determine the other part of the images and the text captions generated by the CLIP model as the image-text data set 1. Among them, the image-text data set 1 includes multiple groups of image-text data pairs, each group of image-text data pairs includes an image and a text caption corresponding to the image. The image-text data pairs obtained by this acquisition method are of high quality and good consistency.
[0105] For example, the text title C1 corresponding to the picture P1 in the artificial picture and text dataset can be "Red and tender hands, yellow rattan wine, the whole city is full of spring colors and willows on the palace walls", and the text title C2 corresponding to the picture P2 in the artificial picture and text dataset can be "The rain on the street is as soft as butter, the grass looks green from a distance but is not green when you get close".
[0106] For example, the text title C3 corresponding to the picture P3 in the picture-text dataset 1 may be “Shadows of trees sway, koalas play”.
[0107] The training device may use the artificial image-text dataset and the image-text dataset 1 as derived image-text datasets.
[0108] 2. How to obtain the crawled image and text dataset:
[0109] The training device can search for web pages with various images and texts on the Internet through web crawler technology, and crawl the images and the text paired with the images from the web pages as web page image-text data pairs. The training device can perform data cleaning, deduplication and other operations on multiple groups of web page image-text data pairs crawled by web crawler technology to obtain crawled image-text data sets. Among them, data cleaning can refer to removing image-text data pairs in web page image-text data pairs that are not suitable as training data because the images are unclear, the texts are too long, etc. Deduplication can refer to removing data pairs with repeated images or texts in web page image-text data pairs, and only retaining one group of web page image-text data pairs. This acquisition method can obtain a large number of primary valid image-text data pairs.
[0110] 3. How to obtain the large language image and text dataset:
[0111] The training device can obtain a second image data set, wherein the second image data set includes multiple images. The training device can generate a text title corresponding to the image based on image reasoning through a language model. The image and the text title corresponding to the image are a set of image-text data pairs, and multiple sets of image-text data pairs constitute a large language image-text data set. This acquisition method can quickly generate a large number of image-text data pairs.
[0112] like Figure 6 As shown, the training device can input the image into the trained image-text generation model, and the image-text generation model generates a text title according to the input image. The image-text generation model first converts the input image into a prompt vector sequence through the CLIP model and the multilayer perceptron (MLP) model, and then converts the prompt vector sequence into explanatory text symbols through the large language model, and finally outputs it as a text title. The input image and the text title generated by the image-text generation model are determined as a large language image-text data set. Among them, the large language image-text data set includes multiple groups of image-text data pairs, and each group of image-text data pairs includes an image and a text title corresponding to the image.
[0113] Phase 2: Screening of image and text datasets.
[0114] In the image and text dataset screening stage, the training device can obtain a text label dataset, wherein the text label dataset includes a plurality of groups of text label pairs, and the text label pairs include text titles and style labels.
[0115] The training device may train the style classification model 502 through the text label data set. The trained style classification model 502 may determine the style of the image-text data pair according to the input image-text data pair.
[0116] For example, the text label dataset may include a Tang poetry label dataset, a Song poetry label dataset, a Yuan opera label dataset, etc.
[0117] For example, the text label corresponding to the text title C5 "A lone sail disappears into the blue sky, only the Yangtze River can be seen flowing across the horizon" in the Tang poetry label data set can be D5 "Tang poetry, seven-character verse". The text label corresponding to the text title C6 "I want to ride the wind and return, but I am afraid that the jade buildings and jade palaces are too high and cold" in the Song poetry label data set can be "Song poetry, graceful". After the training device trains the style classification model 502, the training device can determine the style type of each group of image-text data pairs in the primary image-text data set through the style classification model 502. The training device can remove the image-text data pairs whose style cannot be identified. The training device can filter out the target style image-text data set of the style we want (such as Tang poetry) from the primary image-text data set.
[0118] For example, Figure 7As shown. The training device can receive user input, select and annotate a batch of training data with text style types from the primary image and text data set. The training data includes text titles and style labels such as Tang poetry, Song lyrics, Yuan opera, modern poetry, and prose, which are used to train the BERT model to classify title text data. The trained BERT model 701 and the classification model 702 form a style classification model.
[0119] For example, the input features are a text title and a style label corresponding to the text title. The training device can receive the text title and the style label, distinguish the style type of the text title through the trained BERT model 701 in the style classification model, and then determine whether the text title is in the target style through the style classification model 702. If so, the text title and its corresponding image are retained and output, and if not, they are not retained. This method can screen out image-text data pairs that meet the required style.
[0120] The training device can use the trained style classification model to filter out image-text data pairs with a target style (such as Tang poetry) from the primary image-text data set, and remove image-text data pairs with a non-target style (such as Song poetry).
[0121] The training device can filter out target style image-text data pairs of different styles (for example, Tang poetry, Song lyrics, Yuan opera, vernacular, English, modern poetry, classical Chinese, etc.) from the primary image-text data set, and the target style image-text data pairs constitute the target style image-text data set.
[0122] In the image-text data set screening stage, the training device can receive the user's input, select multiple groups of image-text data pairs with high image and text matching degree from the primary image-text data set, the image-text matching pair includes an image and a text title, and the matching degree of the image and the text title in the image-text matching pair is greater than the second matching degree threshold, and use the multiple groups of image-text data pairs as the image-text matching data set.
[0123] The training device can first train the image-text matching (IMT) model 503 through the image-text matching data set. The image-text matching data set includes multiple groups of image-text data pairs, each group of image-text data pairs includes an image and a text title of the image. The trained image-text matching model 503 can determine the matching score of the image and the text title in the image-text data pair according to the input image-text data pair. The higher the matching score, the higher the matching degree between the text title in the image-text data pair and the content in the image.
[0124] For example, the value range of the matching score may be 0 to 100. When the matching score is 100, it indicates that the text title in the image data pair matches the content in the image most highly. When the matching score is 0, it indicates that the text title in the image data pair matches the content in the image least highly.
[0125] After the training device has trained the image-text matching model 503 , the training device may determine the matching score of each image-text data pair in the primary image-text data set through the image-text matching model 503 .
[0126] The training device may filter out a high-matching image-text data set whose matching score is greater than a first matching threshold (eg, 80 points) from the primary image-text data set.
[0127] For example, Figure 8 A set of image-text data pairs includes an image and a text title of the image. The training device uses a text encoder 801 to generate a vector (embedding) of the text title of the image and encodes it into a set of text vectors (T j ∈T). The training device uses the image encoder 802 to generate the vector (embedding) of the image and encodes it into a set of image vectors (I i ∈I). Text vector (T j ∈T) and the image vector (I i ∈I) as a training data set for the image-text matching model. The image encoder 802 and the text encoder 801 are a transformer structure with 12 layers, 512 channels and 8 attention heads.
[0128] The image-text matching model can use a multimodal pre-trained CLIP model. The training device can use a learning function s(I i , T j ), calculate the image vector (I i ∈I) and the text vector (T j ∈T). The image and text on the main diagonal are a pair and are taken as positive samples (I i , T i The remaining images and texts are taken as negative samples (I i , T j ), i is not equal to j. The cosine value of the positive sample is maximized and the cosine value of the negative sample is minimized to obtain the loss function. This loss function can be used to fine-tune the multimodal pre-trained CLIP model. After the multimodal CLIP model is fine-tuned by the loss function, the image-text data pairs are screened according to the similarity score of text-to-image retrieval and the corresponding threshold is set by calculating the ITM score to screen out the data pairs with a high degree of image-text matching. The image-text data pairs obtained by this method have a high degree of image-text matching.
[0129] The style classification model 502 and the image-text matching model 503 constitute a high-quality image-text data set training module 504. The high-quality image-text data set training module 504 can perform style classification and image-text matching on the image-text data pairs of the primary image-text data set to obtain a high-quality image-text data set with a certain style and a high degree of image-text matching. The training device can filter out high-quality image-text data pairs with a matching score greater than a first matching degree threshold (e.g., 80 points) from the target style image-text data set, and multiple groups of the high-quality image-text data pairs constitute a high-quality image-text data set.
[0130] The training device can filter out data pairs of different styles (for example, Tang poetry, Song lyrics, Yuan opera, vernacular, English, modern poetry, classical Chinese, etc.) from high-matching image and text datasets, and multiple groups of these data pairs constitute a high-quality image and text dataset.
[0131] Phase 3: Model training phase.
[0132] In the model training phase, the training device uses the high-quality image and text data set obtained in phase 2 to train the target image and text generation model 506. The target image and text generation model 506 can be a multimodal pre-trained CLIP model or other types of models, which are not limited here.
[0133] In a possible implementation, the training device uses a high-quality image-text data set to train the target image-text generation model 506. The trained target image-text generation model 506 can generate target text titles with various styles and a high degree of matching with the image according to the input target image.
[0134] In a possible implementation, the training device first performs cluster analysis on the high-quality image and text data set obtained in stage 2 according to the text title of the image to obtain image and text data sets of various styles (for example, image and text data sets in the style of Tang poetry, image and text data sets in the style of Song lyrics, image and text data sets in the style of modern prose, etc.). The training device can use the k-means clustering algorithm to cluster a text vector set with a target style from the image and text data set. The text vector set includes multiple text vectors. The training device can fine-tune the target image and text generation model 506 through the text vector set, and the target image and text generation model after fine-tuning the text vector set can make the style of the generated target text title more accurate.
[0135] For example, Figure 9A-9B As shown. The training device performs cluster analysis on the high-quality image and text dataset according to the text vector of the text title. The traditional mean clustering algorithm (k-means), such as Fig. 9AAs shown. Actual points 902, 903, and 904 represent the position distribution of text vectors of text titles with the same style, and average point 901 represents the average center position of the text vectors of the text titles of this style. In reality, there is no text vector for this text title. For example, actual point 902 represents text vector A, actual point 903 represents text vector B, actual point 904 represents text vector C, and average point 901 represents the centroid obtained by the k-means clustering algorithm. In reality, there is no text vector represented by average point 901.
[0136] The training device uses the center point clustering algorithm (k-mediods), such as Fig. 9B As shown in the figure, after finding the average point 901, the algorithm will select an actual point 902 closest to the average as the centroid. The actual point 902 can represent the text vector A. The text vector A is the text vector of the optimal text title that really exists in the data set, and is also the cluster center of the text vectors of the text title of this style. Therefore, the k-mediods algorithm can be used to find the text vector of the optimal text title that really exists as the cluster center of the text vector of this style.
[0137] The training device can vectorize the text into various styles of text and image title data packets through the cluster center of the text vector of the text title. For example, the training device finds the cluster center of the text vector of the text title with the style of Tang poetry, packs the text vector and the text vectors in the nearby area, and obtains a text and image title data packet in the style of Tang poetry. The training device can send the text and image title data packet to the electronic device.
[0138] Optionally, when training the target image-text generation model 506, the training device introduces additional grid branches (for example, text titles with typical Tang poetry style), integrates information of specific style title data, and guides the model's parameter learning to increase the diversity and typicality of the model's generated title style.
[0139] like Fig.10 As shown, it includes an image encoder 1001, a text encoder 1002, and a similarity regulator 1003. The image encoder 1001 is used to convert the input image into an image vector. The text encoder 1002 is used to convert the input text title and the text title of a typical style into a text vector. The text title of a typical style can be a text title obtained by cluster analysis or a manually selected text title or a manually written text title. The similarity regulator 1003 obtains a multi-class N-pair loss function by calculating the image vector and the text vector. The multi-class N-pair loss function is used to reduce the loss between the text title of a typical style and the target text title, so that the target text title generated by the target image-text generation model is closer to the text title of the typical style.
[0140] Stage 4: Reasoning stage.
[0141] In the inference stage, the trained target image-text generation model is transplanted to the electronic device 100. The electronic device 100 can obtain a target image and infer a target text title from the target image through the target image-text generation model.
[0142] For example, Fig.11 As shown, the trained target image and text generation model 506 has been transplanted to the electronic device. The trained target image and text generation model 506 includes three parts: an image editing module 5061, a reasoning module 5062, and a text decoding module 5063. The image editing module 5061 can convert the input target image into a target image vector. The target image is an image received by the electronic device for the user's selection. The text decoding module 5063 can convert the target text vector into a target text title. The reasoning module 5062 can generate a target text vector based on the target image vector.
[0143] In a possible implementation, the inference module 5062 includes a plurality of styles of picture and text title data packets, which may be the picture and text title data packets of the plurality of styles obtained in stage 3. Each picture and text title data packet includes a plurality of target style text vectors, and the target style text vectors in the same picture and text title data packet have the same style. The electronic device may receive the user's selection of the picture and text title data packet and generate a target text vector.
[0144] For example, the electronic device receives an input from a user selecting a Tang poetry style. In response to the input, the reasoning module 5062 selects a picture and text title data packet with a Tang poetry style to fine-tune the text vector pre-outputted inside the reasoning module 5062, so that the target text vector outputted by the reasoning module 5062 has a Tang poetry style. The target text vector is decoded by the text decoding module 5063 to obtain a target text title with a Tang poetry style. This method can facilitate users to select the style of the target text title they want to generate.
[0145] In a possible implementation, the electronic device 100 includes a plurality of styles of graphic title data packets, which may be graphic title data packets of various styles obtained in stage 3. When the inference module 5062 receives the target image vector, the electronic device 100 may receive a user's selection of a plurality of styles of graphic title data packets. The inference module 5062 fine-tunes the internal pre-output text vector according to the graphic title data packet selected by the user, so that the output target text vector has more of the style of the graphic title data packet.
[0146] In some embodiments, the electronic device 100 can receive an image selected by a user. The electronic device 100 can generate texts of various styles based on the image selected by the user by using a trained target image-text generation model. The text may include a title, descriptive text, and the like. Optionally, the style of the text can be generated by the electronic device 100 based on the user's selection. For example, the electronic device 100 receives a user input of an image P10, and the user chooses to generate a text in a modern prose style. The electronic device 100 generates a text C10 "Ah, petrel, you better be careful and don't be swallowed by the sea". There is no limit on the number of words in the text.
[0147] In some embodiments, the electronic device 100 can also identify images containing e-commerce products. The electronic device 100 can generate texts of various styles based on the e-commerce products in the image through the trained target image-text generation model. The texts may include titles, descriptions, and the like.
[0148] In some embodiments, the electronic device 100 may also receive an image selected by a user. The electronic device 100 may generate advertisement texts of various styles based on the image selected by the user by using a trained target image-text generation model. The advertisement texts may include titles, description texts, and the like.
[0149] In some embodiments, the electronic device 100 may also receive an image of a video frame, etc. The electronic device 100 may generate texts of various styles based on the image of the video frame by using a trained target image-text generation model. The texts may include titles, descriptions, etc.
[0150] In some embodiments, the electronic device 100 can also generate texts of various styles according to specific content or entities in the image and video through the trained target image-text generation model. The texts may include titles, descriptions, and the like.
[0151] The following describes an image title generation method provided in an embodiment of the present application.
[0152] Fig.12 A schematic flow chart of a method for generating an image title provided in an embodiment of the present application is shown.
[0153] like Fig.12 As shown, the method includes:
[0154] S1201. A training device obtains a primary image-text data set, where the primary image-text data set includes multiple sets of training data pairs, where the training data pairs include images and text titles.
[0155] The training device obtains a first image data set, which includes N images, where N is a positive integer greater than 1. The training device receives and responds to a first input from a user, and labels M images in the first image data set with text titles in multiple styles, where M is less than N, and M is a positive integer less than N. The training device uses the M images and the text titles of the M images as a first image-text data set, and trains a first model through the first image-text data set. The training device generates text titles for L images in the image data set through the first model to obtain a second image-text data set, where the L images are not repeated with the M images, N=M+L, and L is a positive integer. The training device puts the first image-text data set and the second image-text data set into a primary image-text data set. In this way, a lot of time and labor costs are saved.
[0156] The first image dataset may be the above Figure 5 In the illustrated embodiment, the image dataset used by the training device is used in the process of obtaining the derived image and text dataset in stage one.
[0157] The first image and text dataset can be the above Figure 5 In the illustrated embodiment, in the process of acquiring the derived image and text dataset in stage 1, the artificial image and text dataset used by the training device is used.
[0158] The first model can be the above Figure 5 In the illustrated embodiment, in the process of acquiring the derived text-image dataset in stage 1, a contrastive language-image pre-training (CLIP) model used by the training device is used.
[0159] The second image and text dataset can be the above Figure 5 In the illustrated embodiment, in the process of acquiring the derived graphic and text dataset in stage 1, the graphic and text dataset 1 used by the training device is used.
[0160] In a possible implementation, the training device crawls multiple sets of high-quality image-text data pairs from a web page using a web crawler technology as a third image-text data set, and puts the third image-text data set into the primary image-text data set. Optionally, the training device crawls multiple sets of high-quality image-text data pairs from a web page, and performs data cleaning and deduplication operations on the multiple sets of high-quality image-text data pairs as the third image-text data set. In this way, the content of the obtained third data set is not repeated, the data is not redundant, and the data is more accurate.
[0161] The third image and text dataset may be the above Figure 5 In the illustrated embodiment, in the process of acquiring the crawled graph and text dataset in stage one, the crawled graph and text dataset used by the training device is used.
[0162] In a possible implementation, the training device obtains a second image data set, which includes a plurality of images. The training device generates a text title for each image in the second image data set through a text-image generation model to obtain a fourth text-image data set, and puts the fourth text-image data set into the primary text-image data set. In this way, a large number of training data sets can be generated.
[0163] The fourth image and text dataset may be the above Figure 5 In the illustrated embodiment, in the process of acquiring a large language image and text dataset in stage one, the large language image and text dataset used by the training device is used.
[0164] For specific training equipment to obtain the content of the primary image and text dataset, please refer to the above Figure 5 The embodiment shown.
[0165] S1202, the training device selects a high-quality image and text data set from the primary image and text data set, wherein the high-quality image and text data set includes a plurality of high-quality image and text data pairs, and the high-quality image and text data pair includes an image and a text title. The matching degree between the image and the text title in the high-quality image and text data pair is greater than a first matching degree threshold, and the style of the text title in the high-quality image and text data set is a target style. In this way, high-quality data that meets the needs of the training device can be obtained to guide model training.
[0166] In the embodiment of the present application, the target style may include one or more of Tang poetry, Song lyrics, Yuan opera, vernacular, English, modern poetry, classical Chinese, etc. The target style may also be other styles, which are not limited in the embodiment of the present application.
[0167] In a possible implementation, the training device may filter out a fifth image-text data set whose text title style is the target style from the primary image-text data set through a style classification model. The training device may filter out a plurality of high-quality image-text data pairs whose image-text matching degree of the image-text data pairs is greater than a first matching degree threshold from the fifth image-text data set through an image-text matching model, and use the plurality of high-quality image-text data pairs as the high-quality image-text data set.
[0168] Among them, the fifth image and text data set can be the above Figure 5 The target style image and text dataset in stage 2 in the illustrated embodiment.
[0169] In a possible implementation, the training device may further filter out a sixth image-text data set whose image-text matching degree is greater than a first matching degree threshold from the primary image-text data set through the image-text matching model. The training device may filter out a plurality of high-quality image-text data pairs whose text title style is the target style from the sixth image-text data set through the style classification model, and use the plurality of high-quality image-text data pairs as the high-quality image-text data set.
[0170] Among them, the sixth image and text data set can be the above Figure 5 The illustrated embodiment shows a high-matching image and text dataset in stage two.
[0171] In a possible implementation, a training device obtains a text label data set, the text label data set includes multiple groups of text label pairs, the text label pairs include text titles and style labels, and the training device trains a style classification model using the text label data set.
[0172] In a possible implementation, a training device obtains a picture-text matching data set, the picture-text matching data set includes a plurality of picture-text matching pairs, the picture-text matching pairs include an image and a text title, and the matching degree between the image and the text title in the picture-text matching pairs is greater than a second matching degree threshold. The training device trains the picture-text matching model using the picture-text matching data set.
[0173] For details about the process of selecting high-quality image and text datasets from primary image and text datasets, please refer to the above Figure 5 The embodiment shown.
[0174] S1203. The training device trains a target image-text generation model using a high-quality image-text data set. The target image-text generation model is used to generate a target text title corresponding to the input image according to the input image. The style of the target text title is a target style.
[0175] In a possible implementation, the training device clusters a text vector set with the target style from the high-quality image and text data set through a clustering algorithm. When the training device trains the target image and text generation model through the high-quality image and text data set, the training device fine-tunes the target image and text generation model through the text vector set.
[0176] For details on how to train the target image-text generation model using high-quality image-text datasets, please refer to the above Figure 5 The embodiment shown.
[0177] The following is a schematic diagram of the hardware structure of a training device provided in an embodiment of the present application.
[0178] Fig.13 The structure of a training device provided in an embodiment of the present application is shown.
[0179] like Fig.13As shown, the training device 1300 may include a communication interface 1301 and a processor 1302. Optionally, the training device 1300 may also include a memory 1303. The memory 1303 may be arranged inside the training device 1300 or outside the training device 1300. The functions implemented by the training device 1300 described in the above embodiments may all be implemented by the processor 1302. The processor 1302 receives a data stream through the communication interface 1301 and is used to implement the image title generation method described in any of the above embodiments. During the implementation process, each step of the processing flow may be completed by an integrated logic circuit of hardware or an instruction in software form in the processor 1302 to complete the image title generation method described in any of the above embodiments. For the sake of brevity, it will not be repeated here. The program code executed by the processor 1302 for implementing the model training in the image title generation method described in any of the above embodiments may be stored in the memory 1303. The memory 1303 is coupled to the processor 1302.
[0180] The processor involved in the embodiments of the present application may be a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component, and may implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0181] The coupling in the embodiments of the present application is an indirect coupling or communication connection between devices, modules or modules, which can be electrical, mechanical or other forms, and is used for information exchange between devices, modules or modules.
[0182] The processor may operate in conjunction with a memory. The memory may be a non-volatile memory, such as a hard disk drive (HDD) or a solid-state drive (SSD), or a volatile memory, such as a random-access memory (RAM). The memory is any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto.
[0183] The specific connection medium between the communication interface, processor and memory is not limited in the embodiments of the present application. For example, the memory, processor and communication interface may be connected via a bus. The bus may be divided into an address bus, a data bus, a control bus, etc.
[0184] The embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0185] The embodiments of the present application also provide a computer program product. When the computer program product is executed on an electronic device, the electronic device can implement the steps in the above-mentioned method embodiments.
[0186] The embodiment of the present application also provides a chip system, the chip system includes a processor, the processor is coupled to a memory, and the processor executes a computer program stored in the memory to implement the steps of any method embodiment of the present application. The chip system can be a single chip or a chip module composed of multiple chips.
[0187] The term "user interface (UI)" in the specification and drawings of this application refers to the medium interface for interaction and information exchange between an application or operating system and a user, which realizes the conversion between the internal form of information and the form acceptable to the user. The user interface of an application is a source code written in a specific computer language such as Java and extensible markup language (XML). The interface source code is parsed and rendered on the electronic device, and finally presented as content that the user can recognize, such as images, text, buttons and other controls. Controls, also known as widgets, are the basic elements of the user interface. Typical controls include toolbars, menu bars, text boxes, buttons, scroll bars, images and text. The properties and contents of controls in the interface are defined by tags or nodes, such as XML through <textview> 、 <imgview> 、 <videoview>The controls contained in the interface are specified by nodes such as <head> and <body>. A node corresponds to a control or attribute in the interface. After being parsed and rendered, the node is presented as user-visible content. In addition, many applications, such as hybrid applications, usually also contain web pages in their interfaces. A web page, also known as a page, can be understood as a special control embedded in the application interface. A web page is source code written in a specific computer language, such as hypertext markup language (HTML), cascading style sheets (CSS), JavaScript (JS), etc. The web page source code can be loaded and displayed as user-recognizable content by a browser or a web page display component with similar functions to a browser. The specific content contained in a web page is also defined by tags or nodes in the web page source code. For example, HTML is defined by <body> tags or nodes in the web page source code. 、 、 <video> 、 <canvas>To define the elements and attributes of a web page.
[0188] The most common form of user interface is graphical user interface (GUI), which refers to a user interface related to computer operation that is displayed in a graphical manner. It can be an icon, window, control or other interface element displayed on the display screen of an electronic device, where a control can include icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, widgets and other visual interface elements.
[0189] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that contains one or more available media integration. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk), etc.
[0190] Those skilled in the art can understand that to implement all or part of the processes in the above-mentioned embodiments, the processes can be completed by computer programs to instruct related hardware, and the programs can be stored in computer-readable storage media. When the programs are executed, they can include the processes of the above-mentioned method embodiments. The aforementioned storage media include: ROM or random access memory RAM, magnetic disk or optical disk and other media that can store program codes.
[0191] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.< / canvas> < / video> < / videoview> < / imgview> < / textview>
Claims
1. A method for generating image titles, It is characterized in that include: Acquire a primary image-text dataset, wherein the primary image-text dataset includes a plurality of training data pairs, wherein the training data pairs include images and text titles; Filtering a high-quality image-text data set from the primary image-text data set, wherein the high-quality image-text data set includes a plurality of high-quality image-text data pairs, the high-quality image-text data pair includes an image and a text title, the matching degree between the image and the text title in the high-quality image-text data pair is greater than a first matching degree threshold, and the style of the text title in the high-quality image-text data set is a plurality of styles; Clustering a text vector set with a target style from the high-quality image and text dataset using a clustering algorithm; The target image-text generation model is trained by a high-quality image-text dataset and fine-tuned by the text vector set. The target image-text generation model is used to generate a target text title corresponding to the input image according to the input image, and the style of the target text title is the target style.
2. The method according to claim 1, It is characterized in that The method further comprises: Acquire a first image data set, where the first image data set includes N images, where N is an integer greater than 1; Receiving and responding to a first input from a user, marking M images in the first image data set with text captions in multiple styles, where M is a positive integer less than N; Using the M images and the text titles of the M images as a first image-text dataset, and training a first model through the first image-text dataset; Generate text captions for L images in the image dataset by using the first model to obtain a second image-text dataset, wherein the L images are not repeated with the M images, N=M+L, and L is a positive integer; The first image and text data set and the second image and text data set are placed into the primary image and text data set.
3. The method according to claim 1 or 2, It is characterized in that The method further comprises: A plurality of web page image-text data pairs are crawled from web pages by web crawler technology as a third image-text data set, and the third image-text data set is put into the primary image-text data set, wherein the web page image-text data pair includes an image and a text title.
4. The method according to claim 3, It is characterized in that The crawling of multiple sets of web page image and text data pairs from the web page as the third image and text data set specifically includes: A plurality of sets of web page image and text data pairs are crawled from the web page, and the plurality of sets of web page image and text data pairs are cleaned and deduplicated to serve as the third image and text data set.
5. The method according to claim 1 or 2, It is characterized in that The method further comprises: Acquire a second image data set, where the second image data set includes a plurality of images; Generate a text title for each image in the second image data set through a picture-text generation model to obtain a fourth picture-text data set, and put the fourth picture-text data set into the primary picture-text data set.
6. The method according to claim 1, It is characterized in that The step of selecting a high-quality image and text dataset from the primary image and text dataset specifically includes: Filtering a fifth image-text dataset whose text title style is a target style from the primary image-text dataset by using a style classification model; A plurality of high-quality image-text data pairs whose image-text matching degrees are greater than a first matching degree threshold are screened out from the fifth image-text data set through the image-text matching model, and the plurality of high-quality image-text data pairs are used as the high-quality image-text data set.
7. The method according to claim 1, It is characterized in that The step of selecting a high-quality image and text dataset from the primary image and text dataset specifically includes: Screening out a sixth image-text data set having an image-text matching degree greater than a first matching degree threshold from the primary image-text data set by using the image-text matching model; A plurality of high-quality image-text data pairs whose text title styles are the target styles are screened out from the sixth image-text data set through a style classification model, and the plurality of high-quality image-text data pairs are used as the high-quality image-text data set.
8. The method according to claim 6 or 7, It is characterized in that Before screening out a high-quality image and text dataset from the primary image and text dataset, the method further includes: Acquire a text label dataset, wherein the text label dataset includes multiple groups of text label pairs, and the text label pairs include text titles and style labels; The style classification model is trained using a text label dataset.
9. The method according to claim 6 or 7, It is characterized in that Before screening out a high-quality image and text dataset from the primary image and text dataset, the method further includes: Acquire a picture-text matching data set, the picture-text matching data set comprising a plurality of picture-text matching pairs, the picture-text matching pairs comprising an image and a text title, and the matching degree between the image and the text title in the picture-text matching pairs being greater than a second matching degree threshold; The image-text matching model is trained using the image-text matching dataset.
10. The method according to claim 1, It is characterized in that The clustering algorithm includes any one of a k-means clustering algorithm and a k-medoids clustering algorithm.
11. The method according to claim 1 or 2, It is characterized in that The target styles include one or more of the following: Tang poetry, Song lyrics, Yuan opera, vernacular Chinese, English, modern poetry and classical Chinese.
12. A training device, It is characterized in that The method comprises one or more processors and one or more memories; wherein the one or more memories are coupled to the one or more processors, and the one or more memories are used to store a computer program, and when the one or more processors execute the computer program, the method as described in any one of claims 1 to 11 is executed.
13. A computer-readable storage medium comprising instructions, It is characterized in that When the instructions are executed on a processor of a training device, the method according to any one of claims 1 to 11 is executed.
