Cigarette sample image generation method and device, electronic equipment and storage medium

By encoding, adding noise, and denoising cigarette images using a target diffusion model, highly controllable and diverse defective cigarette sample images are generated. This solves the problems of scarce defective cigarette samples and insufficient morphological diversity in existing technologies, and improves the data support for cigarette defect detection.

CN121280263APending Publication Date: 2026-01-06CHINA TOBACCO ZHEJIANG IND CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511392103.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-26
Publication Date
2026-01-06

AI Technical Summary

Technical Problem

The lack of defective cigarette samples and insufficient diversity of defect morphology in existing technologies make it easy for cigarette filters to develop appearance defects such as broken patterns, wrinkles, and dirt during the forming process, which affects the quality of cigarettes and market feedback.

Method used

The normal cigarette images are encoded, denoised, and de-denoised using a target diffusion model. The target defect embedding vector and mask embedding vector are used to generate highly controllable and diverse defective cigarette sample images at the cigarette filter, ensuring the authenticity and diversity of the images.

Benefits of technology

It improves the visual realism and diversity of defective cigarette sample images, provides rich data support, and lays a broad and feasible foundation for subsequent cigarette defect detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121280263A_ABST
    Figure CN121280263A_ABST
Patent Text Reader

Abstract

The invention discloses a cigarette sample image generation method and device, electronic equipment and a storage medium. The method comprises the steps of obtaining a to-be-processed normal cigarette image; performing coding processing on the normal cigarette image to be processed based on the target diffusion model to obtain a latent vector to be processed; a noise adding module based on a target diffusion model performs multiple times of noise adding processing on the latent vector to be processed according to the random Gaussian noise to obtain a noise latent vector; denoising the noise latent vector for multiple times based on at least one target embedded vector of a denoising module of the target diffusion model to obtain a target latent vector, and decoding the target latent vector to obtain a target cigarette sample image; the target cigarette sample image is a cigarette image with appearance defects at the cigarette filter tip, the at least one target embedding vector comprises a target defect embedding vector and / or a target mask embedding vector, and the number of times of denoising processing and the number of times of noise adding processing are consistent. According to the invention, the authenticity and reliability of the target cigarette sample image are ensured, and the defective cigarette sample images are enriched.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to a method, apparatus, electronic device, and storage medium for generating cigarette sample images. Background Technology

[0002] With the continuous upgrading and intensified competition in the cigarette industry, more and more high-end cigarette products are incorporating more refined patterns, recessed designs, and other decorative designs into their filters to meet consumers' dual demands for flavor and visual appeal. However, high-speed cigarette rolling machines typically face challenges such as high operating speeds, significant frictional losses, and complex rolling structures during actual operation. This makes cigarette filters highly susceptible to various appearance defects during the forming process, including pattern breakage, wrinkles, stains, and deformation. These defects not only affect the overall quality and visual appeal of the cigarettes but may also generate negative consumer feedback, thereby damaging brand reputation and corporate profits. Therefore, many cigarette factories and equipment manufacturers are gradually adopting computer vision inspection technology to replace traditional manual visual inspection or infrared photoelectric detection, aiming to achieve more accurate and flexible quality control on high-speed cigarette production lines.

[0003] However, in actual production, when using deep learning models to identify filter defects under these complex patterns or recessed designs, there are often problems such as a lack of defective cigarette samples and insufficient diversity of defect morphology. Summary of the Invention

[0004] This invention provides a method, apparatus, electronic device, and storage medium for generating cigarette sample images, which ensures the authenticity and reliability of target cigarette sample images and improves the diversity of defective cigarette sample images.

[0005] According to one aspect of the present invention, a method for generating cigarette sample images is provided, the method comprising:

[0006] Acquire images of normal cigarettes to be processed;

[0007] The target diffusion model is used to encode the normal cigarette image to be processed, and the latent vector to be processed is obtained.

[0008] The noise-adding module based on the target diffusion model performs multiple noise-adding processes on the latent vector to be processed using random Gaussian noise to obtain a noise latent vector.

[0009] In the denoising module based on the target diffusion model, at least one target embedding vector performs multiple denoising processes on the noise latent vector to obtain the target latent vector, and then decodes the target latent vector to obtain the target cigarette sample image.

[0010] The target cigarette sample image is a cigarette image with an appearance defect at the cigarette filter. At least one target embedding vector includes: a target defect embedding vector and / or a target mask embedding vector. The number of noise reduction and noise addition processes is the same.

[0011] According to another aspect of the present invention, a cigarette sample image generation apparatus is provided, the apparatus comprising:

[0012] The image acquisition module is used to acquire images of normal cigarettes to be processed;

[0013] The image encoding module is used to encode the image of a normal cigarette stick to be processed based on the target diffusion model to obtain the latent vector to be processed.

[0014] The vector noise module is used to perform multiple noise addition processes on the latent vector to be processed based on random Gaussian noise, according to the noise addition module of the target diffusion model, to obtain the noise latent vector.

[0015] The cigarette sample image generation module is used to perform multiple denoising processes on the noise latent vector by at least one target embedding vector in the denoising module based on the target diffusion model to obtain the target latent vector, and to decode the target latent vector to obtain the target cigarette sample image.

[0016] The target cigarette sample image is a cigarette image with an appearance defect at the cigarette filter. At least one target embedding vector includes: a target defect embedding vector and / or a target mask embedding vector. The number of noise reduction and noise addition processes is the same.

[0017] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0018] At least one processor; and

[0019] A memory that is communicatively connected to at least one processor; wherein,

[0020] The memory stores a computer program that can be executed by at least one processor, such that the at least one processor is able to perform the cigarette sample image generation method of any embodiment of the present invention.

