Method, system and device for replacing image background and storage medium

By extracting the prospects of product images and combining them with new backgrounds generated based on description and random prompts, the problem that product image background images in the prior art is difficult to adapt to diversified market demands, and the flexibility and creativity of image processing are achieved to meet personalized needs.

CN119672174APending Publication Date: 2025-03-21中和农信农业集团有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411547252.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-01
Publication Date
2025-03-21

AI Technical Summary

Technical Problem

The background images of existing product images are difficult to adapt to diversified market demands, which leads to merchants needing to prepare multiple versions of product images, which increases costs and workload, and cannot meet the personalized needs of different users.

Method used

By obtaining product images and background image description words, extracting foreground images, randomly generate a link between prompt words and background image description words, generate a replacement background image, and synthesize the foreground image and the replacement background image into a new image, providing users with more personalized options.

Benefits of technology

It improves the flexibility and creativity of image processing, makes image editing more convenient and efficient, meets the personalized needs of different users, and reduces repeated work and waste of storage space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119672174A_ABST
    Figure CN119672174A_ABST
Patent Text Reader

Abstract

The invention discloses a method, a system and equipment for replacing an image background and a storage medium. The method comprises the following steps: acquiring a first image and a background image descriptor; extracting a foreground image from the first image; randomly generating a first cue word, and performing text connection according to the background image description word and the first cue word to obtain a background cue word; generating a replacement background image according to the background prompt word and the first image; and synthesizing the foreground image and the replacement background image into a second image. According to the method, by extracting the foreground of the original image and combining the foreground with the new background generated based on description and random prompt, the image with the background of the original image replaced is obtained, more personalized options can be provided for a user, the flexibility and creativity of image processing are improved, and image editing is more convenient and efficient.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to a method, system, device and storage medium for replacing an image background. Background Art

[0002] With the rapid expansion of e-commerce and digital marketing, product images have become an indispensable part of consumers' online shopping experience. Existing product background images often use fixed templates or scene settings, which are difficult to adapt to diverse market needs. In order to meet the different requirements of product images for different platforms or promotional activities, merchants need to prepare multiple versions of product images, resulting in a lot of duplication of work and waste of storage space.

[0003] The existing background image production process often requires professional photographers, venues, equipment and post-processing, which not only increases costs and has low production efficiency, but also fails to meet the personalized needs of different users. Summary of the invention

[0004] The following is a summary of the subject matter described in detail herein. This summary is not intended to limit the scope of the claims.

[0005] The main purpose of the embodiments of the present disclosure is to propose a method, system, device and storage medium for replacing image background, which can provide users with more personalized options, improve the flexibility and creativity of image processing, and make image editing more convenient and efficient.

[0006] A first aspect of an embodiment of the present application provides a method for replacing an image background, the method comprising:

[0007] Obtaining description words for the first image and the background image;

[0008] extracting a foreground image from the first image;

[0009] Randomly generate a first prompt word, and perform text connection based on the background image description word and the first prompt word to obtain a background prompt word;

[0010] Generate a replacement background image according to the background prompt word and the first image;

[0011] The foreground image and the replacement background image are combined into a second image.

[0012] The embodiment of the present application provides a method for replacing the background of an image, the method comprises obtaining a first image and a description word of the background image; extracting a foreground image from the first image; randomly generating a first prompt word, and performing textual connection based on the description word of the background image and the first prompt word to obtain a background prompt word; generating a replacement background image based on the background prompt word and the first image; and synthesizing the foreground image and the replacement background image into a second image. The method obtains an image after the background of the original image is replaced by extracting the foreground of the original image and combining it with a new background generated based on the description and random prompts, which can provide users with more personalized options, improve the flexibility and creativity of image processing, and make image editing more convenient and efficient.

[0013] In some embodiments of the present application, before extracting a foreground image from an image, the method includes:

[0014] Get the original image and background image size;

[0015] The original image is scaled according to the size of the background image to obtain the first image.

[0016] In some embodiments of the present application, extracting a foreground image from the first image includes:

[0017] Identifying a foreground area and a background area of ​​the first image using a preset semantic segmentation model, and generating a corresponding mask according to the background area;

[0018] The background area of ​​the first image is masked by the mask of the background area to obtain a foreground image of the first image.

[0019] In some embodiments of the present application, the randomly generating the first prompt word and performing textual connection according to the background image description word and the first prompt word to obtain the background prompt word includes:

[0020] According to the background image description word, randomly generate the first prompt word from a database;

[0021] Extracting text features from the background image description words;

[0022] According to the text features, the background image description word and the first prompt word are text-linked to obtain the background prompt word.

[0023] In some embodiments of the present application, generating a replacement background image according to the background prompt word and the first image includes:

[0024] Generate a first background image according to the background prompt word and the first image;

[0025] The first background image is input into an image processing model to obtain the replacement background image.

[0026] In some embodiments of the present application, synthesizing the foreground image and the replacement background image into a second image includes:

[0027] Performing image size alignment and color space conversion on the replacement background image according to the foreground image to obtain a processed replacement background image;

[0028] Extracting detail features from the foreground image;

[0029] Mapping the detail features to the processed replacement background image to obtain a second background image;

[0030] The foreground image and the second background image are combined into the second image.

[0031] A second aspect of an embodiment of the present invention provides a system for replacing an image background, the system comprising:

[0032] An acquisition module, used for acquiring description words of the first image and the background image;

[0033] An extraction module, used for extracting a foreground image from the first image;

[0034] A connection module, used for randomly generating a first prompt word, and performing text connection based on the background image description word and the first prompt word to obtain a background prompt word;

[0035] A generating module, used for generating a replacement background image according to the background prompt word and the first image;

[0036] A synthesis module is used to synthesize the foreground image and the replacement background image into a second image.

[0037] A third aspect of an embodiment of the present invention provides an electronic device, comprising: at least one control processor and a memory for communicating with the at least one control processor; the memory stores instructions that can be executed by the at least one control processor, and the instructions are executed by the at least one control processor so that the at least one control processor can execute the above-mentioned method of replacing an image background.

[0038] A fourth aspect of an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the above-mentioned method for replacing an image background.

[0039] A fifth aspect of an embodiment of the present invention provides a computer program product. When instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the above-mentioned method for replacing an image background.

[0040] It can be understood that the beneficial effects of the second to fifth aspects compared with the related art are the same as the beneficial effects of the first aspect compared with the related art. Please refer to the relevant description in the first aspect, and no further details will be given here. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:

[0042] Figure 1 It is a flowchart of a method for replacing an image background provided in an embodiment of the present application.

[0043] Figure 2 This is an application schematic diagram of an implementation method provided in an embodiment of the present application;

[0044] Figure 3 This is a schematic diagram of a process in an implementation method provided in an embodiment of the present application;

[0045] Figure 4 This is a schematic diagram of the effect of an implementation method provided in an embodiment of the present application;

[0046] Figure 5 is a structural schematic diagram of a system for replacing an image background provided in an embodiment of the present application;

[0047] Figure 6 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0048] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be understood as limiting the present application.

[0049] In the description of this application, if there is a description of first, second, etc., it is only for the purpose of distinguishing technical features, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.

[0050] In the description of the present application, it should be understood that the descriptions involving orientation, such as the orientation or positional relationship indicated as up, down, etc., are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present application.

[0051] In the description of this application, it should be noted that, unless otherwise clearly defined, terms such as setting, installing, connecting, etc. should be understood in a broad sense, and technicians in the relevant technical field can reasonably determine the specific meaning of the above terms in this application based on the specific content of the technical solution.

[0052] Existing image background maps are often shot using fixed templates or scenes, which are difficult to adapt to diverse market demands. The production process of replacing the background of an image not only involves a lot of repetitive work and waste of storage space, but also requires professional photographers, venues, equipment, and post-production manual processing, which increases costs, leads to low production efficiency and inability to meet the personalized needs of different users.

[0053] For this purpose, refer to Figure 1 The embodiment of the present application provides a method for replacing an image background. The method is applied to a controller. The controller may be a server, an electronic device, or a mobile terminal, etc., which is not specifically limited here. The method includes the following steps S110 to S150.

[0054] Step S110: Obtain description words for the first image and background image.

[0055] In this step, the first image after image processing and the background image description words used to describe the generation of a new background image are obtained. The image processing includes but is not limited to size processing and color processing of the original image. The background image description words can be a word describing a type or a paragraph of text describing a scene. The background image description words can be used to provide personalized background images generated for the background image description words, generate backgrounds of different styles, meet the needs of different image processing, and improve personalized experience.

[0056] In some embodiments, before obtaining the first image and the background image description words in step 110, the following steps are included:

[0057] Get the original image and background image size;

[0058] The original image is scaled according to the size of the background image to obtain a first image.

[0059] In this step, the size that the original image and the final image required by the method need to adapt to is obtained, and then the original image is scaled according to the size of the background image, and the size of the original image is adjusted to adapt to the given background size, wherein image scaling can be divided into two cases of enlargement and reduction, which are used to adjust the size of the original image while maintaining or optimizing the image quality and reducing image distortion or blur. Specifically, image scaling can be achieved through different interpolation algorithms (such as nearest neighbor interpolation, bilinear interpolation, Lanczos interpolation, etc.) to ensure the visual effect of the original image after the size is changed, such as avoiding image distortion, blurring and other problems, and finally obtaining the first image adjusted according to the size of the background image.

[0060] Specifically, the original image is not limited to the photos taken directly by the image processing device equipped with the image background replacement system, but also includes the photos taken by other external devices (such as webcams, portable cameras, etc.) and then imported or synchronized to the image processing device. Secondly, the original image may also come from a cloud storage platform and directly reach the image processing device for processing through network transmission. In addition, the original image may also be taken by an independent imaging device, such as a high-end digital SLR camera or a professional camera in different environments, and then uploaded to the image processing device through wireless transmission or data cable transmission.

[0061] Step S120: extracting a foreground image from the first image.

[0062] In this step, by performing image extraction on the preprocessed first image, a foreground image representing the foreground portion of the first image is obtained, wherein the preprocessing of the first image includes but is not limited to scaling the image according to the size of the background image, and also includes adjusting the brightness, contrast, etc. according to personalized needs to ensure that the image quality is suitable for subsequent processing, and then using image segmentation technology to distinguish between the foreground and background in the image, thereby extracting the image of the foreground portion.

[0063] In some embodiments, extracting a foreground image from the first image in step 120 includes the following steps:

[0064] Using a preset semantic segmentation model to identify a foreground area and a background area of ​​the first image, and generating a corresponding mask according to the background area;

[0065] The background area of ​​the first image is masked by a mask of the background area to obtain a foreground image of the first image.

[0066] In this embodiment, image analysis is performed on the acquired first image, and a semantic segmentation model is selected or trained, such as a deep learning model U-Net, to distinguish different object categories in the image. The foreground area and background area of ​​the first image are then analyzed using the determined semantic segmentation model, and then a binary mask (usually a black and white image) is generated based on the identified background area of ​​the first image, wherein the white portion represents the foreground area and the black portion represents the background area. The generated mask is then combined with the first image to block the background portion and retain only the foreground area, thereby finally obtaining a foreground image of the first image.

[0067] Step S130: randomly generate a first prompt word, and perform text connection based on the background image description word and the first prompt word to obtain a background prompt word.

[0068] In this step, a word is randomly selected from a series of preset words or phrases as an initial keyword, which is used to describe the specific characteristics of the background. It can be a word that describes elements such as natural landscapes, buildings, colors, atmosphere, etc. Then, the first prompt word randomly generated in the first step is combined with the background image description word to form a new descriptive phrase. It can be formed through natural connection in language, such as using a combination of adjectives and nouns, or by integrating the two through grammatical structure, and finally forming a descriptive background prompt word. Through the randomly generated first prompt word, the result generated each time will be different, which helps to improve the diversity and novelty of the replacement background image. Moreover, after combining with the specific background image description word, the generated background prompt word can more accurately express the scene characteristics that need to be depicted, making the description richer and more specific.

[0069] In some embodiments, in step 130, a first prompt word is randomly generated, and a text connection is performed based on the background image description word and the first prompt word to obtain a background prompt word, including the following steps:

[0070] According to the background image description words, randomly generate the first prompt word from the database;

[0071] Extract text features from the background image description words;

[0072] According to the text features, the background image description words and the first prompt words are textually linked to obtain the background prompt words.

[0073] In this embodiment, a first prompt word related to a given background image description word is randomly selected from a database containing multiple words or phrases, or the first prompt word related to the given background image description word is selected based on a certain association metric (such as similarity), and then the background image description word is analyzed to extract text features from the background image description word. Specifically, the text features can be the words themselves, the attributes of the words (such as color, shape, emotional color, etc.), or higher-level concepts (such as environmental atmosphere, scene type, etc.).

