Movatterモバイル変換


[0]ホーム

URL:


CN120070663A - Commodity graph background changing method, device, equipment and medium based on Lora model training - Google Patents

Commodity graph background changing method, device, equipment and medium based on Lora model training
Download PDF

Info

Publication number
CN120070663A
CN120070663ACN202510108338.7ACN202510108338ACN120070663ACN 120070663 ACN120070663 ACN 120070663ACN 202510108338 ACN202510108338 ACN 202510108338ACN 120070663 ACN120070663 ACN 120070663A
Authority
CN
China
Prior art keywords
image
background
product
model
lora
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202510108338.7A
Other languages
Chinese (zh)
Inventor
刘志海
黄建谊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujian Zixun Information Technology Co ltd
Original Assignee
Fujian Zixun Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujian Zixun Information Technology Co ltdfiledCriticalFujian Zixun Information Technology Co ltd
Priority to CN202510108338.7ApriorityCriticalpatent/CN120070663A/en
Publication of CN120070663ApublicationCriticalpatent/CN120070663A/en
Pendinglegal-statusCriticalCurrent

Links

Classifications

Landscapes

Abstract

The invention provides a commodity image background replacing method, device, equipment and medium based on Lora model training, which comprises the steps of obtaining first commodity images of various commodities to obtain training data, labeling each first commodity image to form a corresponding label file, setting the number of training rounds, learning rate and training image pixels, inputting the training data and the label file to perform model training to obtain a required background Lora model, carrying out matting on a second commodity image needing background replacement to obtain a commodity main mask, extracting edge information of the second commodity image, loading the background Lora model in a graph generation algorithm, inputting the edge information, a background prompt word and the commodity main mask into the graph generation algorithm to generate a commodity replacement image, wherein the background prompt word corresponds to a background label with a set format, so that the drawing efficiency is improved, and the drawing cost is reduced.

Description