[0021] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the cigarette sample image generation method of any embodiment of the present invention.

[0022] According to another aspect of the present invention, a computer program product is provided, comprising a computer program, characterized in that, when executed by a processor, the computer program implements a cigarette sample image generation method as described in any embodiment of the present invention.

[0023] The technical solution of this invention involves acquiring a normal cigarette image to be processed and encoding it according to a target diffusion model to obtain a latent vector to be processed. The target diffusion model's noise-adding module performs multiple noise-adding processes based on random Gaussian noise to obtain a noise latent vector. The target diffusion model's denoising module then performs multiple denoising processes on the noise latent vector using a target defect embedding vector and / or a target mask embedding vector to obtain a target latent vector. This allows defect features to be flexibly injected into the latent vector of the normal cigarette image. The obtained target latent vector is then decoded to obtain the target cigarette image. This achieves the generation of highly controllable and diverse defective cigarette sample images for a specified local area (cigarette filter). This invention solves the problems of scarce defective cigarette samples and insufficient diversity of defect morphology in existing technologies. By using at least one target embedding vector from the target diffusion model, the position and morphology of defects generated in the normal cigarette image to be processed can be flexibly controlled, improving the visual realism, diversity, and richness of defective cigarette sample images, providing broader and more feasible data support for subsequent cigarette defect detection.

[0024] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

[0025] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0026] Figure 1 This is a flowchart of a method for generating cigarette sample images provided in an embodiment of the present invention;

[0027] Figure 2 This is a training example diagram of the diffusion model of the application of the defect embedding vector to be used, provided in an embodiment of the present invention;

[0028] Figure 3 This is a flowchart illustrating the process of processing normal cigarette images using the target diffusion model provided in this embodiment of the invention.

[0029] Figure 4 This is a flowchart of a method for generating cigarette sample images provided in an embodiment of the present invention;

[0030] Figure 5This is a flowchart illustrating the process of determining supplementary cigarette sample images provided in an embodiment of the present invention;

[0031] Figure 6 This is a schematic diagram of the model structure of the YOLOv8-Seg model provided in an embodiment of the present invention;

[0032] Figure 7 This is a schematic diagram of the structure of a cigarette sample image generation device provided in an embodiment of the present invention;

[0033] Figure 8 This is a schematic diagram of the structure of an electronic device that implements the cigarette sample image generation method of this invention. Detailed Implementation

[0034] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0035] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0036] Example 1

[0037] Figure 1 This is a flowchart of a cigarette sample image generation method provided in Embodiment 1 of the present invention. This embodiment is applicable to situations where defect features are added to a normal cigarette image to be processed based on a target diffusion model to generate a target cigarette sample image with appearance defects at the cigarette filter. This method can be executed by a cigarette sample image generation device, which can be implemented in hardware and / or software. This cigarette sample image generation device can be configured in electronic devices such as mobile phones, computers, or servers. Figure 1 As shown, the method includes:

[0038] S110. Obtain the image of the normal cigarette stick to be processed.

[0039] Among them, the normal cigarette images to be processed can be cigarette images without any appearance defects.

[0040] Specifically, in order to obtain a sample image of a target cigarette with an appearance defect at the cigarette filter, an image of a normal cigarette to be processed can be obtained first, and then the normal cigarette image to be processed can be processed using a target diffusion model.

[0041] Optionally, before processing the normal cigarette images to be processed based on the target diffusion model, a target diffusion model can be trained first. Specifically, the following steps are taken: First, acquire multiple images of cigarettes with first defects, where each first defective cigarette image is an image of a cigarette with an appearance defect at the filter tip; perform feature extraction processing on the multiple first defective cigarette images to obtain defect embedding vectors to be optimized corresponding to the first defective cigarette images; apply the defect embedding vectors to be optimized and / or the mask embedding vectors to be optimized to the pre-trained diffusion model to obtain the diffusion model to be used; wherein the mask embedding vectors to be optimized are embedding vectors that adjust the shape of the defective region; for the multiple first defective cigarette images, process the first defective cigarette images based on the diffusion model to be used to obtain actual cigarette images; determine the denoising loss value based on the actual cigarette images and the first defective cigarette images; optimize the defect embedding vectors to be optimized and / or the mask embedding vectors to be optimized in the diffusion model to be used based on the denoising loss value to obtain the target diffusion model, wherein the target diffusion model is a diffusion model including at least one target embedding vector.

[0042] The first defective cigarette image can be an image of a cigarette with an appearance defect at the filter tip. Optionally, the first defective cigarette image can be an image of a defective cigarette captured by a camera device, or it can be a pre-stored image of a defective cigarette from a corresponding storage space. To ensure compatibility under different lighting, size, or imaging device conditions, multiple first defective cigarette images can be processed by image size unification, brightness and contrast normalization, or simple denoising operations to remove impurities and noise, etc., to obtain first defective cigarette images with consistent resolution, laying a data foundation for the subsequent training of the target diffusion model.

[0043] The defect embedding vector to be optimized can be the defect feature vector obtained by feature extraction from the first defective cigarette image. Optionally, to ensure the authenticity and accuracy of the defect embedding vector to be optimized, multiple first defective cigarette images can be obtained, and feature extraction processing can be performed on the multiple first defective cigarette images through a corresponding feature extraction model or feature extraction algorithm to obtain the defect embedding vector to be optimized.

[0044] The mask embedding vector to be optimized can be used to adjust the shape or size of the defect region. Optimizing the mask embedding vector can improve the diversity of defect size and shape in the generated actual cigarette images or target cigarette sample images, thus increasing the diversity and richness of the generated sample images. The pre-trained diffusion model can be a pre-trained diffusion model. The diffusion model to be used can be a pre-trained diffusion model that applies the defect embedding vector to be optimized and / or the mask embedding vector to be optimized.