[0074] Furthermore, according to the extracted text features, the background image description words are linked to the first prompt words in text, specifically, multiple text data are linked and combined in a specific way to generate more complete semantic information, which can be a simple splicing combination or a more complex grammatical structure adjustment to ensure that the result sounds natural and smooth, and then form a new descriptive phrase, namely the background prompt word, to ensure that the generated prompt word has a high correlation with the background image description word, so as to better reflect the expected scene characteristics. Moreover, by randomly generating the first prompt word and combining it with the background image description word, a variety of background prompt words can be created to inspire more creative inspiration.

[0075] Step S140: Generate a replacement background image according to the background prompt words and the first image.

[0076] In this step, by generating background prompt words based on the randomly generated first prompt words, a first background image that matches the background prompt words is randomly generated to replace the background in the first image, which also includes image processing of the first background image, including but not limited to processing edges and details, so that the replaced background and foreground are more seamlessly combined.

[0077] In some embodiments, in step 140, generating a replacement background image according to the background prompt word and the first image includes the following steps:

[0078] Generate a first background image according to the background prompt word and the first image;

[0079] The first background image is input into the image processing model to obtain a replacement background image.

[0080] In this embodiment, a background image that meets the description in the background prompt words, i.e., a first background image, is generated through the description of the background prompt words, and then the first background image is input into the image processing model to obtain a replacement background image, which is used to replace the background in the first image, thereby obtaining an image after the background is replaced, thereby creating a scene that is completely different from the original background of the first image, providing more possibilities for creative expression.

[0081] Specifically, the image processing model can be a deep learning-based method (such as GANs, VAEs, etc.) or a traditional image processing technology (such as image synthesis), so as to better handle edges and details, improve the efficiency of background replacement, and reduce the workload of manual editing.

[0082] Step S150: synthesize the foreground image and the replacement background image into a second image.

[0083] In this step, a second image after replacing the background of the first image is generated by synthesizing a foreground image that only retains the foreground portion of the first image and a replacement background image randomly generated according to background prompt words.

[0084] In some embodiments, in step 150, the foreground image and the replacement background image are combined into a second image, including the following steps:

[0085] Perform image size alignment and color space conversion on the replacement background image according to the foreground image to obtain a processed replacement background image;

[0086] Extract detail features from the foreground image;

[0087] Mapping the detail features to the processed replacement background image to obtain a second background image;

[0088] The foreground image and the second background image are combined into a second image.

[0089] In this embodiment, a foreground image that only retains the foreground portion of the first image and a replacement background image randomly generated according to background prompt words are synthesized, and preferably the replacement background image is size aligned and color space converted according to the foreground image to obtain a processed replacement background image.

[0090] Specifically, image size alignment is to adjust the replacement background image to the same size as the foreground image to ensure that the two can be seamlessly combined, to ensure that the foreground image and the background image are not distorted or stretched when synthesized, and to ensure that the visual effect of the final image is natural. Color space conversion is to convert the color mode of the replacement background image into a mode consistent with the foreground image to avoid visual inconsistency caused by color mode mismatch. For example, the HSV color space is converted into the RGB color space to ensure the consistency of the foreground image and the background image in color and avoid the incoordination caused by different color modes.

[0091] Furthermore, key detail features, such as edge, texture, color distribution and other information, are extracted from the foreground image to adjust the replacement background image so that it is better integrated with the foreground image. Then, the detail features extracted from the foreground image are used to adjust the properties of the replacement background image, such as color, texture, etc., so that the characteristics of the replacement background image match the foreground image and are more harmonious and unified visually. Finally, the adjusted replacement background image is merged with the foreground image to generate a new image to obtain a second image. This not only improves the naturalness of image synthesis, but also may enhance the artistic effect or information communication ability of the final image by adjusting the details of the replacement background image.

[0092] like Figure 2 As shown, in one implementation of this embodiment, the product image background is directly replaced by a device loaded with a method for replacing the image background. Preferably, the device includes three modules: a front-end module, a back-end module, and a ComfyUI (Comfy User Interface) workflow module.

[0093] Specifically, the front-end module is responsible for collecting user input information and calling the interface of the back-end module, querying the generation queue and estimated time, and displaying the generation progress and results; the back-end module is responsible for processing generation requests, recording request information, and interacting with the business library and generation queue; the ComfyUI workflow module is responsible for executing the task of replacing the image background, processing the images and parameters uploaded by the user, generating the background image and returning the generation results. Through modular design, users are allowed to freely connect between different image processing nodes to achieve diversified image editing tasks.