Commodity graph background changing method, device, equipment and medium based on Lora model training
Technical Field
The invention relates to the technical field, in particular to a commodity graph background changing method, device, equipment and medium based on Lora model training.
Background
In the electronic commerce industry, the production of commodity images mainly relies on professional photographic team shooting or a designer uses Photoshop for background synthesis, which is manually edited. The traditional methods have the remarkable defects of long manufacturing period, lack of timeliness and difficulty in rapidly adapting to market change, meanwhile, the cost is high due to excessive dependence on manual operation, the efficiency is low, the achievement is limited by personal skill level, the efficiency and the quality are unstable, and therefore the new operation progress of a product and a store is influenced.
Disclosure of Invention
The invention aims to solve the technical problem of providing a commodity graph background changing method, device, equipment and medium based on Lora model training, which improves the drawing efficiency and reduces the drawing cost.
In a first aspect, the invention provides a commodity graph background-changing method based on Lora model training, which comprises the following steps:
Step 1, acquiring a first commodity image of various commodities, wherein the first commodity image is a picture with a set shooting angle, and comprises a plurality of pictures of the same commodity in different proportions in the picture, so as to obtain training data;
Step 2, labeling each first commodity graph through a multi-mode model according to a background label with a set format to form a corresponding label file;
step 3, setting the training round number, the learning rate and the training image pixels, inputting training data and a label file, and performing model training to obtain a required background Lora model;
Step 4, carrying out image matting on a second commodity image with a background to be replaced to obtain a commodity main body mask;
And 5, loading the background Lora model in a graphic algorithm, inputting the edge information, the background prompt words and the commodity main body mask into the graphic algorithm, and generating a commodity replacement map, wherein the background prompt words correspond to the background labels with the set formats.
In a second aspect, the present invention provides a commodity graph background-changing device based on Lora model training, including:
The system comprises a training data acquisition module, a data acquisition module and a data processing module, wherein the training data acquisition module acquires first commodity diagrams of various commodities, the first commodity diagrams are pictures with preset shooting angles, and the first commodity diagrams comprise a plurality of pictures of the same commodity in different proportions in the pictures, so that training data are obtained;
a label module is arranged, and each first commodity image is labeled through a multi-mode model according to a background label with a set format to form a corresponding label file;
The training model module is used for setting the training round number, the learning rate and training image pixels, inputting training data and a label file, and performing model training to obtain a required background Lora model;
The image acquisition module is used for carrying out image matting on a second commodity image with a background to be replaced, and acquiring a commodity main body mask;
and the picture generation module loads the background Lora model in a picture generation algorithm, inputs the edge information, the background prompt words and the commodity main body mask into the picture generation algorithm, and generates a commodity replacement picture, wherein the background prompt words correspond to the background labels with the set formats.
In a third aspect, the invention provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the method of the first aspect when executing the program.
In a fourth aspect, the present invention provides a computer readable storage medium having stored thereon a computer program which when executed by a processor implements the method of the first aspect.
The one or more technical schemes provided by the invention have at least the following technical effects or advantages:
The invention successfully solves the background changing requirement of commodity graphs of commodity sellers, sellers can generate exquisite commodity graphs only by simply shooting themselves, greatly improves the efficiency of manufacturing commodity graphs, reduces the operation cost of sellers, and does not need to use professional shooting teams, cushion graph editing of art designing and the like;
the light and shadow optimization method can greatly improve commodity synthesis efficiency, can effectively solve the problem of light and shadow deficiency which easily occurs in the traditional light and shadow synthesis algorithm, and enables the generated commodity graph to have higher authenticity, fusion effect and illumination effect.
The foregoing description is only an overview of the present invention, and is intended to be implemented in accordance with the teachings of the present invention in order that the same may be more clearly understood and to make the same and other objects, features and advantages of the present invention more readily apparent.
Drawings
The invention will be further described with reference to examples of embodiments with reference to the accompanying drawings.
FIG. 1 is a flow chart of a method according to a first embodiment of the invention;
fig. 2 is a schematic structural diagram of a device in a second embodiment of the present invention.
Detailed Description
The technical scheme in the embodiment of the application has the following overall thought:
(1) The data preprocessing needs various commodity graphs, wherein various angles of upward shooting, horizontal shooting and downward shooting are needed to be included, various backgrounds are needed to be included, commodities with different size proportions, namely, commodity partial areas occupy the proportion of the whole picture, double-cube sharpening interpolation scaling (shrinking or enlarging) is carried out on the commodity graphs, all images are scaled to 1024 x 1024, definition optimization and the like, and the step needs to screen various commodity graphs, including various different backgrounds.
(2) And (3) marking data, and carrying out detailed structural description on the processed commodity graph main body and the background, wherein the formats comprise shooting angles, background element details, commodity main body colors and commodity main body names, and the formatted marking can greatly improve the effect of the prompt words in the use of the Lora model.
(3) And constructing a data set, and corresponding the text labels to the commodity images one by one.
(4) Model training, namely training a Lora model by using a Lora training script, setting model training parameters before the model, setting and adjusting the model training parameters, setting the total training wheel number to 15000, setting the learning rate to 0.0001, setting the training image size to 1024, and running the script to start model training by one key.
(5) Loading the trained commodity graph Lora in a graph generation algorithm, setting the loading weight of the Lora to 0.75, calling a canny algorithm, and adjusting the weight parameter weight to 0.9, wherein the main purpose of the parameter is to control the influence intensity of the canny algorithm on edge information extraction. And transmitting the mask image and the prompt word with the scene and the illumination description into the icon together for mask redrawing to obtain the commodity replacement diagram.
(6) The commodity replacement diagram is transferred into Ic-light to carry out illumination optimization of an image by using a prompt word again, or a back-removed diagram and a background diagram in the commodity replacement diagram are obtained, the back-removed diagram is enhanced through Gamma transformation, the brightness of a commodity main body in the back-removed diagram is improved by a first set value to obtain an enhanced diagram, the background diagram is mapped to an HSV space, a V space in the HSV space is reduced by a second set value and then mapped back to an RGB space to obtain a background darkening diagram, the enhanced diagram and the background darkening diagram are synthesized to obtain a first synthesized diagram, first latent information is extracted from the first synthesized diagram through VAE decoding, the back-removed diagram and the background diagram are synthesized to obtain a second synthesized diagram, a ControlNet model is adopted to extract first set information from the second synthesized diagram, the first latent information and the first set information are sent to a diffusion model to generate a first shadow guiding diagram, second lantent information is extracted from the first shadow guiding diagram, the second lantent information and the first set information are sent to a diffusion model to generate a second shadow guiding diagram, and the second shadow guiding diagram is reserved on the first shadow guiding diagram through a high shadow guiding algorithm, and then the commodity migration algorithm is obtained by adopting the intermediate shadow guiding diagram.
Model training, namely the training process of the Lora model, lora is a model fine tuning technology, and the quantity of parameters required for fine tuning is reduced by inserting a low-rank matrix into a pre-trained large model, so that the training efficiency is improved and overfitting is avoided. In the application scene of the commodity image, the Lora training is used for generating or optimizing the commodity image of the electronic commerce, so that the commodity image can be better adapted to a specific background.
And (3) extracting a mask image of the commodity image to be replaced to be used as a mask of the primitive image, so as to ensure that the commodity main body is unchanged during redrawing.
The Canny algorithm is an image processing technology, is mainly used for edge detection, namely, identifying edges in images, and can extract clear and accurate edge information from the images. And combining img2img pictorial drawings to limit the commodity body edge and ensure the consistency of commodity body edge information after background replacement and the commodity diagram edge to be replaced.
Ic-light can control the illumination of the image through the prompt words, so that the illumination of the foreground main body is consistent with that of the background environment, and the foreground main body and the background environment are integrated, and the illumination of the image is affected by properly giving the illumination prompt words by using the prompt words, so that the fusion effect of the commodity main body and the background is improved.
Example 1
As shown in fig. 1, the embodiment provides a commodity graph background-changing method based on the Lora model training, which comprises the following steps:
Step 1, acquiring a first commodity image of various commodities, wherein the first commodity image is a picture with a set shooting angle, and comprises a plurality of pictures of the same commodity in different proportions in the picture, so as to obtain training data;
Step 2, labeling each first commodity graph through a multi-mode model according to a background label with a set format to form a corresponding label file;
step 3, setting the training round number, the learning rate and the training image pixels, inputting training data and a label file, and performing model training to obtain a required background Lora model;
Step 4, carrying out image matting on a second commodity image with a background to be replaced to obtain a commodity main body mask;
And 5, loading the background Lora model in a graphic algorithm, inputting the edge information, the background prompt words and the commodity main body mask into the graphic algorithm, and generating a commodity replacement map, wherein the background prompt words correspond to the background labels with the set formats.
In this embodiment, preferably, the method further includes step 6 of obtaining a back-removed image and a background image in the commodity replacement image, where the back-removed image is an image of a commodity main body portion remaining after the background is deleted in the commodity replacement image, enhancing the back-removed image by Gamma conversion, increasing brightness of the commodity main body in the back-removed image by a first set value to obtain an enhanced image, mapping the background image to HSV space, reducing V space in HSV space by a second set value, then mapping the V space back to RGB space to obtain a background darkened image, synthesizing the enhanced image and the background darkened image to obtain a first synthesized image, extracting first latent information from the first synthesized image by VAE decoding, synthesizing the back-removed image and the background image to obtain a second synthesized image, extracting first setting information from the second synthesized image by using a control net model, transmitting the first 383256 information and the first setting information to a diffusion model to generate a first shadow guide image, extracting second lantent information from the first shadow guide image, transmitting the second lantent information and the first setting information to the diffusion model to generate a second shadow guide image, and then optimizing the second shadow guide image by using a contrast algorithm to obtain an intermediate image, and obtaining the intermediate image.
In the embodiment, the step 1 specifically includes obtaining a first commodity image of each commodity, where the first commodity image is a picture with a set shooting angle, and the first commodity image includes a plurality of pictures of the same commodity in different proportions in the picture, and scaling all the first commodity images so that the size of each first commodity image is 1024 x 1024, and obtaining training data.
In the embodiment, the step 4 specifically includes that a second commodity image with a background to be replaced is scratched to obtain a commodity main mask, and a canny algorithm is called to extract edge information of the second commodity image, wherein the weight parameter weight of the canny algorithm is 0.9;
The step 5 specifically includes loading the background Lora model in a graphic algorithm, setting the loading weight of the background Lora model to be 0.75, inputting the edge information, the background prompt word and the commodity main mask into the graphic algorithm, and generating a commodity replacement map, wherein the background prompt word corresponds to the background label with the set format.
Based on the same inventive concept, the application also provides a device corresponding to the method in the first embodiment, and the details of the second embodiment are shown.
Example two
As shown in fig. 2, in this embodiment, a commodity graph background replacing device based on the Lora model training is provided, including:
The system comprises a training data acquisition module, a data acquisition module and a data processing module, wherein the training data acquisition module acquires first commodity diagrams of various commodities, the first commodity diagrams are pictures with preset shooting angles, and the first commodity diagrams comprise a plurality of pictures of the same commodity in different proportions in the pictures, so that training data are obtained;
a label module is arranged, and each first commodity image is labeled through a multi-mode model according to a background label with a set format to form a corresponding label file;
The training model module is used for setting the training round number, the learning rate and training image pixels, inputting training data and a label file, and performing model training to obtain a required background Lora model;
The image acquisition module is used for carrying out image matting on a second commodity image with a background to be replaced, and acquiring a commodity main body mask;
and the picture generation module loads the background Lora model in a picture generation algorithm, inputs the edge information, the background prompt words and the commodity main body mask into the picture generation algorithm, and generates a commodity replacement picture, wherein the background prompt words correspond to the background labels with the set formats.
In this embodiment, preferably, the method further includes an optimizing light and shadow module, obtaining a back-removed image and a background image in the commodity replacement image, wherein the back-removed image is a picture of a commodity main body part remaining after a background is deleted in the commodity replacement image, enhancing the back-removed image through Gamma transformation, improving brightness of the commodity main body in the back-removed image by a first set value to obtain an enhanced image, mapping the background image to an HSV space, reducing a second set value in the V space, then mapping the V space back to the RGB space to obtain a background darkening image, synthesizing the enhanced image and the background darkening image to obtain a first synthesized image, extracting first latent information from the first synthesized image through VAE decoding, synthesizing the back-removed image and the background image to obtain a second synthesized image, extracting first set information from the second synthesized image by a control net model, transmitting the first latent information and the first set information to a diffusion model to generate a first light and shadow guiding image, extracting second lantent information from the first light and shadow guiding image, transmitting the second lantent information and the first set information to the diffusion model to generate a high-contrast algorithm guiding image, and obtaining intermediate image migration algorithm by the second image.
In this embodiment, the training data acquisition module is preferably configured to acquire a first commodity image of each commodity, where the first commodity image is a picture with a set shooting angle, and the first commodity image includes a plurality of pictures of the same commodity in different proportions in the picture, and scale all the first commodity images so that the size of each first commodity image is 1024 x 1024, to obtain training data.
In the embodiment, the picture acquisition module specifically performs matting on a second commodity image with a background to be replaced to acquire a commodity main body mask thereof, calls a canny algorithm to extract edge information of the second commodity image, and the weighting parameter weight of the canny algorithm is 0.9;
The image generation module specifically loads the background Lora model in an image generation algorithm, the loading weight of the background Lora model is set to be 0.75, the edge information, the background prompt word and the commodity main body mask are input into the image generation algorithm, and a commodity replacement image is generated, wherein the background prompt word corresponds to the background label with the set format.
Since the device described in the second embodiment of the present invention is a device for implementing the method described in the first embodiment of the present invention, based on the method described in the first embodiment of the present invention, a person skilled in the art can understand the specific structure and the deformation of the device, and thus the detailed description thereof is omitted herein. All devices used in the method according to the first embodiment of the present invention are within the scope of the present invention.
Based on the same inventive concept, the application provides an electronic device embodiment corresponding to the first embodiment, and the details of the third embodiment are shown in the specification.
Example III
The present embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where any implementation of the first embodiment may be implemented when the processor executes the computer program.
Since the electronic device described in this embodiment is a device for implementing the method in the first embodiment of the present application, those skilled in the art will be able to understand the specific implementation of the electronic device and various modifications thereof based on the method described in the first embodiment of the present application, so how the electronic device implements the method in the embodiment of the present application will not be described in detail herein. The apparatus used to implement the methods of embodiments of the present application will be within the scope of the intended protection of the present application.
Based on the same inventive concept, the application provides a storage medium corresponding to the first embodiment, and the detail of the fourth embodiment is shown in the specification.
Example IV
The present embodiment provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, can implement any of the implementation modes of the embodiment.
The technical scheme provided by the embodiment of the application has at least the following technical effects or advantages:
the embodiment successfully solves the background changing requirement of the commodity image of the commodity seller, the seller only needs to simply shoot the commodity image, then the shot commodity image is used for generating the required synthetic image by using the technical scheme, the efficiency of manufacturing the commodity image is greatly improved, the operation cost of the seller is reduced, and professional shooting team, the cushion image editing of an artist and the like are not needed;
the light and shadow optimization method can greatly improve commodity synthesis efficiency, can effectively solve the problem of light and shadow deficiency which easily occurs in the traditional light and shadow synthesis algorithm, and enables the generated commodity graph to have higher authenticity, fusion effect and illumination effect.
It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While specific embodiments of the invention have been described above, it will be appreciated by those skilled in the art that the specific embodiments described are illustrative only and not intended to limit the scope of the invention, and that equivalent modifications and variations of the invention in light of the spirit of the invention will be covered by the claims of the present invention.