[0045] The actual cigarette image can be obtained by performing multiple denoising and denoising processes on the first defective cigarette image using the diffusion model to be used, resulting in a cigarette image with an appearance defect at the cigarette filter. The denoising loss value can be used to characterize the degree of difference between the actual cigarette image and the first defective cigarette image. Optionally, if only the defect embedding vector to be optimized from the diffusion model to be used is applied to denoise the denoised latent vector corresponding to the first defective cigarette image, then when calculating the denoising loss value, it can be calculated only using the loss function corresponding to the defect embedding vector to be optimized. The loss function corresponding to the defect embedding vector to be optimized can be as follows:

[0046]

[0047] in, Let ε represent the denoising loss value corresponding to the defect embedding vector v to be optimized, and let ε represent random Gaussian noise. θ () represents the function to be used for denoising using the diffusion model, ε θ Let z represent the denoised latent vector. t Let v represent the latent vector of the diffusion step at time step t, where t represents the time step, v represents the embedding vector of the defect to be optimized, and ⊙ represents the element-wise multiplication operation. This is a defect mask used to emphasize the error contribution of defective regions. It's worth noting that when training a model using a diffusion model, a defect mask can be introduced to highlight the contribution of defective regions to the denoising loss value, making the learning of defect morphology by the diffusion model more focused. Defect Mask Corresponding to the image of the first defective cigarette. The defective region at the cigarette filter tip. Since the number of parameters in the defect embedding vector v is much smaller than that of the entire diffusion model to be used, the diffusion model to be used can converge quickly when the first defective cigarette image is limited, and can always focus on the defective region at the cigarette filter tip without overfitting other cigarette regions when training the diffusion model to be used.

[0048] Optionally, if only the mask embedding vector to be optimized from the diffusion model to be used is applied to denoise the noisy latent vector corresponding to the first defective cigarette image, then when calculating the denoising loss value, it can be calculated solely using the loss function corresponding to the mask embedding vector to be optimized. The loss function corresponding to the mask embedding vector to be optimized can be expressed as follows:

[0049]

[0050] in, Represents the embedding vector e of the mask to be optimized. m The corresponding denoising loss value, where ε represents random Gaussian noise. θ () represents the function to be used for denoising using the diffusion model, ε θ This represents the latent vector after denoising. Let e ​​represent the latent vector of the diffusion step at time step t, where t represents the time step. m This represents the mask embedding vector to be optimized. The target diffusion model may include a diffusion model of the target defect embedding vector and / or the target mask embedding vector.

[0051] Specifically, multiple images of first-defect cigarettes are acquired, and feature extraction processing is performed on these images to obtain defect embedding vectors to be optimized corresponding to the first-defect cigarette images. These defect embedding vectors and / or mask embedding vectors are then applied to a pre-trained diffusion model to obtain a diffusion model to be used, which is then trained based on the multiple first-defect cigarette images.

[0052] The specific training process can be as follows: The first defective cigarette image is encoded and subjected to multiple noise additions using the diffusion model to be used, resulting in a noisy latent vector. The noisy latent vector is then subjected to multiple denoising processes using the defect embedding vector and / or mask embedding vector to be optimized in the denoising module of the diffusion model to be used, resulting in the actual cigarette image. Based on the actual cigarette image and the first defective cigarette image, a denoising loss value is determined. This loss value is then used to optimize the defect embedding vector and / or mask embedding vector to be optimized in the diffusion model to be used, thereby obtaining the target diffusion model.

[0053] When optimizing the defect embedding vector and / or mask embedding vector in the diffusion model to be used using the loss value, the convergence of the loss function can be used as a training objective. This can be achieved by checking if the training error is less than a preset error, if the error change tends to stabilize, or if the current number of iterations equals a preset number. If convergence is detected, such as the training error of the loss function being less than the preset error, or the error change trend stabilizing, it indicates that the diffusion model to be used has been successfully trained, and iterative training can be stopped. If convergence has not been detected, other images of first-defect cigarettes can be acquired to continue training the diffusion model to be used until the training error of the loss function is within a preset range. When the training error of the loss function converges, the trained diffusion model to be used can be used as the target diffusion model.

[0054] For example, for a small number of images of cigarettes with first-order defects, a defect mask can be introduced during training to highlight the contribution of the defect region to the denoising loss value, making the learning of defect morphology by the diffusion model more focused. Simultaneously, optimizing only the defect embedding vector and / or the mask embedding vector, while freezing all other model parameters in the diffusion model, can avoid overfitting or convergence difficulties, thus characterizing the main features of cigarette filter defects in a low-dimensional space.

[0055] like Figure 2 As shown, Figure 2 This is a training example image for applying the defect embedding vector to the diffusion model to be used. It identifies the image of the cigarette with the first defect. Defect mask corresponding to the defect area at the cigarette filter tip Image of the first defective cigarette. The input is fed into the diffusion model to encode the first defective cigarette image. A noise-adding module then adds random Gaussian noise ε to the image, resulting in a noisy latent vector. The noisy latent vector is then denoised using the defect embedding vector to be optimized in the denoising module, yielding a denoised latent vector. Based on the denoised latent vector ε... θ Random Gaussian noise ε and defect mask Using the loss function corresponding to the defect embedding vector to be optimized, the denoising loss value is determined. The denoising loss value is then used to optimize the defect embedding vector in the diffusion model to be used, resulting in a target diffusion model that includes the target defect embedding vector.