[0094] Furthermore, the front-end module responsible for collecting user information and displaying the generated results includes: the user uploads the request information through the front-end module, including: the original image of the product, the description of the generated background image and the size of the background image, and then the front-end module calls the back-end interface to query the generation queue and display the estimated generation time. In addition, when the user initiates the generation request, the front-end will query the generation results regularly, and once the generation is completed, the final result will be displayed.

[0095] Furthermore, the backend module that provides generation request processing and data query functions includes receiving generation requests from the frontend and saving the request information to the business library. The backend module will query the current number of waiting in the generation queue and the number of images currently requested to be generated, calculate the estimated time required for generation based on different hardware conditions, and return it to the frontend module. The backend module is also responsible for placing requests into the generation queue and regularly querying the generation results of the ComfyUI workflow to ensure the smooth execution of the generation task.

[0096] Furthermore, the ComfyUI workflow module is responsible for processing the original product image uploaded by the user, applying the background image description words and size requirements, and generating a new product background image. After the generation is completed, the ComfyUI workflow module returns the result to the backend module, and finally the frontend module displays it to the user.

[0097] Finally, by applying a device equipped with a method for replacing image background in product images, the product image background can be quickly and randomly replaced, and a variety of personalized product image backgrounds can be generated. Moreover, due to the randomness of the replacement process, the generated background image is also random, thus ensuring the diversity of product images.

[0098] like Figure 3 As shown, in one implementation of this embodiment, user requirements are first obtained, including the background image size, the original image of the product, and the background image generation prompt words. Then, according to the background image size, the original image of the product is scaled to adapt to the size of the background image. At the same time, the background of the original image of the product is removed to leave the main body of the product.

[0099] Specifically, a simple k sampler is used to extract sample data from the processed product images for subsequent encoding and conditional application. VAE (Variational Autoencoder, VAE) encoding is used to encode product images and extract features. In addition, by applying ICLight conditions, the encoded features are combined with the ICLight conditions to optimize the performance of product images.

[0100] Furthermore, the processed product image node is output through the node bundle for use in the next step, and then the pre-trained ICLight model is loaded to process and optimize the product image. By adjusting the background image size and applying different ICLight conditions, synthetic images of various styles and sizes are generated according to specific needs.

[0101] Furthermore, simple image detail transfer ensures that the product details are retained by transferring the processed product image details to the background image, and finally generates the product background image after replacing the image background, completing the entire image processing flow. It can not only efficiently generate high-quality composite images, effectively improve the realism and aesthetics of the replaced image background, but also meet diverse design needs.

[0102] The specific process includes: the user uploads the original image of the product to be processed through the front-end page, inputs the description words of the background image to be generated, selects the size of the background image to be generated, and then standardizes the size of the original image of the product uploaded by the user through the image scaling node, and then uses the image background removal node to analyze the product image, intelligently identify and remove the background, and outputs an image and mask that only retains the foreground product, and then text-links the description words of the background image to be generated uploaded by the user with the preset prompt words, and according to the processed prompt words and product image, loads the image generation model through the simple loader, loads the ICLight model to load the image processing model, and sets the image processing parameters (for example: light direction, intensity, color, shadow) by applying ICLight conditions, and finally generates a new background image through VAE encoding.

[0103] Then the identified product image is synthesized with the generated background, and simple image detail transmission is used to ensure smooth transition of product edges and improve visual effects. Finally, the product image with replaced background is returned to the front end for users to download. In the whole process, the random number sequence is changed through the global random seed, thereby affecting each random decision point of image generation, ensuring the repeatability and consistency of the random process in the generation task.

[0104] like Figure 4 As shown, in one implementation of this embodiment, the user Figure 4 On the left page, upload the original image of the product to be processed, enter the description of the background image to be generated, select the size of the background image to be generated, and click Start Generation.

[0105] After receiving the user's start production click start generation instruction, call the ComfyUI process to start the task of replacing the image background. After the replacement is completed, the page will display as follows Figure 4 The newly generated product image is shown on the right. Users can click to download the image and save it.

[0106] In addition, users can also choose to regenerate a new image to replace the image background by re-uploading the original image of the product to be processed or changing the background image description or background image size, or users can directly choose to refresh the results. The device will call the ComfyUI process to re-randomly generate a replacement background image, and then generate different images with replaced image backgrounds for users to choose from, providing a variety of choices.