Claims (10)

Translated fromChinese
1.一种基于Lora模型训练的商品图换背景方法,其特征在于:包括下述步骤:1. A method for changing the background of a product image based on Lora model training, characterized in that it includes the following steps:步骤1、获取各种商品的第一商品图,所述第一商品图为设定拍摄角度的图片,且所述第一商品图包括同一商品在图片中不同比例的多张图片,得到训练数据;Step 1: Obtain first product images of various products, where the first product images are images taken at a set shooting angle, and the first product images include multiple images of the same product in different proportions in the image, to obtain training data;步骤2、将每张所述第一商品图通过多模态模型按照设定格式背景标签进行打标签,形成对应的标签文件;Step 2: Label each of the first product images according to the set format background label through the multimodal model to form a corresponding label file;步骤3、设置训练轮数、学习率以及训练图像像素,之后将训练数据与标签文件输入,进行模型训练,得到所需的背景Lora模型;Step 3: Set the number of training rounds, learning rate, and training image pixels, then input the training data and label file to perform model training to obtain the required background Lora model.步骤4、将需要更换背景的第二商品图进行抠图,获取其中的商品主体蒙版;提取所述第二商品图的边缘信息;Step 4: Cut out the second product image whose background needs to be replaced to obtain a product main body mask; extract edge information of the second product image;步骤5、在图生图算法中加载所述背景Lora模型,将所述边缘信息、背景提示词以及商品主体蒙版输入至所述图生图算法中,生成商品替换图;所述背景提示词与所述设定格式背景标签对应。Step 5: Load the background Lora model into the image generation algorithm, input the edge information, background prompt words and product body mask into the image generation algorithm, and generate a product replacement image; the background prompt words correspond to the set format background label.2.根据权利要求1所述的一种基于Lora模型训练的商品图换背景方法,其特征在于:还包括步骤6、获取商品替换图中的去背图和背景图;通Gamma变换对去背图进行增强,将去背图中商品主体的亮度提高第一设定值,得到增强图;将背景图映射到HSV空间,将HSV空间中的V空间进行降低第二设定值,之后再映射回RGB空间,得到背景暗化图;将增强图和背景暗化图进行合成,得到第一合成图,通过VAE解码从第一合成图中提取得到第一latent信息;将去背图和背景图进行合成,得到第二合成图,采用ControlNet模型从第二合成图中提取得到第一设定信息;将第一latent信息和第一设定信息发送至扩散模型,生成第一光影指导图;从第一光影指导图中提取得到第二lantent信息,将第二lantent信息和第一设定信息发送至扩散模型,生成第二光影指导图;通过高反差保留算法将第一光影指导图的纹理信息迁移到第二光影指导图上,得到中间图,之后采用welsh算法把背景图的颜色信息迁移到中间图,得到商品优化图。2. According to the method for replacing the background of a product image based on Lora model training described in claim 1, it is characterized by: further comprising step 6, obtaining a background-removed image and a background image in the product replacement image; enhancing the background-removed image by Gamma transformation, increasing the brightness of the product body in the background-removed image by a first set value, and obtaining an enhanced image; mapping the background image to the HSV space, reducing the V space in the HSV space by a second set value, and then mapping it back to the RGB space to obtain a background darkening image; synthesizing the enhanced image and the background darkening image to obtain a first synthesized image, and extracting first latent information from the first synthesized image by VAE decoding; and The background image is synthesized to obtain a second synthetic image, and the ControlNet model is used to extract the first setting information from the second synthetic image; the first latent information and the first setting information are sent to the diffusion model to generate a first light and shadow guidance map; the second latent information is extracted from the first light and shadow guidance map, and the second latent information and the first setting information are sent to the diffusion model to generate a second light and shadow guidance map; the texture information of the first light and shadow guidance map is transferred to the second light and shadow guidance map through the high contrast retention algorithm to obtain the intermediate image, and then the Welsh algorithm is used to transfer the color information of the background image to the intermediate image to obtain the product optimization map.3.根据权利要求1所述的一种基于Lora模型训练的商品图换背景方法,其特征在于:所述步骤1具体为:获取各种商品的第一商品图,所述第一商品图为设定拍摄角度的图片,且所述第一商品图包括同一商品在图片中不同比例的多张图片;将所有的所述第一商品图进行缩放,使得每张第一商品图的大小为1024*1024,得到训练数据。3. According to claim 1, a method for changing the background of a product image based on Lora model training is characterized in that: the step 1 specifically comprises: obtaining a first product image of various products, the first product image is a picture with a set shooting angle, and the first product image includes multiple pictures of the same product in different proportions in the picture; scaling all the first product images so that the size of each first product image is 1024*1024, and obtaining training data.4.根据权利要求1所述的一种基于Lora模型训练的商品图换背景方法,其特征在于:所述步骤4具体为:将需要更换背景的第二商品图进行抠图,获取其中的商品主体蒙版;调用canny算法提取所述第二商品图的边缘信息,所述canny算法的权重参数weight为0.9;4. According to the method for changing the background of a product image based on Lora model training in claim 1, the feature is that: the step 4 specifically comprises: cutting out the second product image whose background needs to be changed to obtain a product main body mask; calling the Canny algorithm to extract edge information of the second product image, wherein the weight parameter weight of the Canny algorithm is 0.9;所述步骤5具体为:在图生图算法中加载所述背景Lora模型,其加载权重设置为0.75,将所述边缘信息、背景提示词以及商品主体蒙版输入至所述图生图算法中,生成商品替换图;所述背景提示词与所述设定格式背景标签对应。The step 5 is specifically as follows: loading the background Lora model into the image generation algorithm, setting its loading weight to 0.75, inputting the edge information, background prompt words and product body mask into the image generation algorithm, and generating a product replacement image; the background prompt words correspond to the set format background label.5.一种基于Lora模型训练的商品图换背景装置,其特征在于:包括:5. A background changing device for a product image based on Lora model training, characterized in that it includes:获取训练数据模块,获取各种商品的第一商品图,所述第一商品图为设定拍摄角度的图片,且所述第一商品图包括同一商品在图片中不同比例的多张图片,得到训练数据;A training data acquisition module is provided to acquire first product images of various products, wherein the first product images are images taken at a set shooting angle and include multiple images of the same product in different proportions in the images, thereby obtaining training data;设置标签模块,将每张所述第一商品图通过多模态模型按照设定格式背景标签进行打标签,形成对应的标签文件;Setting a labeling module to label each of the first product images according to a set format background label through a multimodal model to form a corresponding label file;训练模型模块,设置训练轮数、学习率以及训练图像像素,之后将训练数据与标签文件输入,进行模型训练,得到所需的背景Lora模型;In the training model module, set the number of training rounds, learning rate, and training image pixels, then input the training data and label file to perform model training to obtain the required background Lora model;获取图片模块,将需要更换背景的第二商品图进行抠图,获取其中的商品主体蒙版;提取所述第二商品图的边缘信息;The image acquisition module cuts out the second product image whose background needs to be replaced to obtain a product main body mask; and extracts edge information of the second product image;生成图片模块,在图生图算法中加载所述背景Lora模型,将所述边缘信息、背景提示词以及商品主体蒙版输入至所述图生图算法中,生成商品替换图;所述背景提示词与所述设定格式背景标签对应。Generate an image module, load the background Lora model in the image generation algorithm, input the edge information, background prompt words and product body mask into the image generation algorithm, and generate a product replacement image; the background prompt words correspond to the set format background label.6.根据权利要求5所述的一种基于Lora模型训练的商品图换背景装置,其特征在于:还包括优化光影模块,获取商品替换图中的去背图和背景图;通Gamma变换对去背图进行增强,将去背图中商品主体的亮度提高第一设定值,得到增强图;将背景图映射到HSV空间,将HSV空间中的V空间进行降低第二设定值,之后再映射回RGB空间,得到背景暗化图;将增强图和背景暗化图进行合成,得到第一合成图,通过VAE解码从第一合成图中提取得到第一latent信息;将去背图和背景图进行合成,得到第二合成图,采用ControlNet模型从第二合成图中提取得到第一设定信息;将第一latent信息和第一设定信息发送至扩散模型,生成第一光影指导图;从第一光影指导图中提取得到第二lantent信息,将第二lantent信息和第一设定信息发送至扩散模型,生成第二光影指导图;通过高反差保留算法将第一光影指导图的纹理信息迁移到第二光影指导图上,得到中间图,之后采用welsh算法把背景图的颜色信息迁移到中间图,得到商品优化图。6. According to the device for replacing the background of a product image based on Lora model training as described in claim 5, it is characterized by: further comprising a light and shadow optimization module to obtain a background-removed image and a background image in the product replacement image; enhancing the background-removed image by Gamma transformation, increasing the brightness of the product body in the background-removed image by a first set value, and obtaining an enhanced image; mapping the background image to the HSV space, reducing the V space in the HSV space by a second set value, and then mapping it back to the RGB space to obtain a background darkening image; synthesizing the enhanced image and the background darkening image to obtain a first synthesized image, and extracting first latent information from the first synthesized image by VAE decoding; The background image is synthesized to obtain a second synthesized image, and the ControlNet model is used to extract the first setting information from the second synthesized image; the first latent information and the first setting information are sent to the diffusion model to generate a first light and shadow guidance map; the second latent information is extracted from the first light and shadow guidance map, and the second latent information and the first setting information are sent to the diffusion model to generate a second light and shadow guidance map; the texture information of the first light and shadow guidance map is migrated to the second light and shadow guidance map through a high contrast retention algorithm to obtain an intermediate image, and then the Welsh algorithm is used to migrate the color information of the background image to the intermediate image to obtain a product optimization image.7.根据权利要求5所述的一种基于Lora模型训练的商品图换背景装置,其特征在于:所述获取训练数据模块具体为:获取各种商品的第一商品图,所述第一商品图为设定拍摄角度的图片,且所述第一商品图包括同一商品在图片中不同比例的多张图片;将所有的所述第一商品图进行缩放,使得每张第一商品图的大小为1024*1024,得到训练数据。7. According to claim 5, a background changing device for product images based on Lora model training is characterized in that: the module for obtaining training data specifically comprises: obtaining first product images of various products, the first product images being images with a set shooting angle, and the first product images including multiple images of the same product in different proportions in the images; scaling all the first product images so that the size of each first product image is 1024*1024 to obtain training data.8.根据权利要求5所述的一种基于Lora模型训练的商品图换背景装置,其特征在于:所述获取图片模块具体为:将需要更换背景的第二商品图进行抠图,获取其中的商品主体蒙版;调用canny算法提取所述第二商品图的边缘信息,所述canny算法的权重参数weight为0.9;8. The device for replacing the background of a product image based on Lora model training according to claim 5, characterized in that: the image acquisition module specifically cuts out the second product image whose background needs to be replaced to obtain the product main body mask; calls the Canny algorithm to extract the edge information of the second product image, and the weight parameter weight of the Canny algorithm is 0.9;所述生成图片模块具体为:在图生图算法中加载所述背景Lora模型,其加载权重设置为0.75,将所述边缘信息、背景提示词以及商品主体蒙版输入至所述图生图算法中,生成商品替换图;所述背景提示词与所述设定格式背景标签对应。The image generation module specifically includes: loading the background Lora model in the image generation algorithm, setting its loading weight to 0.75, inputting the edge information, background prompt words and product body mask into the image generation algorithm, and generating a product replacement image; the background prompt words correspond to the set format background label.9.一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其特征在于,所述处理器执行所述程序时实现如权利要求1至4任一项所述的方法。9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 4 when executing the program.10.一种计算机可读存储介质,其上存储有计算机程序,其特征在于,该程序被处理器执行时实现如权利要求1至4任一项所述的方法。10. A computer-readable storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
CN202510108338.7A2025-01-232025-01-23Commodity graph background changing method, device, equipment and medium based on Lora model trainingPendingCN120070663A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202510108338.7ACN120070663A (en)2025-01-232025-01-23Commodity graph background changing method, device, equipment and medium based on Lora model training

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202510108338.7ACN120070663A (en)2025-01-232025-01-23Commodity graph background changing method, device, equipment and medium based on Lora model training