[0056] Since the optimization process of the mask embedding vector to be optimized is similar to that of the defect embedding vector to be optimized, it will not be described again here. When the target mask embedding vector and the target defect embedding vector are obtained, the normal cigarette image to be processed can be processed based on the target diffusion model including the target mask embedding vector and / or the target defect embedding vector. This allows defect features to be flexibly injected into the latent vectors of the normal cigarette image. While preserving most of the normal texture of the normal cigarette image, defect features can be added to a specified local area (cigarette filter area) to generate highly controllable and highly diverse defective cigarette sample images.

[0057] S120. Encode the normal cigarette image to be processed based on the target diffusion model to obtain the latent vector to be processed.

[0058] The latent vector to be processed can be the feature vector after encoding the normal cigarette image to be processed.

[0059] Specifically, the target diffusion model is used to encode the normal cigarette image to be processed, thereby obtaining the latent vector to be processed.

[0060] For example, see Figure 3 , Figure 3 This is an example flowchart illustrating the processing flow of a normal cigarette image for a target diffusion model. (Image I of the normal cigarette image to be processed) n Encoding is performed to obtain the latent vector to be processed.

[0061] S130. The noise-adding module based on the target diffusion model performs multiple noise-adding processes on the latent vector to be processed based on random Gaussian noise to obtain a noise latent vector.

[0062] Random Gaussian noise can be understood as random noise that follows a Gaussian distribution. The noise latent vector can be the feature vector obtained by applying noise to the latent vector to be processed multiple times.

[0063] Specifically, the noise-adding module of the target diffusion model performs multiple noise-adding processes on the latent vector to be processed based on random Gaussian noise to obtain a noise latent vector.

[0064] For example, in conjunction with the above example, the latent vector to be processed is based on random Gaussian noise ε added by the noise-adding module. Noise is added progressively before time step T to obtain the noise latent vector.

[0065] S140. At least one target embedding vector in the denoising module based on the target diffusion model performs multiple denoising processes on the noise latent vector to obtain the target latent vector, and decodes the target latent vector to obtain the target cigarette sample image.

[0066] The target cigarette sample image is an image of a cigarette with an appearance defect at the filter tip. At least one target embedding vector includes a target defect embedding vector and / or a target mask embedding vector, with the number of denoising and noise-adding processes being the same. The target defect embedding vector is used to add defect features to the noise latent vector. The target mask embedding vector is used to control the shape or size of the defect region corresponding to the added defect features.

[0067] Specifically, the target defect embedding vector and / or target mask embedding vector in the denoising module based on the target diffusion model are used to denoise the noise latent vector multiple times to obtain the target latent vector. The target latent vector is then decoded to obtain a target cigarette sample image with an appearance defect at the cigarette filter, which is then used in the subsequent model training for cigarette filter defect detection.

[0068] In this embodiment of the invention, the method of performing multiple denoising processes on the noise latent vector by at least one target embedding vector in the denoising module based on the target diffusion model is as follows: when denoising the noise latent vector based on the denoising module, the noise latent vector corresponding to the target mask range is updated based on the target defect embedding vector and / or the target mask embedding vector to obtain the target latent vector.

[0069] The target mask range is used to characterize the defect area at the cigarette filter.

[0070] Specifically, when denoising the noise latent vector based on the denoising module, the noise latent vector corresponding to the target mask range can be updated according to the target defect embedding vector and / or the target mask embedding vector to obtain the target latent vector.

[0071] For example, in conjunction with the above example, in each denoising step that proceeds backward from 1 at time step t=T, a local editing strategy is adopted. That is, noise latent vectors that do not belong to the target mask range corresponding to the target defect mask are subjected to normal denoising processing, while noise latent vectors within the target mask range are processed using the target defect embedding vector v. * and target mask embedding vector The target latent vector is then updated, as shown in the following formula:

[0072]

[0073] Among them, z ' t-1 This indicates the use of the target defect embedding vector v * The denoising result after that. Represents the embedding vector of the target mask The generated target defect mask corresponds to the target mask range mentioned above, z t-1This represents the latent vector at time step t-1 after denoising. This represents the latent vector obtained by performing conventional diffusion denoising on the region outside the target mask range.

[0074] Based on this, it can be ensured that the cigarette filter area corresponding to the target mask range in the target cigarette sample image displays defect texture, while other areas retain a normal cigarette image. Through multiple denoising processes, the target latent vector z0 is obtained at t=0. Decoding the target latent vector z0 yields the target cigarette sample image.

[0075] The technical solution of this embodiment acquires a normal cigarette image to be processed and encodes it according to a target diffusion model to obtain a latent vector to be processed. The target diffusion model's noise-adding module performs multiple noise-adding processes based on random Gaussian noise to obtain a noise latent vector. The target diffusion model's denoising module then performs multiple denoising processes on the noise latent vector using a target defect embedding vector and / or a target mask embedding vector to obtain a target latent vector. This allows defect features to be flexibly injected into the latent vector of the normal cigarette image. The obtained target latent vector is then decoded to obtain the target cigarette image. This achieves the generation of highly controllable and diverse defective cigarette sample images for a specified local area (cigarette filter). This invention solves the problems of scarce defective cigarette samples and insufficient diversity of defect morphology in the prior art. By using at least one target embedding vector from the target diffusion model, the position and morphology of defects generated in the normal cigarette image to be processed can be flexibly controlled, improving the visual realism of the defective cigarette sample images, increasing their diversity, and enriching their content. This provides broader and more feasible data support for subsequent cigarette defect detection.

[0076] Example 2

[0077] Figure 4 This is a flowchart of a method for generating cigarette sample images according to Embodiment 2 of the present invention. This embodiment provides another way to generate defective cigarette sample images based on the above embodiments. Specific implementation details can be found in the technical solution of this embodiment. Technical terms that are the same as or corresponding to those in the above embodiments will not be repeated here. Figure 4 As shown, the method includes:

[0078] S210. Obtain the image of the second defective cigarette and perform image segmentation processing on the image of the second defective cigarette to obtain the defect foreground image.

[0079] The second defective cigarette image can be an image of a cigarette with an appearance defect at the cigarette filter. Optionally, the second defective cigarette image can be an image of a defective cigarette captured by a camera device, or it can be a defective cigarette image pre-stored in a corresponding storage space. The second defective cigarette image may or may not be the same as the first defective cigarette image. The defect foreground image can be an image of the defective area at the cigarette filter obtained using an image segmentation algorithm or image annotation processing.

[0080] Specifically, an image of the second defective cigarette is acquired, and at least one of the image processing methods, namely image segmentation algorithm, image segmentation mask, and image annotation processing, is used to perform image segmentation processing on the second defective cigarette image in order to extract the defect foreground and remove the cigarette background as much as possible to preserve the texture features of the defect itself, thereby obtaining the defect foreground image.

[0081] For example, see Figure 5 , Figure 5 A flowchart illustrating the process of determining supplementary cigarette sample images. Figure 5 In the image, the existing defective image corresponds to the second defective cigarette image. Image enhancement processing Aug1 is performed on the second defective cigarette image to obtain the enhanced cigarette image A. The second defective cigarette image is then processed to determine the corresponding image segmentation mask. Based on the image segmentation mask, image segmentation processing is performed on the enhanced cigarette image A to obtain the defective foreground image.

[0082] S220. Perform at least one image random transformation on the defective foreground image to obtain at least one derived foreground image.

[0083] The image random transformation process can include at least one of the following: exposure adjustment, sharpness adjustment, automatic contrast adjustment, tone adjustment, rotation, cropping, and translation. By employing at least one image random transformation process, defects that may occur in real-world cigarette production can be simulated from multiple angles and in multiple poses. The derived foreground image is an image of the defective area at the cigarette filter tip, obtained by adjusting the defective foreground image.

[0084] Specifically, to simulate the lighting conditions and geometric differences that may occur when actually capturing cigarette images, at least one image randomization process can be applied to the defective foreground image, including exposure adjustment, sharpness adjustment, contrast adjustment, tone adjustment, rotation, cropping, and translation, to obtain at least one derived foreground image. Based on this, derived foreground images with different appearances, positions, and deformations can be obtained, which helps to improve the diversity and randomness of supplementary cigarette sample images. This ensures that even with a limited number of real cigarette defect sample images, the coverage of defect morphology can be effectively expanded, providing a richer visual scene for subsequent defect detection training.

[0085] For example, in conjunction with the above example, the defective foreground image is processed by the Aug2 image enhancement process to obtain the derived foreground image R.

[0086] S230. For at least one derived foreground image, when the derived foreground image satisfies the positional constraint condition, the derived foreground image and the normal cigarette image to be processed are subjected to image synthesis processing to obtain a supplementary cigarette sample image.

[0087] The supplementary cigarette sample images are images of cigarettes with visible defects at the filter tip. Positional constraints can be the positional conditions that the derived foreground image must satisfy when combining the derived foreground image with the normal cigarette image to be processed.

[0088] Specifically, for at least one derived foreground image, the positional relationship between the derived foreground image and the normal cigarette image to be processed is used to determine whether the derived foreground image satisfies the positional constraints. If the derived foreground image satisfies the positional constraints, the derived foreground image and the normal cigarette image to be processed can be combined to obtain a supplementary cigarette image.

[0089] Optionally, the derived foreground image satisfying the positional constraint condition can be: determining the cross-union ratio (CUP) information between the derived foreground image and the filter mask image; wherein, the filter mask image is a mask image generated based on the filter region of the normal cigarette image to be processed; when the CUP information exceeds a preset CUP threshold, it is determined that the derived foreground image satisfies the positional constraint condition.

[0090] The filter mask image can be a pre-generated or labeled mask image corresponding to the filter area of ​​the cigarette in the image of the normal cigarette to be processed. The filter area refers to the region where the cigarette filter is located. Optionally, in the filter mask image, 1 indicates that it can be composited with the derived foreground image, and 0 indicates the cigarette background, i.e., it cannot be composited with the derived foreground image. The Cross-Union-Placement (CUP) information can be used to characterize the overlapping area between the derived foreground image and the filter mask image. The CUP information can avoid the problem of unqualified supplementary cigarette sample images caused by inappropriate positioning of the derived foreground image during image synthesis. For example, if the derived foreground image is too far out, the supplementary cigarette sample image cannot be properly defect-detected. The preset CUP threshold can be a pre-set standard value for the CUP information. Optionally, the preset CUP threshold can be 0.5.

[0091] Specifically, the filter area of ​​the normal cigarette image to be processed can be masked to determine a filter mask image corresponding to the filter area. This filter mask image allows the derived foreground image to be accurately pasted onto the cigarette filter area of ​​the normal cigarette image to be processed. That is, when performing image compositing between the derived foreground image and the normal cigarette image to be processed, the intersection-over-union (IoU) ratio between the derived foreground image and the filter mask image is determined. If the IoU ratio is greater than a preset IoU threshold, the derived foreground image and the normal cigarette image to be processed can be composited to obtain a supplementary cigarette sample image. Conversely, if the IoU ratio does not exceed the preset IoU threshold, the position of the derived foreground image is readjusted until the IoU ratio between the derived foreground image and the normal cigarette image to be processed exceeds the preset IoU threshold, at which point the derived foreground image and the normal cigarette image to be processed are composited to obtain a supplementary cigarette sample image.