[0107] In this embodiment, by obtaining a first image and a description word of a background image; extracting a foreground image from the first image; randomly generating a first prompt word, and performing textual connection based on the description word of the background image and the first prompt word to obtain a background prompt word; generating a replacement background image based on the background prompt word and the first image; and synthesizing the foreground image and the replacement background image into a second image. This embodiment extracts the foreground of the original image and combines it with a new background generated based on the description and random prompts to obtain an image after the background of the original image is replaced, which can provide users with more personalized options, improve the flexibility and creativity of image processing, and make image editing more convenient and efficient.

[0108] like Figure 5 As shown, some embodiments of the present application provide a system for replacing image background, the system includes an acquisition module 501, an extraction module 502, a connection module 503, a generation module 504, and a synthesis module 505. Specifically:

[0109] The acquisition module 501 is used to acquire description words of the first image and the background image.

[0110] The extraction module 502 is used to extract a foreground image from the first image.

[0111] The connection module 503 is used to randomly generate a first prompt word, and perform text connection based on the background image description word and the first prompt word to obtain a background prompt word.

[0112] The generating module 504 is used to generate a replacement background image according to the background prompt words and the first image.

[0113] The synthesis module 505 is used to synthesize the foreground image and the replacement background image into a second image.

[0114] In one implementation, the extraction module 502 is further used to obtain the size of the original image and the background image.

[0115] In one implementation, the extraction module 502 is further configured to: scale the original image according to the size of the background image to obtain the first image.

[0116] In one embodiment, the extraction module 502 is further used to: identify the foreground area and the background area of ​​the first image using a preset semantic segmentation model, and generate a corresponding mask according to the background area.

[0117] In one implementation, the extraction module 502 is further configured to: mask the background area of ​​the first image by using a mask of the background area to obtain a foreground image of the first image.

[0118] In one embodiment, the linking module 503 is further used to randomly generate a first prompt word from a database according to the background image description word.

[0119] In one implementation, the linking module 503 is further used to extract text features from the background image description words.

[0120] In one embodiment, the linking module 503 is further used to: perform text linking on the background image description word and the first prompt word according to text features to obtain the background prompt word.

[0121] In one implementation, the generating module 504 is further configured to generate a first background image according to the background prompt words and the first image.

[0122] In one implementation, the generation module 504 is further configured to: input the first background image into an image processing model to obtain a replacement background image.

[0123] In one implementation, the synthesis module 505 is further configured to: perform image size alignment and color space conversion on the replacement background image according to the foreground image to obtain a processed replacement background image.

[0124] In one implementation, the synthesis module 505 is further configured to extract detail features from the foreground image.

[0125] In one implementation, the synthesis module 505 is further configured to: map the detail features to the processed replacement background image to obtain a second background image.

[0126] In one implementation, the synthesis module 505 is further configured to synthesize the foreground image and the second background image into a second image.

[0127] It should be noted that the image background replacement system provided in this embodiment and the above-mentioned image background replacement method are based on the same inventive concept, so the relevant content of the above-mentioned image background replacement method is also applicable to the content of the image background replacement system, so it will not be repeated here.

[0128] like Figure 6 The embodiment of the present application further provides an electronic device, the electronic device comprising:

[0129] At least one battery;

[0130] at least one memory;

[0131] at least one processor;

[0132] at least one program;

[0133] The programs are stored in the memory, and the processor executes at least one program to implement the above-mentioned method for replacing the image background in the present disclosure.

[0134] The electronic device may be any intelligent terminal including a mobile phone, a tablet computer, a personal digital assistant (PDA), a vehicle-mounted computer, etc.

[0135] The electronic device according to the embodiment of the present application is described in detail below.

[0136] The processor 1600 may be implemented by a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present disclosure;

[0137] The memory 1700 may be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1700 may store an operating system and other application programs. When the technical solution provided in the embodiments of this specification is implemented by software or firmware, the relevant program code is stored in the memory 1700, and the processor 1600 calls and executes a method for replacing an image background in the embodiments of the present disclosure.

[0138] Input / output interface 1800, used to implement information input and output;

[0139] The communication interface 1900 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WIFI, Bluetooth, etc.);

[0140] Bus 2000 , which transmits information between various components of the device (e.g., processor 1600 , memory 1700 , input / output interface 1800 , and communication interface 1900 );

