Training method, device, equipment and storage medium of raw image model
Patent Information
- Application Number
- CN202411952597.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-04-01
AI Technical Summary
[0004]然而,在对生图模型进行训练时,需要提前准备大量的样本图像,少则几千张,多则几万张,即训练过程需要非常巨大的图像量级才能满足需求,而获取图像的过程费时费资源
[0075] In the embodiment of the present application, the subject average color and the subject color of each target image are determined by acquiring a target image that conforms to the target filter style and based on the pixels of each target image. Afterwards, in the target image, the sample images that meet the preset conditions between the subject color and the subject average color can be filtered. These sample images and the Lora training method can be used to train the raw graph model to obtain the pre-trained raw graph model. Since the lora training method requires a small number of sample images, the training process of the biographic model can be completed without obtaining a large number of images, saving time and effort in obtaining sample images.
Smart Images

Figure CN119741190A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a training method, device, equipment and storage medium for a raw image model. Background Art
[0002] Posters are important materials for film and television marketing and promotion. They interpret the theme and connotation of the film and television series, and influence and shape the audience's first impression of the film and television series. In order to obtain a large number of posters, suitable parts are often automatically selected from the original series materials as posters. At the same time, in order to match the characteristics of the series, a certain theme filter style will be added to the picture manually. For example, period dramas often add khaki or gold color styles, and suspense dramas add dark filter styles.
[0003] In the prior art, a filter style corresponding to a certain theme is added to an image through a pre-trained raw image model.
[0004] However, when training the raw image model, a large number of sample images need to be prepared in advance, ranging from a few thousand to tens of thousands. That is, the training process requires a very large amount of images to meet the needs, and the process of obtaining images is time-consuming and resource-intensive. Summary of the invention
[0005] The present application provides a training method, device, equipment and storage medium for a raw image model, which does not require the acquisition of a large number of images, saving time and energy in acquiring sample images.
[0006] In a first aspect, the present application provides a method for training a raw image model, the method comprising:
[0007] Get the target image that matches the target filter style;
[0008] Determine the theme average color and the theme color of each target image based on the pixels of each target image;
[0009] In the target image, sample images that meet a preset condition between the theme color and the theme average color are selected;
[0010] The raw image model is trained using the sample image and the lora training method to obtain a pre-trained raw image model, which is used to generate an image with a target filter style added.
[0011] Optionally, determining a theme color of each target image according to the pixels of each target image includes:
[0012] For each target image, obtaining the color of each pixel in the target image;
[0013] According to the color interval where the color of each pixel is located, the number of pixels corresponding to each color interval is determined;
[0014] Determine the color interval with the largest number of corresponding pixels as the target color interval;
[0015] According to the target color range, a theme color of the target image is determined.
[0016] Optionally, screening, in the target image, sample images that meet a preset condition between the theme color and the theme average color includes:
[0017] Generating a plurality of theme color intervals according to the theme average color;
[0018] Determine the number of target images in each theme color interval, and obtain the number corresponding to each theme color interval;
[0019] Among the theme color intervals whose corresponding number meets the preset number, the theme color interval with the smallest interval range is determined as the target interval;
[0020] The target image included in the target interval is determined as a sample image.
[0021] Optionally, generating a plurality of theme color intervals according to the theme average color includes:
[0022] According to the theme average color, determine the average value corresponding to each color type;
[0023] For each color type, taking the corresponding average value as the center and the corresponding preset length as the sub-interval length, a theme color sub-interval of the type is generated;
[0024] Different types of theme color sub-intervals are combined to obtain multiple theme color intervals.
[0025] Optionally, the method further includes:
[0026] Collect multiple images;
[0027] Based on a clustering method, clustering the image to obtain at least one clustering result, each clustering result including at least one image;
[0028] Determine the proportion corresponding to each clustering result according to the total number of the images and the images included in each clustering result;
[0029] The image included in the clustering result with the highest proportion is determined as the target image.
[0030] Optionally, determining the theme color of the target image according to the target color range includes:
[0031] Obtaining a pixel set corresponding to the target color interval;
[0032] determining an average color of the set of pixels;
[0033] The average color is determined as the theme color of the target image.
[0034] Optionally, the raw image model is trained using the sample image and the lora training method to obtain a pre-trained raw image model, including
[0035] Obtain the wake-up word corresponding to the target filter style and the image description word corresponding to each sample image;
[0036] The lora training method is used to train the raw image model using the sample image, the corresponding image description word and the wake-up word to obtain a pre-trained raw image model.
[0037] In a second aspect, the present application provides a training device for a raw image model, the device comprising:
[0038] An acquisition unit, used for acquiring a target image that matches a target filter style;
[0039] A determination unit, used to determine the theme average color and the theme color of each target image according to the pixels of each target image;
[0040] A screening unit, used for screening, in the target image, sample images that meet a preset condition between the theme color and the theme average color;
[0041] A training unit is used to train the raw image model using the sample image and the lora training method to obtain a pre-trained raw image model, wherein the raw image model is used to generate an image with a target filter style added.
[0042] Optionally, determine the unit for:
[0043] For each target image, obtaining the color of each pixel in the target image;
[0044] According to the color interval where the color of each pixel is located, the number of pixels corresponding to each color interval is determined;
[0045] Determine the color interval with the largest number of corresponding pixels as the target color interval;
[0046] According to the target color range, a theme color of the target image is determined.
[0047] Optional, screening unit for:
[0048] Generating a plurality of theme color intervals according to the theme average color;
[0049] Determine the number of target images in each theme color interval, and obtain the number corresponding to each theme color interval;
[0050] Among the theme color intervals whose corresponding number meets the preset number, the theme color interval with the smallest interval range is determined as the target interval;
[0051] The target image included in the target interval is determined as a sample image.
[0052] Optional, screening unit for:
[0053] According to the theme average color, determine the average value corresponding to each color type;
[0054] For each color type, taking the corresponding average value as the center and the corresponding preset length as the sub-interval length, a theme color sub-interval of the type is generated;
[0055] Different types of theme color sub-intervals are combined to obtain multiple theme color intervals.
[0056] Optionally, the device further includes an image determining unit, wherein the image determining unit is configured to:
[0057] Collect multiple images;
[0058] Based on a clustering method, clustering the image to obtain at least one clustering result, each clustering result including at least one image;
[0059] Determine the proportion corresponding to each clustering result according to the total number of the images and the images included in each clustering result;
[0060] The image included in the clustering result with the highest proportion is determined as the target image.
[0061] Optionally, the screening unit is used to:
[0062] Obtaining a pixel set corresponding to the target color interval;
[0063] determining an average color of the set of pixels;
[0064] The average color is determined as the theme color of the target image.
[0065] Optional, training unit for:
[0066] Obtain the wake-up word corresponding to the target filter style and the image description word corresponding to each sample image;
[0067] The lora training method is used to train the raw image model using the sample image, the corresponding image description word and the wake-up word to obtain a pre-trained raw image model.
[0068] In a third aspect, the present application provides a training device for a raw image model, comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; at least one memory connected to the at least one bus, wherein the processor is configured to:
[0069] Get the target image that matches the target filter style;
[0070] Determine the theme average color and the theme color of each target image based on the pixels of each target image;
[0071] In the target image, sample images that meet a preset condition between the theme color and the theme average color are selected;
[0072] The raw image model is trained using the sample image and the lora training method to obtain a pre-trained raw image model, which is used to generate an image with a target filter style added.
[0073] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-mentioned training method for the raw image model.
[0074] The above technical solution provided by the embodiment of the present application has the following advantages compared with the prior art:
[0075] In an embodiment of the present application, a target image that conforms to the target filter style is obtained, and the theme average color and the theme color of each target image are determined based on the pixels of each target image. Afterwards, in the target image, sample images that meet the preset conditions between the theme color and the theme average color are screened, and these sample images and the Lora training method can be used to train the raw image model to obtain a pre-trained raw image model. Since the Lora training method requires a small number of sample images, the training process of the raw image model can be completed without obtaining a large number of images, saving time and energy in obtaining sample images. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0077] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0078] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0079] Figure 1 A schematic diagram of a flow chart of a method for training a raw image model provided in an embodiment of the present application;
[0080] Figure 2 A flowchart of a method for determining a theme color provided in an embodiment of the present application;
[0081] Figure 3 A schematic diagram of a flow chart of a sample image determination method provided in an embodiment of the present application;
[0082] Figure 4 A flowchart of a method for determining a theme color interval provided in an embodiment of the present application;
[0083] Figure 5 A schematic diagram of a flow chart of a target image determination method provided in an embodiment of the present application;
[0084] Figure 6 A flowchart of a method for determining a theme color provided in an embodiment of the present application;
[0085] Figure 7 A flowchart of another method for training a raw image model provided in an embodiment of the present application;
[0086] Figure 8 A schematic diagram of a flow chart of a training device for a raw image model provided in an embodiment of the present application;
[0087] Fig. 9 A schematic diagram of a training device for a raw image model provided in an embodiment of the present application. DETAILED DESCRIPTION
[0088] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0089] The disclosure below provides many different embodiments or examples to implement different structures of the present invention. In order to simplify the disclosure of the present invention, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present invention. In addition, the present invention can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0090] Posters are important materials for film and television marketing and promotion. They interpret the theme and connotation of the film and television drama, and influence and shape the audience's first impression of the film and television drama. In order to obtain a large number of posters, suitable parts are often automatically selected from the original drama materials as posters. At the same time, in order to meet the characteristics of the drama, the filter style of a certain theme will be added to the picture manually. For example, period dramas often add khaki or gold color styles, and suspense dramas add dark filter styles. In the prior art, a filter style corresponding to a certain theme is added to the image through a pre-trained raw image model. However, when training the raw image model, a large number of sample images need to be prepared in advance, ranging from a few thousand to tens of thousands. That is, the training process requires a very large amount of images to meet the needs, and the process of obtaining images is time-consuming and resource-intensive.
[0091] In order to solve the above problems, the embodiment of the present application provides a method for training a raw image model. The method only needs a small number of sample images to complete the training process of the raw image model, without obtaining a large number of images, thus saving time and energy for obtaining sample images. Figure 1 As shown, the specific steps include:
[0092] Step 101, obtaining a target image that meets the target filter style.
[0093] Among them, the target filter style is the filter style added to the image.
[0094] In this step, the technician can collect images with the same filter style on the Internet, and can use the filter style as the target filter style and the image as the target image.
[0095] Step 102, determining the theme color and theme average color of each target image according to the pixels of each target image.
[0096] The theme average color is the average of the theme colors of all target images.
[0097] In this step, for each target image, the color of each pixel in the target image is obtained, and the theme color of the target image is determined according to the colors of these pixels. According to the theme color of each target image, the theme average color of these target images is calculated.
[0098] Furthermore, the average color of all pixels in the target image can be determined as the theme color of the target image. A plurality of color intervals can also be pre-divided. Then, based on the color interval, the color interval where the color of each pixel in the target image is located is determined, and then, according to the number of pixels included in each color interval, the target color interval where the pixel is mainly located is found in these color intervals, and then the theme color of the target image is determined according to the target color interval.
[0099] Furthermore, the average color of all pixels corresponding to the target color interval can be determined as the theme color of the target image, or the middle color in the target color interval can be determined as the theme color of the target image. Of course, the present application can also use other methods for determining the theme color, which are not limited here.
[0100] Step 103 , screening sample images that meet preset conditions between the theme color and the theme average color in the target image.
[0101] In this step, among the target images, target images that meet the preset conditions between the theme color and the theme average color are screened out and determined as sample images.
[0102] Step 104: train the raw image model using the sample image and the Lora training method to obtain a pre-trained raw image model.
[0103] Among them, the raw image model is used to add the target filter style to the image.
[0104] In this step, the raw image model can also be trained using sample images and the lora training method to obtain a pre-trained raw image model.
[0105] In an embodiment of the present application, a target image that conforms to the target filter style is obtained, and the theme average color and the theme color of each target image are determined based on the pixels of each target image. Afterwards, in the target image, sample images that meet the preset conditions between the theme color and the theme average color are screened, and these sample images and the Lora training method can be used to train the raw image model to obtain a pre-trained raw image model. Since the Lora training method requires a small number of sample images, the training process of the raw image model can be completed without obtaining a large number of images, saving time and energy in obtaining sample images.
[0106] In the embodiment of the present application, the theme color of each target image can also be determined according to the pixels of each target image. Therefore, the embodiment of the present application provides a theme color determination method, which is a further limitation of step 102, such as Figure 2 As shown, the specific steps are:
[0107] Step 201, obtaining the color of each pixel in the target image.
[0108] In this step, the color of each pixel in the target image is obtained.
[0109] Step 202: Determine the number of pixels corresponding to each color interval according to the color interval of each pixel.
[0110] The color interval may be set by a technician based on experience or based on other methods, which is not limited here.
[0111] In this step, the color interval of each pixel is determined according to the color of each pixel, the pixels corresponding to each color interval are obtained, and the number of pixels corresponding to each color interval is determined according to the pixels corresponding to each color interval.
[0112] Step 203: determine the color interval with the largest number of corresponding pixels as the target color interval.
[0113] In this step, when a color interval includes the largest number of pixels, it means that the colors of most pixels in the target image are concentrated in this color interval. Therefore, the color interval with the largest number of corresponding pixels can be determined as the target color interval.
[0114] Step 204: determining the theme color of the target image according to the target color range.
[0115] In this step, the average color of all pixels included in the target color interval can be determined as the theme color of the target image, or the average of the left endpoint value and the right endpoint value of the target color interval can be determined, and the color corresponding to the average value can be determined as the theme color, or the pixel color with the highest proportion in the pixel set corresponding to the target color interval can be determined as the theme color, which is not limited here.
[0116] It should be noted that for each target image, Figure 2 The method of the embodiment.
[0117] In the embodiment of the present application, multiple theme color intervals can also be determined based on the theme average color, and then based on the theme color intervals, sample images that meet preset conditions between the theme color and the theme average color are screened in the target image. Therefore, the embodiment of the present application provides a sample image determination method, which is a further limitation of step 103, such as Figure 3 As shown, the specific steps are:
[0118] Step 301, generating a plurality of theme color intervals according to the theme average color.
[0119] In this step, a plurality of theme color intervals may be generated with the theme average color as the center and a preset length as the interval length.
[0120] Step 302: for each theme color interval, determine the number of target images of the theme color in the theme color interval to obtain the number corresponding to the theme color interval.
[0121] In this step, for each theme color interval, target images of the theme color in the theme color interval are determined, and the number of these target images is counted to obtain the number corresponding to the theme color interval.
[0122] Step 303 : among the theme color intervals whose corresponding number is greater than a preset number, determine the theme color interval with the smallest interval range as the target interval.
[0123] Among them, the preset number is set by the technician according to the required number of samples. For example, when the Lora training method requires 50 sample images, the preset number can be set to 50. When the Lora training method requires 100 sample images, the preset number can be set to 100.
[0124] In this step, the theme color intervals whose corresponding number is greater than the preset number can be first screened out, and among these theme color intervals, the theme color interval with the smallest interval range is determined as the target interval. Alternatively, these theme color intervals are sorted according to the interval range corresponding to each theme color interval to obtain the arrangement order of the theme color intervals. From small to large, the number corresponding to the theme color intervals is detected in sequence to see if it is greater than the preset number. When the corresponding number is not greater than the preset number, continue to detect the next theme color interval. When the corresponding number is greater than the preset number, the theme color interval is determined as the target interval.
[0125] In one embodiment, when the theme color interval includes sub-intervals corresponding to each color type, for each theme color interval, the length of the sub-interval corresponding to each color type included therein may be added to obtain the interval length corresponding to the theme color interval, and then these theme color intervals may be sorted according to the interval length corresponding to each theme color interval to obtain the arrangement order of the theme color intervals.
[0126] Furthermore, when there are multiple theme color intervals with the same interval length, these theme color intervals can be randomly sorted, or the theme color intervals can be sorted according to the difference between the sub-interval lengths. For example, when the theme color intervals are sorted in order from small to large, the smaller the difference, the earlier the corresponding order, and the larger the difference, the later the corresponding order. Of course, the present application can also use the actual sorting method, which is not limited here.
[0127] Step 304 , determining the target image with the theme color in the target interval as a sample image that satisfies a preset condition between the theme color and the theme average color.
[0128] In this step, a target image whose theme color is in a target interval is determined, and the target image is determined as a sample image that meets a preset condition between the theme color and the theme average color.
[0129] In the embodiment of the present application, when the theme average color includes the average values of different color types, a corresponding theme color sub-interval can be generated for each color type, and then different types of theme color sub-intervals can be combined to obtain multiple theme color intervals. Therefore, the embodiment of the present application provides a theme color interval determination method, which is as follows: Figure 4 As shown, the specific steps include:
[0130] Step 401, determining the average value corresponding to each color type according to the theme average color.
[0131] Among them, the color type is the type included in the HSV color space, such as hue, saturation and brightness. Hue is the basic attribute of color, which determines the category of color, such as red, blue, etc. Saturation indicates the purity or vividness of the color. The higher the saturation, the brighter the color. Brightness indicates the brightness of the color. The higher the brightness, the brighter the color.
[0132] In this step, the hue value corresponding to the theme average color in the HSV color space is obtained, and it is determined as the average value corresponding to the color. The saturation value corresponding to the theme average color in the HSV color space is obtained, and it is determined as the average value corresponding to the saturation. The lightness value corresponding to the theme average color in the HSV color space is obtained, and it is determined as the average value corresponding to the lightness.
[0133] For example, the average value corresponding to color is h_avg, the average value corresponding to saturation is s_avg, and the average value corresponding to lightness is v_avg.
[0134] Step 402 : For each color type, a theme color sub-interval of the color type is generated with the corresponding average value as the center and the corresponding preset length as the sub-interval length.
[0135] The preset lengths corresponding to each color type may be the same or different. The preset lengths may be set by technicians for each color type based on experience or may be set based on other methods, which are not limited here.
[0136] In this step, for each color type, a theme color sub-interval of the color type is generated with the corresponding average value as the center and the corresponding preset length as the sub-interval length.
[0137] It should be noted that different color types correspond to different numbers of preset lengths. For example, hue corresponds to one preset length, saturation corresponds to three different preset lengths, and brightness also corresponds to three different preset lengths.
[0138] For example, the theme color sub-interval corresponding to hue is [h_avg-5,h_avg+5], the theme color sub-interval corresponding to saturation is [s_avg-10,s_avg+10], [s_avg-15,s_avg+15] and [s_avg-20,s_avg+20], and the theme color sub-interval corresponding to lightness is [v_avg-10,v_avg+10], [v_avg-15,v_avg+15] and [v_avg-20,v_avg+20].
[0139] Step 403: combining different types of theme color sub-intervals to obtain multiple theme color intervals.
[0140] In this step, a theme color sub-interval is selected from each of the theme color sub-interval corresponding to the color, the theme color sub-interval corresponding to the saturation, and the theme color sub-interval corresponding to the lightness, and these three theme color sub-intervals are combined to obtain a theme color interval. It is known that all different combinations are selected to obtain all theme color intervals.
[0141] For example, according to the example in step 402, 9 theme color intervals can be obtained, namely {[h_avg-5,h_avg+5], [s_avg-10,s_avg+10], [v_avg-10,v_avg+10]}, {[h_avg-5,h_avg+5], [s_avg-10,s_avg+10], [v_avg-15,v_avg+10]}. vg+15]}, {[h_avg-5,h_avg+5], [s_avg-10,s_avg+10], [v_avg-20,v_avg+20]}, {[h _avg-5,h_avg+5], [s_avg-15,s_avg+15], [v_avg-10,v_avg+10]}, {[h_avg-5,h_avg +5], [s_avg-15,s_avg+15], [v_avg-15,v_avg+15]}, {[h_avg-5,h_avg+5], [s_avg- 15,s_avg+15], [v_avg-20,v_avg+20]}, {[h_avg-5,h_avg+5], [s_avg-20,s_avg+20 ], [v_avg-10,v_avg+10]}, {[h_avg-5,h_avg+5], [s_avg-20,s_avg+20], [v_avg-15 ,v_avg+15]}, {[h_avg-5,h_avg+5], [s_avg-20,s_avg+20], [v_avg-20,v_avg+20]}.
[0142] In the embodiment of the present application, after collecting multiple images, these images can also be screened to obtain a target image. Therefore, the embodiment of the present application provides a method for determining a target image. Figure 5 As shown, the specific steps include:
[0143] Step 501: collect multiple images.
[0144] In this step, after collecting multiple images of the target filter style on the Internet, these images can be screened to obtain the target image.
[0145] Step 502: cluster the image based on a clustering method to obtain at least one clustering result.
[0146] Each clustering result includes at least one image. The clustering method is used to divide the samples in the data set into different groups, and the specific method may be K-Means clustering or the like.
[0147] In this step, a clustering method is used to cluster the images, and then images with similar colors are divided into one clustering result.
[0148] Step 503: Determine the proportion corresponding to each clustering result according to the total number of images and the images included in each clustering result.
[0149] In this step, for each clustering result, the images included in the clustering result are counted to obtain the number corresponding to the clustering result, and the ratio of the number to the total number is determined as the proportion corresponding to the clustering result.
[0150] Alternatively, for each clustering result, the number of pixels included in the clustering result and the total number of pixels of all images are counted, and the ratio of the number of pixels to the total number of pixels is determined as the proportion corresponding to the clustering result.
[0151] Step 504: determine the image included in the clustering result with the highest proportion as the target image.
[0152] In this step, the image included in the clustering result with the highest proportion is determined as the target image.
[0153] Furthermore, it is also possible to detect whether the highest proportion is greater than a preset proportion. If not, continue to collect images and repeat the above steps. If greater, the image included in the clustering result with the highest proportion is determined as the target image.
[0154] In the embodiment of the present application, the theme color of the target image can also be determined according to the target color interval. Therefore, the embodiment of the present application provides a theme color determination method. Figure 6 As shown, specifically including:
[0155] Step 601, obtaining a pixel set corresponding to a target color interval.
[0156] In this step, all pixels whose colors are within the target color interval are obtained, and these pixels are combined into a pixel set corresponding to the target color interval.
[0157] Step 602, determine the average color of a set of pixels.
[0158] In this step, the color of each pixel in the pixel set is obtained, and the average color of these colors is calculated.
[0159] Step 603: determine the average color as the theme color of the target image.
[0160] In this step, the average color is determined as the theme color of the target image.
[0161] In the embodiment of the present application, after obtaining the sample images, it is also necessary to obtain the image description words corresponding to each sample image and the wake-up words corresponding to the target filter style, and then use the wake-up words and each sample image and the corresponding image description words to train the raw image model. Therefore, the embodiment of the present application provides a method for training the raw image model. Figure 7 As shown, the specific steps include:
[0162] Step 701, obtain the wake-up word corresponding to the target filter style and the image description word corresponding to each sample image.
[0163] In this step, the wake-up word is a meaningless word used to determine the model of the target filter style and to represent the commonality of these sample images. At the same time, a whole sentence or word is used to describe the objects and other information in each sample image. In order to make the image description words corresponding to the sample images accurately describe the sample images, any existing open source methods, such as WD Tagger, DeepseekVL, etc., or manual descriptions are used. It is only necessary to describe the content of the image clearly.
[0164] For example, the wake-up word can be written as: niandaistyle, which represents the style filter of period dramas and is used to instruct the use of the model corresponding to the style of period dramas.
[0165] Step 702: Use the Lora training method to train the raw image model using sample images, corresponding image description words, and wake-up words to obtain a pre-trained raw image model.
[0166] In the process of training the raw image model using the lora training method, the image description words and the wake-up words are used as the input of the raw image model so that the raw image model outputs a predicted image, and then the raw image model is adjusted according to the predicted image and the sample object.
[0167] Furthermore, the process of training the raw image model using the lora training method is similar to the prior art and will not be described in detail here.
[0168] like Figure 8 As shown, the embodiment of the present application provides a training device for a raw image model, which corresponds to the method embodiment and specifically includes:
[0169] An acquisition unit 801 is used to acquire a target image that matches a target filter style;
[0170] A determination unit 802, configured to determine a theme average color and a theme color of each target image according to pixels of each target image;
[0171] A screening unit 803 is used to screen, in the target image, sample images that meet a preset condition between the theme color and the theme average color;
[0172] The training unit 804 is used to train the raw image model using the sample image and the lora training method to obtain a pre-trained raw image model, and the raw image model is used to generate an image with a target filter style added.
[0173] Optionally, the determining unit 802 is configured to:
[0174] For each target image, obtaining the color of each pixel in the target image;
[0175] According to the color interval where the color of each pixel is located, the number of pixels corresponding to each color interval is determined;
[0176] The color interval with the largest number of corresponding pixels is determined as the target color interval;
[0177] According to the target color range, a theme color of the target image is determined.
[0178] Optionally, the screening unit 803 is used to:
[0179] Generating a plurality of theme color intervals according to the theme average color;
[0180] Determine the number of target images in each theme color interval, and obtain the number corresponding to each theme color interval;
[0181] Among the theme color intervals whose corresponding number meets the preset number, the theme color interval with the smallest interval range is determined as the target interval;
[0182] The target image included in the target interval is determined as a sample image.
[0183] Optionally, the screening unit 803 is used to:
[0184] According to the theme average color, determine the average value corresponding to each color type;
[0185] For each color type, taking the corresponding average value as the center and the corresponding preset length as the sub-interval length, a theme color sub-interval of the type is generated;
[0186] Different types of theme color sub-intervals are combined to obtain multiple theme color intervals.
[0187] Optionally, the apparatus further includes an image determining unit 805, wherein the image determining unit 805 is configured to:
[0188] Collect multiple images;
[0189] Based on a clustering method, clustering the image to obtain at least one clustering result, each clustering result including at least one image;
[0190] Determine the proportion corresponding to each clustering result according to the total number of the images and the images included in each clustering result;
[0191] The image included in the clustering result with the highest proportion is determined as the target image.
[0192] Optionally, the screening unit 803 is used to:
[0193] Obtaining a pixel set corresponding to the target color interval;
[0194] determining an average color of the set of pixels;
[0195] The average color is determined as the theme color of the target image.
[0196] Optionally, the training unit 804 is used to:
[0197] Obtain the wake-up word corresponding to the target filter style and the image description word corresponding to each sample image;
[0198] The lora training method is used to train the raw image model using the sample image, the corresponding image description word and the wake-up word to obtain a pre-trained raw image model.
[0199] like Fig. 9 As shown, the embodiment of the present application provides a training device for a raw image model, including a processor 901, a communication interface 902, a memory 903 and a communication bus 904, wherein the processor 901, the communication interface 902, and the memory 903 communicate with each other through the communication bus 904.
[0200] Memory 903, used for storing computer programs;
[0201] In one embodiment of the present application, the processor 901 is used to execute the program stored in the memory 903 to implement the training method of the raw image model provided by any of the above method embodiments, including:
[0202] Get the target image that matches the target filter style;
[0203] Determine the theme average color and the theme color of each target image based on the pixels of each target image;
[0204] In the target image, sample images that meet a preset condition between the theme color and the theme average color are selected;
[0205] The raw image model is trained using the sample image and the lora training method to obtain a pre-trained raw image model, which is used to generate an image with a target filter style added.
[0206] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps performed by the training method of the raw image model provided in any of the aforementioned method embodiments are implemented.
[0207] The device embodiments described above are merely illustrative, wherein 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 modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0208] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0209] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.
[0210] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A method for training a raw image model, characterized in that: The method comprises: Get the target image that matches the target filter style; Determine the theme average color and the theme color of each target image based on the pixels of each target image; In the target image, sample images that meet a preset condition between the theme color and the theme average color are selected; The raw image model is trained using the sample image and the lora training method to obtain a pre-trained raw image model, which is used to generate an image with a target filter style added.
2. The method according to claim 1, characterized in that: According to the pixels of each target image, the theme color of each target image is determined, including: For each target image, obtaining the color of each pixel in the target image; According to the color interval where the color of each pixel is located, the number of pixels corresponding to each color interval is determined; The color interval with the largest number of corresponding pixels is determined as the target color interval; According to the target color range, a theme color of the target image is determined.
3. The method according to claim 1, characterized in that: The step of screening, in the target image, sample images that meet a preset condition between the theme color and the theme average color includes: Generating a plurality of theme color intervals according to the theme average color; Determine the number of target images in each theme color interval, and obtain the number corresponding to each theme color interval; Among the theme color intervals whose corresponding number meets the preset number, the theme color interval with the smallest interval range is determined as the target interval; The target image included in the target interval is determined as a sample image.
4. The method according to claim 3, characterized in that: The step of generating a plurality of theme color intervals according to the theme average color includes: According to the theme average color, determine the average value corresponding to each color type; For each color type, taking the corresponding average value as the center and the corresponding preset length as the sub-interval length, a theme color sub-interval of the type is generated; Different types of theme color sub-intervals are combined to obtain multiple theme color intervals.
5. The method according to claim 1, characterized in that: The method further comprises: Collect multiple images; Based on a clustering method, clustering the image to obtain at least one clustering result, each clustering result including at least one image; Determine the proportion corresponding to each clustering result according to the total number of the images and the images included in each clustering result; The image included in the clustering result with the highest proportion is determined as the target image.
6. The method according to claim 2, characterized in that: Determining the theme color of the target image according to the target color interval includes: Obtaining a pixel set corresponding to the target color interval; determining an average color of the set of pixels; The average color is determined as the theme color of the target image.
7. The method according to claim 1, characterized in that: The raw image model is trained using the sample image and the lora training method to obtain a pre-trained raw image model, including Obtain the wake-up word corresponding to the target filter style and the image description word corresponding to each sample image; The lora training method is used to train the raw image model using the sample image, the corresponding image description word and the wake-up word to obtain a pre-trained raw image model.
8. A training device for a raw image model, characterized in that: The device comprises: An acquisition unit, used for acquiring a target image that matches a target filter style; A determination unit, used to determine the theme average color and the theme color of each target image according to the pixels of each target image; A screening unit, used for screening, in the target image, sample images that meet a preset condition between the theme color and the theme average color; A training unit is used to train the raw image model using the sample image and the lora training method to obtain a pre-trained raw image model, wherein the raw image model is used to generate an image with a target filter style added.
9. A training device for a raw image model, characterized in that: include: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; at least one memory connected to the at least one bus, wherein the processor is configured to: Get the target image that matches the target filter style; Determine the theme average color and the theme color of each target image based on the pixels of each target image; In the target image, sample images that meet a preset condition between the theme color and the theme average color are selected; The raw image model is trained using the sample image and the lora training method to obtain a pre-trained raw image model, which is used to generate an image with a target filter style added.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the training method of the raw image model described in any one of claims 1 to 7 is implemented.