[0092] For example, in conjunction with the above examples, Figure 5 The target region in the image corresponds to the aforementioned filter mask image. The derived foreground image R is subjected to positional constraint processing using the filter mask image. The positionally constrained derived foreground image is then binarized and inverted to obtain the inverted derived foreground image. When the intersection-over-union (IoU) ratio between the inverted derived foreground image and the filter mask image exceeds a preset IoU threshold, the inverted derived foreground image and the normal cigarette image to be processed are combined to obtain a supplementary sample cigarette image.

[0093] Optionally, when performing image synthesis processing on the derived foreground image and the normal cigarette image to be processed, the pixel information of the derived foreground image and the normal cigarette image to be processed is adjusted based on a preset transparency parameter to obtain a supplementary cigarette sample image.

[0094] The preset transparency parameter, also known as the transparency fusion parameter, is used to adjust the pixel information of the derived foreground image and the normal cigarette image to be processed, so as to adjust the transition strength between the defect edge and the cigarette background, making the generated supplementary cigarette sample image more realistic.

[0095] Specifically, in order to improve the realism of the supplementary cigarette sample image, the pixel information of the derived foreground image and the normal cigarette image to be processed can be adjusted based on a preset transparency parameter when performing image synthesis processing on the derived foreground image and the normal cigarette image to be processed, so as to obtain the supplementary cigarette sample image.

[0096] For example, Figure 5 In this context, β represents a preset transparency parameter. After constraining the position of the derived foreground image R using the filter mask image, the position-constrained derived foreground image and the normal cigarette image to be processed can be further processed based on the preset transparency parameter. Finally, the derived foreground image processed by the preset transparency parameter and the normal cigarette image to be processed are combined to obtain supplementary cigarette sample images. Based on this processing, hundreds or even thousands of new supplementary cigarette sample images can be obtained in a short time, significantly expanding the quantity and diversity of defective samples.

[0097] Optionally, embodiments of the present invention further include: performing evaluation processing on the target cigarette sample image and / or supplementary cigarette sample image under at least one index based on a preset detection model, so that when the evaluation result meets preset conditions, the target cigarette sample image and / or supplementary cigarette sample image are used as usable cigarette sample images.

[0098] The preset detection model can be a defect detection model used to evaluate the target cigarette sample image and / or supplementary cigarette sample images. Optionally, the preset detection model can be a YOLOv8-Seg model or a Transformer-based detection network model, etc. The model structure of the YOLOv8-Seg model can be as follows: Figure 6 As shown. At least one metric can be the detection rate, precision, recall, average precision, etc., determined by the preset detection model processing the target cigarette sample image and / or supplementary cigarette sample images. The evaluation result meets the preset conditions, meaning that the detection rate, precision, recall, average precision, etc., determined by the preset detection model for the target cigarette sample image and / or supplementary cigarette sample images are superior to the detection rate, precision, recall, average precision, etc., determined by the preset detection model for processing the first defective cigarette image or the second defective cigarette image. The cigarette sample images that can be used are sample images that can be used to subsequently train relevant models for cigarette filter defect detection.

[0099] Specifically, the target cigarette sample image and / or supplementary cigarette sample image are evaluated under at least one indicator according to a preset detection model to obtain an evaluation result. If the evaluation result under at least one indicator determined by the preset detection model in processing the target cigarette sample image and / or supplementary cigarette sample image is better than the benchmark evaluation result under at least one indicator determined by the preset detection model in processing the first defective cigarette image or the second defective cigarette image, the evaluation result is determined to meet a preset condition. When the evaluation result meets the preset condition, the target cigarette sample image and / or supplementary cigarette sample image are used as usable cigarette sample images.

[0100] For example, the YOLOv8-Seg model is used as the preset detection model for illustration. The generated target cigarette sample images and / or supplementary cigarette sample images are divided into training and testing sets according to a certain ratio. The cigarette sample images in the training set are input into the YOLOv8-Seg model for multiple iterations of training. During testing based on the testing set, indicators such as detection rate, precision, recall, and average precision are quantified to obtain the corresponding evaluation results. When the evaluation result of at least one indicator corresponding to the target cigarette sample image and / or supplementary cigarette sample image is better than the benchmark evaluation result of the indicator corresponding to the real defective cigarette image, the target cigarette sample image and / or supplementary cigarette sample image are used as usable cigarette sample images.

[0101] It should be noted that using both target cigarette sample images and supplementary cigarette sample images as available cigarette sample images for subsequent training of the cigarette filter defect detection model is beneficial in the case of small sample sizes. It can simultaneously increase the number and diversity of defective cigarette sample images, further enhance the generalization ability of the detection model, and thus effectively improve the cigarette filter defect detection effect.

[0102] The technical solution of this embodiment involves acquiring a second defective cigarette image and performing image segmentation on it to obtain a defective foreground image. The defective foreground image undergoes at least one image random transformation to obtain at least one derived foreground image, providing image support for subsequently improving the diversity and randomness of supplementary cigarette sample images. For at least one derived foreground image, when the derived foreground image meets positional constraints, image synthesis processing is performed between the derived foreground image and the normal cigarette image to be processed to obtain a supplementary cigarette sample image. This invention solves the problems of scarce defective cigarette samples and insufficient diversity of defect morphology in the prior art. By generating derived foreground images and performing image synthesis processing between the derived foreground images and the normal cigarette images to be processed when the derived foreground images meet positional constraints, the generation efficiency and image clarity of supplementary cigarette sample images can be effectively improved, enhancing the visual realism of defective cigarette sample images, increasing the diversity of defective cigarette sample images, enriching the defective cigarette sample imagery, and providing broader and more feasible data support for subsequent cigarette defect detection.

[0103] Example 3