Publications (1)

Publication NumberPublication Date
CN120070663Atrue CN120070663A (en)2025-05-30

Family

ID=95802877

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202510108338.7APendingCN120070663A (en)2025-01-232025-01-23Commodity graph background changing method, device, equipment and medium based on Lora model training

Country Status (1)

CountryLink
CN (1)CN120070663A (en)

Similar Documents

PublicationPublication DateTitle
US11302053B2 (en)Determining image handle locations
US6009209A (en)Automated removal of red eye effect from a digital image
US9135732B2 (en)Object-level image editing
JP4971768B2 (en) Editing apparatus, editing method, and program
US11386589B2 (en)Method and device for image generation and colorization
US20140218356A1 (en)Method and apparatus for scaling images
US20200242823A1 (en)Transferring Vector Style Properties to a Vector Artwork
US20120249571A1 (en)Image display method, server, and image display system
CN106447756B (en)Method and system for generating user-customized computer-generated animations
US20160314502A1 (en)System and method for streamlining the design and development process of multiple advertising units
CN114997105A (en) Design template and material generation method, computing device and storage medium
KR101392166B1 (en)Method for editing an image and for generating an editing image and for storing an edited image of a portable display device and apparatus thereof
EP1826724B1 (en)Object-level image editing using tiles of image data
CN117495894A (en)Image generation processing method and electronic equipment
CN113223187A (en)Advertisement finished product image batch manufacturing method, system, equipment and readable storage medium
Hu et al.Inverse image editing: Recovering a semantic editing history from a before-and-after image pair
CN111881648A (en) A method for generating e-book font files
Chen et al.Zero-shot image harmonization with generative model prior
CN120070663A (en)Commodity graph background changing method, device, equipment and medium based on Lora model training
CN117726718A (en)E-commerce product poster generation method based on artificial intelligence image generation tool
CN116486412A (en) Image material processing method, device and equipment
CN112927321B (en)Intelligent image design method, device, equipment and storage medium based on neural network
Dayley et al.Photoshop CS5 Bible
JP7612785B1 (en) Information processing device, information processing method, program, and storage medium
BradleyMastering Adobe Photoshop 2024: Discover the smart way to polish your digital imagery skills by editing professional looking photos

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination

[8]ページ先頭

©2009-2025 Movatter.jp