[0141] The processor 1600 , the memory 1700 , the input / output interface 1800 , and the communication interface 1900 are connected to each other in communication within the device via the bus 2000 .

[0142] The embodiment of the present disclosure further provides a storage medium, which is a computer-readable storage medium. The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the above-mentioned method for replacing an image background.

[0143] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0144] The embodiment of the present disclosure also provides a computer program product. When instructions in the computer program product are executed by a processor of an electronic device, the electronic device is used to execute the above-mentioned method for replacing an image background.

[0145] The embodiments described in the embodiments of the present disclosure are intended to more clearly illustrate the technical solutions of the embodiments of the present disclosure and do not constitute a limitation on the technical solutions provided by the embodiments of the present disclosure. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of the present disclosure are also applicable to similar technical problems.

[0146] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present disclosure, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.

[0147] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0148] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0149] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0150] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0151] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components 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 units, which can be electrical, mechanical or other forms.

[0152] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0153] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0154] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable an electronic device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of each embodiment method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store programs.

[0155] The above is a specific description of the preferred implementation of the embodiments of the present application, but the embodiments of the present application are not limited to the above-mentioned implementation methods. Technical personnel familiar with the field can also make various equivalent modifications or substitutions without violating the spirit of the embodiments of the present application. These equivalent modifications or substitutions are all included in the scope defined by the claims of the embodiments of the present application.

[0156] The embodiments of the present application are described in detail above in conjunction with the accompanying drawings, but the present application is not limited to the above embodiments, and various changes can be made within the knowledge scope of ordinary technicians in the relevant technical field without departing from the purpose of the present application.

Claims

1. A method for replacing an image background, characterized in that: The method comprises: Obtaining description words for the first image and the background image; extracting a foreground image from the first image; Randomly generate a first prompt word, and perform text connection based on the background image description word and the first prompt word to obtain a background prompt word; Generate a replacement background image according to the background prompt word and the first image; The foreground image and the replacement background image are combined into a second image.

2. The method for replacing image background according to claim 1, characterized in that: Before extracting a foreground image from an image, the method comprises: Get the original image and background image size; The original image is scaled according to the size of the background image to obtain the first image.

3. The method for replacing image background according to claim 2, characterized in that: The step of extracting a foreground image from the first image comprises: Identifying a foreground area and a background area of ​​the first image using a preset semantic segmentation model, and generating a corresponding mask according to the background area; The background area of ​​the first image is masked by the mask of the background area to obtain a foreground image of the first image.

4. The method for replacing image background according to claim 2, characterized in that: The randomly generated first prompt word and the text connection between the background image description word and the first prompt word to obtain the background prompt word include: According to the background image description word, randomly generate the first prompt word from a database; Extracting text features from the background image description words; According to the text features, the background image description word and the first prompt word are text-linked to obtain the background prompt word.

5. The method for replacing image background according to claim 4, characterized in that: The step of generating a replacement background image according to the background prompt word and the first image includes: Generate a first background image according to the background prompt word and the first image; The first background image is input into an image processing model to obtain the replacement background image.

6. The method for replacing image background according to claim 5, characterized in that: The step of synthesizing the foreground image and the replacement background image into a second image comprises: Performing image size alignment and color space conversion on the replacement background image according to the foreground image to obtain a processed replacement background image; Extracting detail features from the foreground image; Mapping the detail features to the processed replacement background image to obtain a second background image; The foreground image and the second background image are combined into the second image.

7. A system for replacing image background, characterized in that: The system comprises: An acquisition module, used for acquiring description words of the first image and the background image; An extraction module, used for extracting a foreground image from the first image; A connection module, used for randomly generating a first prompt word, and performing text connection based on the background image description word and the first prompt word to obtain a background prompt word; A generating module, used for generating a replacement background image according to the background prompt word and the first image; A synthesis module is used to synthesize the foreground image and the replacement background image into a second image.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the method for replacing an image background according to any one of claims 1 to 6.

9. An electronic device, characterized in that: It includes at least one control processor and a memory for communicating with the at least one control processor; the memory stores instructions that can be executed by the at least one control processor, and the instructions are executed by the at least one control processor to enable the at least one control processor to execute a method for replacing an image background as described in any one of claims 1 to 6.

10. A computer program product, characterized in that When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes a method for replacing an image background as described in any one of claims 1 to 6.