[0104] Figure 7 This is a schematic diagram of the structure of a cigarette sample image generation device provided in Embodiment 3 of the present invention. Figure 7 As shown, the device includes: an image acquisition module 310, an image encoding module 320, a vector noise addition module 330, and a cigarette sample image generation module 340.

[0105] Image acquisition module 310 is used to acquire a normal cigarette image to be processed; image encoding module 320 is used to encode the normal cigarette image to be processed based on the target diffusion model to obtain the latent vector to be processed; vector denoising module 330 is used to perform multiple denoising processes on the latent vector to be processed based on random Gaussian noise by the denoising module of the target diffusion model to obtain a noise latent vector; cigarette sample image generation module 340 is used to perform multiple denoising processes on the noise latent vector based on at least one target embedding vector in the denoising module of the target diffusion model to obtain a target latent vector, and decode the target latent vector to obtain a target cigarette sample image; wherein, the target cigarette sample image is a cigarette image with an appearance defect at the cigarette filter, and at least one target embedding vector includes: a target defect embedding vector and / or a target mask embedding vector, and the number of denoising processes and denoising processes is the same.

[0106] The technical solution of this embodiment acquires a normal cigarette image to be processed and encodes it according to a target diffusion model to obtain a latent vector to be processed. The target diffusion model's noise-adding module performs multiple noise-adding processes based on random Gaussian noise to obtain a noise latent vector. The target diffusion model's denoising module then performs multiple denoising processes on the noise latent vector using a target defect embedding vector and / or a target mask embedding vector to obtain a target latent vector. This allows defect features to be flexibly injected into the latent vector of the normal cigarette image. The obtained target latent vector is then decoded to obtain the target cigarette image. This achieves the generation of highly controllable and diverse defective cigarette sample images for a specified local area (cigarette filter). This invention solves the problems of scarce defective cigarette samples and insufficient diversity of defect morphology in the prior art. By using at least one target embedding vector from the target diffusion model, the position and morphology of defects generated in the normal cigarette image to be processed can be flexibly controlled, improving the visual realism of the defective cigarette sample images, increasing their diversity, and enriching their content. This provides broader and more feasible data support for subsequent cigarette defect detection.

[0107] Optionally, based on the above embodiments, the device further includes: a target diffusion model determination module, configured to acquire multiple first defective cigarette images, wherein the first defective cigarette images are cigarette images with appearance defects at the cigarette filter; perform feature extraction processing on the multiple first defective cigarette images to obtain a defect embedding vector to be optimized corresponding to the first defective cigarette image; apply the defect embedding vector to be optimized and / or the mask embedding vector to be optimized to a pre-trained diffusion model to obtain a diffusion model to be used; wherein the mask embedding vector to be optimized is an embedding vector for adjusting the shape of the defective region; for the multiple first defective cigarette images, process the first defective cigarette images based on the diffusion model to be used to obtain actual cigarette images; determine a denoising loss value based on the actual cigarette image and the first defective cigarette image; optimize the defect embedding vector to be optimized and / or the mask embedding vector to be optimized in the diffusion model to be used based on the denoising loss value to obtain a target diffusion model, wherein the target diffusion model is a diffusion model including at least one target embedding vector.

[0108] Optionally, the cigarette sample image generation module includes: a vector denoising unit, used to update the noise latent vector corresponding to the target mask range based on the target defect embedding vector and / or the target mask embedding vector when the noise latent vector is denoised based on the denoising module, so as to obtain the target latent vector.

[0109] Optionally, the device further includes: a supplementary cigarette sample image generation module, comprising: a defective foreground image determination unit, used to acquire a second defective cigarette image and perform image segmentation processing on the second defective cigarette image to obtain a defective foreground image; an image transformation processing unit, used to perform at least one image random transformation processing on the defective foreground image to obtain at least one derived foreground image; and an image synthesis processing unit, used to perform image synthesis processing on the derived foreground image and the normal cigarette image to be processed when the derived foreground image satisfies the positional constraint condition, to obtain a supplementary cigarette sample image.

[0110] Optionally, the image synthesis processing unit includes: a derived foreground image determination subunit, used to determine the cross-union ratio (CUP) information between the derived foreground image and the filter mask image; wherein, the filter mask image is a mask image generated based on the filter region of the normal cigarette image to be processed; when the CUP information exceeds a preset CUP threshold, it is determined that the derived foreground image meets the position constraint condition.

[0111] Optionally, the image synthesis processing unit further includes a pixel information adjustment subunit, used to adjust the pixel information of the derived foreground image and the normal cigarette image to be processed based on a preset transparency parameter when performing image synthesis processing on the derived foreground image and the normal cigarette image to be processed, so as to obtain a supplementary cigarette sample image.

[0112] Optionally, the device further includes: a sample image evaluation module, used to evaluate the target cigarette sample image and / or supplementary cigarette sample image under at least one index based on a preset detection model, so that when the evaluation result meets the preset conditions, the target cigarette sample image and / or supplementary cigarette sample image can be used as a cigarette sample image.

[0113] The cigarette sample image generation device provided in this embodiment of the invention can execute the cigarette sample image generation method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the method.

[0114] Example 4

[0115] Figure 8This is a schematic diagram of the structure of an electronic device provided in Embodiment 4 of the present invention. The electronic device 10 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0116] like Figure 8 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0117] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0118] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as the cigarette sample image generation method.

[0119] In some embodiments, the cigarette sample image generation method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the cigarette sample image generation method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the cigarette sample image generation method by any other suitable means (e.g., by means of firmware).

[0120] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0121] The computer program for implementing the cigarette sample image generation method of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to the processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program can be executed entirely on the machine, partially on the machine, as a standalone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0122] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication unit 19, or installed from storage unit 18, or installed from ROM 12. When the computer program is executed by processor 11, it performs the functions defined in the methods of the embodiments of the present invention.

