Image screening method and system, storage medium and electronic equipment
By extracting text features and high-dimensional space features in the image generation model, calculating the image pixel score, and selecting the image with the largest image score, the problem of difficult image screening in the existing technology is solved, and the quality and intelligence of image generation are improved. .
Patent Information
- Application Number
- CN202410747147.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-11
- Publication Date
- 2024-09-10
AI Technical Summary
In the existing technology, after multiple images are generated through an image generation model, it is difficult to select the best quality image, which affects the quality of image generation.
By obtaining text hints used to describe the desired image, extract text features and high-dimensional space features, calculate the pixel score of each candidate image, and select the candidate image with the largest image score as the best generated image. Specific steps include extracting text features and high-dimensional space features based on the Transformer model, obtaining pixel feature values through the decoder, applying the softmax function to calculate the pixel score, and constructing a pixel score set, and finally selecting the image with the largest image score.
It effectively improves the quality of image generation, improves the degree of intelligence, and is extremely practical.
Smart Images

Figure CN118628610A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of deep learning, and in particular relates to an image screening method, system, storage medium and electronic device. Background Art
[0002] With the development of deep learning technology, image generation has become a research field that has attracted much attention. In the existing technology, image generation models are usually used to generate images, mainly including the following two methods:
[0003] (1) Given a fixed text prompt, use different image screening models (such as SD, midjourney, and Dalle) to obtain multiple images, and select one as the generated image;
[0004] (2) Fixed text prompt, use the same image to filter the model, generate multiple images, and select one as the generated image.
[0005] However, it is often difficult to select a picture with the best quality from multiple images, which in turn affects the quality of image generation. Summary of the invention
[0006] In view of the above-mentioned shortcomings of the prior art, an object of the present invention is to provide an image screening method, system, storage medium and electronic device, which select the best quality generated image based on text prompts, thereby effectively improving the quality of image generation.
[0007] In a first aspect, the present invention provides an image screening method, which comprises the following steps: obtaining a text prompt for describing a desired image; obtaining a plurality of candidate images generated based on the text prompt; extracting text features of the text prompt; passing the plurality of candidate images through a multi-layer perceptron to obtain high-dimensional space features; obtaining a set of pixel scores for each candidate image based on the text features and the high-dimensional space features; obtaining image scores for each candidate image based on the pixel score set; and selecting the candidate image with the largest image score as the best generated image corresponding to the text prompt.
[0008] In an implementation of the first aspect, an encoder based on a transformer model extracts text features of the text prompt.
[0009] In an implementation of the first aspect, obtaining a pixel score set for each candidate image based on the text feature and the high-dimensional space feature comprises the following steps:
[0010] Taking the text features as K vectors and V vectors, taking the high-dimensional space features as Q vectors, and obtaining feature values of each pixel in the candidate image through a decoder of a transformer model;
[0011] Pass the feature value through the softmax function to obtain the pixel score of each pixel;
[0012] A pixel score set of the candidate image is constructed based on the pixel scores.
[0013] In an implementation of the first aspect, obtaining an image score for each candidate image based on the pixel score set includes the following steps:
[0014] For each candidate image, calculate the product of the pixel scores of each pixel;
[0015] The product is used as the image score of the candidate image.
[0016] In a second aspect, the present invention provides an image screening system, the system comprising a first acquisition module, a second acquisition module, an extraction module, a third acquisition module, a fourth acquisition module, a fifth acquisition module and a selection module;
[0017] The first acquisition module is used to acquire a text prompt for describing the required image;
[0018] The second acquisition module is used to acquire multiple candidate images generated based on the text prompt;
[0019] The extraction module is used to extract text features of the text prompt;
[0020] The third acquisition module is used to pass the multiple candidate images through a multi-layer perceptron to obtain high-dimensional spatial features;
[0021] The fourth acquisition module is used to acquire a pixel score set of each candidate image based on the text feature and the high-dimensional space feature;
[0022] The fifth acquisition module is used to acquire the image score of each candidate image based on the pixel score set;
[0023] The selection module is used to select the candidate image with the largest image score as the best generated image corresponding to the text prompt.
[0024] In an implementation of the second aspect, the extraction module extracts text features of the text prompt based on an encoder of a transformer model.
[0025] In an implementation of the second aspect, the fourth acquisition module acquires a pixel score set of each candidate image based on the text feature and the high-dimensional space feature, comprising the following steps:
[0026] Taking the text features as K vectors and V vectors, taking the high-dimensional space features as Q vectors, and obtaining feature values of each pixel in the candidate image through a decoder of a transformer model;
[0027] Pass the feature value through the softmax function to obtain the pixel score of each pixel;
[0028] A pixel score set of the candidate image is constructed based on the pixel scores.
[0029] In an implementation of the second aspect, the fifth acquisition module acquires the image score of each candidate image based on the pixel score set, comprising the following steps:
[0030] For each candidate image, calculate the product of the pixel scores of each pixel;
[0031] The product is used as the image score of the candidate image.
[0032] In a third aspect, the present invention provides an electronic device, the electronic device comprising: a processor and a memory;
[0033] The memory is used to store computer programs;
[0034] The processor is used to execute the computer program stored in the memory so that the electronic device performs the above-mentioned image screening method.
[0035] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which implements the above-mentioned image screening method when executed by an electronic device.
[0036] As described above, the image screening method, system, storage medium and electronic device of the present invention have the following beneficial effects:
[0037] (1) The best quality generated image is selected based on text prompts, which effectively improves the quality of image generation;
[0038] (2) Highly intelligent and extremely practical. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 Shown is a schematic diagram of a scene of an electronic device in an embodiment of the present invention;
[0040] Figure 2 Shown is a flow chart of an image screening method of the present invention in one embodiment;
[0041] Figure 3 It is a schematic diagram showing the structure of an image screening method of the present invention in one embodiment;
[0042] Figure 4 Shown is a schematic diagram of the structure of an image screening system of the present invention in one embodiment;
[0043] Figure 5 It is a schematic structural diagram of an electronic device of the present invention in one embodiment. DETAILED DESCRIPTION
[0044] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0045] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0046] The following embodiments of the present invention provide image screening methods, which can be applied to Figure 1 The electronic device shown. The electronic device described in the present invention may include a mobile phone 11 with a wireless charging function, a tablet computer 12, a laptop computer 13, a wearable device, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc. The embodiment of the present invention does not impose any restrictions on the specific type of the electronic device.
[0047] For example, the electronic device may be a station (STAION, ST) in a WLAN with a wireless charging function, a cellular phone, a cordless phone, a Session Initiation Protocol (SIP) phone, a Wireless Local Loop (WLL) station, a Personal Digital Assistant (PDA) device, a handheld device with a wireless charging function, a computing device or other processing device, a computer, a laptop computer, a handheld communication device, a handheld computing device, and / or other devices for communicating on a wireless system and a next generation communication system, such as a mobile terminal in a 5G network, a mobile terminal in a future evolved Public Land Mobile Network (PLMN), or a mobile terminal in a future evolved Non-terrestrial Network (NTN).
[0048] For example, the electronic device can communicate with the network and other devices through wireless communication. The above wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobilecommunication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), BT, GNSS, WLAN, NFC, FM, and / or IR technology. The GNSS can include Global Positioning System (GPS), Global Navigation Satellite System (GLONASS), BeiDou navigation Satellite System (BDS), Quasi-Zenith Satellite System (QZSS) and / or Satellite Based Augmentation Systems (SBAS).
[0049] The technical solutions in the embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0050] like Figure 2 and Figure 3 As shown, in one embodiment, the image screening method of the present invention includes steps S1 to S7.
[0051] Step S1: Obtain a text prompt for describing a desired image.
[0052] Specifically, when generating an image based on the image generation model, the text prompt is input into the image generation model to generate an image that matches the text prompt, wherein the text prompt can describe the characteristics of the desired image in terms of color, content, etc.
[0053] Step S2: Acquire multiple candidate images generated based on the text prompt.
[0054] Specifically, the text prompt is input into one or more image generation models, and the images obtained by the image generation models are used as candidate images. It is necessary to screen out the best generated image corresponding to the text prompt based on the multiple candidate images.
[0055] Step S3: extracting text features of the text prompt.
[0056] Specifically, an encoder based on a transformer model extracts text features of the text prompt. Transformer is a deep learning model architecture used for natural language processing (NLP) and other sequence-to-sequence tasks. The transformer model consists of two parts: an encoder and a decoder. Both the encoder and the decoder contain 6 blocks.
[0057] Step S4: Pass the multiple candidate images through a multi-layer perceptron to obtain high-dimensional spatial features.
[0058] Specifically, the plurality of candidate images are first reshaped into a vector pattern, which is represented as (height x width, number of channels). The number of channels is the number of candidate images. The candidate images in the vector pattern are input into a multilayer perceptron (MLP), so as to map the pixel space to a high-dimensional space and obtain the high-dimensional space feature. The shape of the high-dimensional space feature is (height x width, embedding dimension), and height x width = number of pixels.
[0059] Among them, the multilayer perceptron is a deep learning model based on a feedforward neural network, which consists of multiple neuron layers, each of which is fully connected to the previous layer. The multilayer perceptron can be used to solve various machine learning problems such as classification, regression, and clustering. Each neuron layer of the multilayer perceptron is composed of many neurons, where the input layer receives input features, the output layer gives the final prediction results, and the hidden layer in the middle is used to extract features and perform nonlinear transformations. Each neuron receives the output of the previous layer, performs weighted sum and activation function operations, and obtains the output of the current layer. Through continuous iterative training, the multilayer perceptron can automatically learn the complex relationship between input features and predict new data.
[0060] Step S5: acquiring a pixel score set of each candidate image based on the text feature and the high-dimensional space feature.
[0061] Specifically, obtaining a pixel score set of each candidate image based on the text feature and the high-dimensional space feature includes the following steps:
[0062] 51) For each candidate image, the text feature is used as a K vector and a V vector, and the high-dimensional space feature is used as a Q vector, and the feature value of each pixel in the candidate image is obtained through the decoder of the transformer model.
[0063] 52) The feature value is passed through a softmax function to obtain a pixel score for each pixel.
[0064] 53) Constructing a pixel score set of the candidate image based on the pixel scores.
[0065] Step S6: Obtain image scores for each candidate image based on the pixel score set.
[0066] Specifically, for each candidate image, the pixel scores of each pixel are multiplied to obtain the product of the pixel scores of each pixel, and the product is used as the image score of the candidate image.
[0067] Step S7: Select the candidate image with the largest image score as the best generated image corresponding to the text prompt.
[0068] The protection scope of the image screening method described in the embodiment of the present invention is not limited to the execution order of the steps listed in this embodiment. All solutions implemented by adding, reducing or replacing steps in the prior art based on the principles of the present invention are included in the protection scope of the present invention.
[0069] An embodiment of the present invention also provides an image screening system, which can implement the image screening method described in the present invention. However, the implementation device of the image screening system described in the present invention includes but is not limited to the structure of the image screening system listed in this embodiment. All structural deformations and replacements of the prior art made according to the principles of the present invention are included in the protection scope of the present invention.
[0070] like Figure 4 As shown, in one embodiment, the image screening system of the present invention includes a first acquisition module 41, a second acquisition module 42, an extraction module 43, a third acquisition module 44, a fourth acquisition module 45, a fifth acquisition module 46 and a selection module 47.
[0071] The first acquisition module 41 is used to acquire a text prompt for describing a desired image.
[0072] The second acquisition module 42 is used to acquire a plurality of candidate images generated based on the text prompt.
[0073] The extraction module 43 is connected to the first acquisition module 41 and is used to extract text features of the text prompt.
[0074] The third acquisition module 44 is connected to the second acquisition module 42, and is used to pass the multiple candidate images through a multi-layer perceptron to obtain high-dimensional spatial features.
[0075] The fourth acquisition module 45 is connected to the extraction module 43 and the third acquisition module 44, and is used to acquire a pixel score set of each candidate image based on the text feature and the high-dimensional space feature.
[0076] The fifth acquisition module 46 is connected to the fourth acquisition module 45, and is used to acquire the image score of each candidate image based on the pixel score set.
[0077] The selection module 47 is connected to the fifth acquisition module 46 and is used to select the candidate image with the largest image score as the best generated image corresponding to the text prompt.
[0078] Among them, the structures and principles of the first acquisition module 41, the second acquisition module 42, the extraction module 43, the third acquisition module 44, the fourth acquisition module 45, the fifth acquisition module 46 and the selection module 47 correspond one by one to the steps in the above-mentioned image screening method, so they are not repeated here.
[0079] In the several embodiments provided by the present invention, it should be understood that the disclosed system, device or method can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules / units is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules or units can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules or units, which can be electrical, mechanical or other forms.
[0080] The modules / units described as separate components may or may not be physically separated, and the components displayed as modules / units may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules / units may be selected according to actual needs to achieve the purpose of the embodiments of the present invention. For example, the functional modules / units in the various embodiments of the present invention may be integrated into one processing module, or each module / unit may exist physically separately, or two or more modules / units may be integrated into one module / unit.
[0081] Those of ordinary skill in the art should further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0082] The embodiment of the present invention also provides a computer-readable storage medium. A person of ordinary skill in the art can understand that all or part of the steps in the method for implementing the above embodiment can be completed by instructing the processor through a program, and the program can be stored in a computer-readable storage medium, and the storage medium is a non-transitory medium, such as a random access memory, a read-only memory, a flash memory, a hard disk, a solid-state hard disk, a magnetic tape, a floppy disk, an optical disc, and any combination thereof. The above storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a digital video disc (DVD)), or a semiconductor medium (e.g., a solid-state disk (SSD)), etc.
[0083] An embodiment of the present invention further provides an electronic device, which includes a processor and a memory.
[0084] The memory is used to store computer programs.
[0085] The memory includes: ROM, RAM, disk, USB flash drive, memory card or CD and other media that can store program codes.
[0086] The processor is connected to the memory and is used to execute the computer program stored in the memory so that the electronic device executes the above-mentioned image screening method.
[0087] Preferably, the processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0088] like Figure 5As shown, the electronic device of the present invention is in the form of a general computing device. The components of the electronic device may include but are not limited to: one or more processors or processing units 51, a memory 52, and a bus 53 connecting different system components (including the memory 52 and the processing unit 51).
[0089] Bus 53 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnect (PCI) bus.
[0090] Electronic devices typically include a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device, including volatile and non-volatile media, removable and non-removable media.
[0091] The memory 52 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 521 and / or cache memory 522. The electronic device may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 523 may be used to read and write non-removable, non-volatile magnetic media ( Figure 5 not shown, usually called a "hard drive"). Although Figure 5 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 53 via one or more data medium interfaces. The memory 52 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.
[0092] A program / utility 524 having a set (at least one) of program modules 5241 may be stored, for example, in the memory 52, such program modules 5241 including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which or some combination thereof may include an implementation of a network environment. The program modules 5241 generally perform the functions and / or methods of the embodiments described herein.
[0093] The electronic device may also communicate with one or more external devices (e.g., keyboards, pointing devices, displays, etc.), one or more devices that enable a user to interact with the electronic device, and / or any device that enables the electronic device to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed via input / output (I / O) interface 54. Furthermore, the electronic device may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via network adapter 55. Figure 5 As shown, the network adapter 55 communicates with other modules of the electronic device via the bus 53. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the electronic device, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0094] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by a person of ordinary skill in the art without departing from the spirit and technical concept disclosed by the present invention shall still be covered by the claims of the present invention.
Claims
1. An image screening method, characterized in that: The method comprises the following steps: Get a text hint describing the desired image; Acquire multiple candidate images generated based on the text prompt; Extracting text features of the text prompt; Passing the multiple candidate images through a multi-layer perceptron to obtain high-dimensional spatial features; Obtaining a pixel score set for each candidate image based on the text feature and the high-dimensional space feature; Obtaining an image score for each candidate image based on the pixel score set; The candidate image with the largest image score is selected as the best generated image corresponding to the text prompt.
2. The image screening method according to claim 1, characterized in that: The transformer-based encoder extracts text features of the text prompt.
3. The image screening method according to claim 1, characterized in that: Acquiring a pixel score set of each candidate image based on the text feature and the high-dimensional space feature comprises the following steps: Taking the text features as K vectors and V vectors, taking the high-dimensional space features as Q vectors, and obtaining feature values of each pixel in the candidate image through a decoder of a transformer model; Pass the feature value through the softmax function to obtain the pixel score of each pixel; A pixel score set of the candidate image is constructed based on the pixel scores.
4. The image screening method according to claim 1, characterized in that: Obtaining the image score of each candidate image based on the pixel score set comprises the following steps: For each candidate image, calculate the product of the pixel scores of each pixel; The product is used as the image score of the candidate image.
5. An image screening system, characterized in that: The system comprises a first acquisition module, a second acquisition module, an extraction module, a third acquisition module, a fourth acquisition module, a fifth acquisition module and a selection module; The first acquisition module is used to acquire a text prompt for describing the required image; The second acquisition module is used to acquire multiple candidate images generated based on the text prompt; The extraction module is used to extract text features of the text prompt; The third acquisition module is used to pass the multiple candidate images through a multi-layer perceptron to obtain high-dimensional spatial features; The fourth acquisition module is used to acquire a pixel score set of each candidate image based on the text feature and the high-dimensional space feature; The fifth acquisition module is used to acquire the image score of each candidate image based on the pixel score set; The selection module is used to select the candidate image with the largest image score as the best generated image corresponding to the text prompt.
6. The image screening system according to claim 5, characterized in that: The extraction module extracts text features of the text prompt based on an encoder of a transformer model.
7. The image screening system according to claim 5, characterized in that: The fourth acquisition module acquires a pixel score set of each candidate image based on the text feature and the high-dimensional space feature, comprising the following steps: Taking the text features as K vectors and V vectors, taking the high-dimensional space features as Q vectors, and obtaining feature values of each pixel in the candidate image through a decoder of a transformer model; Pass the feature value through the softmax function to obtain the pixel score of each pixel; A pixel score set of the candidate image is constructed based on the pixel scores.
8. The image screening system according to claim 5, characterized in that: The fifth acquisition module acquires the image score of each candidate image based on the pixel score set, comprising the following steps: For each candidate image, calculate the product of the pixel scores of each pixel; The product is used as the image score of the candidate image.
9. An electronic device, characterized in that: The electronic device comprises: a processor and a memory; The memory is used to store computer programs; The processor is configured to execute the computer program stored in the memory so as to enable the electronic device to perform the image screening method according to any one of claims 1 to 4.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by an electronic device, the image screening method according to any one of claims 1 to 4 is implemented.