[0123] Example 5

[0124] Embodiment 5 of the present invention also provides a computer-readable storage medium storing computer instructions for causing a processor to execute a method for generating a cigarette sample image, the method comprising:

[0125] A normal cigarette image to be processed is acquired; the normal cigarette image to be processed is encoded based on a target diffusion model to obtain a latent vector to be processed; a noise-adding module based on the target diffusion model adds noise to the latent vector to be processed multiple times based on random Gaussian noise to obtain a noise latent vector; at least one target embedding vector in the denoising module based on the target diffusion model performs denoising on the noise latent vector multiple times to obtain a target latent vector, and decodes the target latent vector to obtain a target cigarette sample image; wherein, the target cigarette sample image is a cigarette image with an appearance defect at the cigarette filter, and at least one target embedding vector includes: a target defect embedding vector and / or a target mask embedding vector, and the number of denoising and noise-adding processes is the same.

[0126] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0127] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0128] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0129] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through a communication network. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.

[0130] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0131] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A method of generating a cigarette sample image, the method comprising: The method comprises: obtaining a to-be-processed normal cigarette image; encoding the to-be-processed normal cigarette image based on a target diffusion model to obtain a to-be-processed latent vector; performing multiple noise adding processes on the to-be-processed latent vector based on a noise adding module of the target diffusion model according to random Gaussian noise to obtain a noise latent vector; performing multiple denoising processes on the noise latent vector based on at least one target embedding vector in a denoising module of the target diffusion model to obtain a target latent vector, and decoding the target latent vector to obtain a target cigarette sample image; wherein the target cigarette sample image is a cigarette image with an appearance defect at a cigarette filter, the at least one target embedding vector comprises a target defect embedding vector and / or a target mask embedding vector, and the number of denoising processes and the number of noise adding processes are consistent.

2. The method of claim 1, wherein, The method further comprises: obtaining a plurality of first defect cigarette images, wherein the first defect cigarette image is a cigarette image with an appearance defect at a cigarette filter; performing feature extraction processing on a plurality of the first defect cigarette images to obtain a to-be-optimized defect embedding vector corresponding to the first defect cigarette image; applying the to-be-optimized defect embedding vector and / or a to-be-optimized mask embedding vector to a pre-trained diffusion model to obtain a to-be-used diffusion model; wherein the to-be-optimized mask embedding vector is an embedding vector for adjusting the morphology of a defect region; for a plurality of the first defect cigarette images, processing the first defect cigarette image based on the to-be-used diffusion model to obtain an actual cigarette image; based on the actual cigarette image and the first defect cigarette image, determining a denoising loss value; based on the denoising loss value, optimizing the to-be-optimized defect embedding vector and / or the to-be-optimized mask embedding vector in the to-be-used diffusion model to obtain a target diffusion model, wherein the target diffusion model is a diffusion model comprising at least one target embedding vector.

3. The method of claim 1, wherein, The method further comprises: based on the denoising module, updating the noise latent vector corresponding to the target mask range based on the target defect embedding vector and / or the target mask embedding vector to obtain a target latent vector.

4. The method of claim 1, wherein, The method further comprises: obtaining a second defect cigarette image and performing image segmentation processing on the second defect cigarette image to obtain a defect foreground image; performing at least one image random transformation process on the defect foreground image to obtain at least one derived foreground image; for the at least one derived foreground image, when the derived foreground image satisfies a position constraint condition, performing image synthesis processing on the derived foreground image and the to-be-processed normal cigarette image to obtain a supplemented cigarette sample image.

5. The method of claim 4, wherein, The derived foreground image satisfies the position constraint condition, comprising: determining intersection and union ratio information between the derived foreground image and a filter mask image; wherein the filter mask image is a mask image generated based on a filter region of the to-be-processed normal cigarette image; When the intersection-over-union information exceeds a preset intersection-over-union threshold, it is determined that the derived foreground image meets a position constraint condition.

6. The method of claim 4, wherein, The method further includes: When performing image synthesis processing on the derived foreground image and the normal cigarette image to be processed, adjusting pixel information of the derived foreground image and the normal cigarette image to be processed based on a preset transparency parameter to obtain a supplemented cigarette sample image.

7. The method according to claim 1 or 4, characterized in that, The method further includes: Based on a preset detection model, performing evaluation processing on the target cigarette sample image and / or the supplemented cigarette sample image under at least one index, so as to use the target cigarette sample image and / or the supplemented cigarette sample image as a usable cigarette sample image when the evaluation result meets a preset condition.

8. A cigarette sample image generating apparatus, characterized by comprising: Comprise: An image acquisition module configured to acquire a normal cigarette image to be processed; An image encoding module configured to encode the normal cigarette image to be processed based on a target diffusion model to obtain a processed latent vector; A vector noise adding module configured to add noise to the processed latent vector based on a noise adding module of the target diffusion model according to random Gaussian noise multiple times to obtain a noise latent vector; A cigarette sample image generation module configured to perform denoising processing on the noise latent vector based on at least one target embedding vector in a denoising module of the target diffusion model multiple times to obtain a target latent vector, and to perform decoding processing on the target latent vector to obtain a target cigarette sample image; The target cigarette sample image is a cigarette image with an appearance defect at a cigarette filter, the at least one target embedding vector comprises a target defect embedding vector and / or a target mask embedding vector, and the number of times of denoising processing and noise adding processing is consistent.

9. An electronic device, comprising: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the cigarette sample image generation method of any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions for enabling the processor to execute the cigarette sample image generation method of any one of claims 1-7 when executed by the processor. The computer readable storage medium stores computer instructions for enabling the processor to execute the cigarette sample image generation method of any one of claims 1-7 when executed by the processor.