A model training commodity image light enhancement data processing method, device, equipment and medium

By performing positive and negative light enhancement processing on the product mask image and combining it with random mixed intensity to generate light feature gradients, the problem of the lack of product light features and light feature gradients in the FLUX.1-Kontext model is solved, and the model's light adaptation ability is improved.

CN122156026APending Publication Date: 2026-06-05XIAMEN ZIXUN INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
XIAMEN ZIXUN INFORMATION TECHNOLOGY CO LTD
Filing Date
2026-01-31
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

In the existing technology, the FLUX.1-Kontext model lacks training samples of commodity lighting features, existing data augmentation techniques are not targeted enough, fixed mixing intensity leads to the loss of lighting feature gradients, and the model's adaptability is insufficient.

Method used

By focusing on the product mask to perform positive and negative light enhancement, and combining random mixing intensity to generate light feature gradients, image processing algorithms are used to perform positive and negative light enhancement processing on the product mask image, and the final dataset is generated through checksum mixing.

Benefits of technology

We provide high-quality product and diverse lighting feature training samples for the FLUX.1-Kontext model, which solves the problem of lighting non-adaptability and improves the model's lighting adaptability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122156026A_ABST
    Figure CN122156026A_ABST
Patent Text Reader

Abstract

The application provides a commodity image light enhancement data processing method, device and equipment and medium for model training. The method comprises the following steps: S10, obtaining a commodity white background image and a commodity category, performing cutout, size processing and commodity removal processing on the commodity white background image to obtain a commodity mask image; S20, performing forward light enhancement processing and negative light enhancement processing on the commodity mask image respectively by using an image processing algorithm, and outputting a bidirectional light enhancement image; S30, performing pixel ratio checking and edge integrity checking on the bidirectional light enhancement image; adjusting the enhancement parameters of the bidirectional light enhancement image that fails to pass the checking and re-performing the processing of S20 until passing the checking; outputting a valid mask; S40, generating a random mixing intensity value for each valid mask; and performing layer mixing on the valid mask and the corresponding commodity white background image based on the random mixing intensity value to generate a final data set.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision data augmentation technology, and in particular to a method, apparatus, device, and medium for processing product image light enhancement data for model training. Background Technology

[0002] The FLUX.1-Kontext model (developed by Black Forest Labs) is a mainstream scene generation and diffusion model, often used in e-commerce to generate "product display images with context" from "white background images of products" (e.g., generating a scene image of a phone on an office desktop from a white background image of a phone) to improve product marketing effectiveness. However, existing technologies have the following key technical issues when preparing training data for this model, causing the generated products to fail to adaptively match the scene lighting: 1. The FLUX.1-Kontext model lacks training samples for product lighting features. The default training data for the FLUX.1-Kontext model consists mostly of natural scene images (such as landscapes and people), and does not include targeted samples of "product white background images + scene lighting features". The background of the product white background image is pure white, without any information on lighting changes. When used directly for model training, the model cannot learn the appearance changes of the product under different scene lighting (such as strong light, weak light, warm light and shadow). For example, after training with a pure white background image of a mobile phone, when the model generates a mobile phone image in an "outdoor strong light scene", the mobile phone still retains the "cold white light texture" of the white background image, which conflicts with the "warm tone + highlight reflection" features of the scene's strong light, resulting in a strong visual incongruity. 2. Existing data augmentation technologies are not sufficiently targeted at product masks. Existing data augmentation tools (such as Albumentations and TorchVision) have two core shortcomings that prevent them from meeting the product training requirements of FLUX.1-Kontext: Enhancement of object bias: Light enhancement is often performed on the entire image (such as adjusting the exposure and contrast of the entire image). However, the product in the white background image is processed by cutting out the scene image from the training data pair. The product carries the original scene's light (for further explanation: the training data are paired, product white background image - product scene image. The product white background image is cut out from the scene image). The whole image enhancement will cause the background light features to interfere with the product area - the model will mislearn "the light on the product remains unchanged" instead of "the light features of the product itself". When the scene image is generated later, the product still carries "the original background light residue". Incomplete coverage of lighting dimensions: It only supports light enhancement in a single direction (such as only increasing exposure) and lacks differentiated lighting coverage in "positive-negative" directions. It cannot simulate the diverse lighting common in e-commerce scenarios, such as "strong light (such as window spotlights)" and "weak light (such as warehouse environment)", which results in the model being able to adapt to only a single lighting scenario and having weak generalization ability. 3. Fixed mixing intensity leads to loss of light characteristic gradient. Some enhancement techniques attempt to blend the enhanced image with the original image, but using a fixed blending intensity (e.g., 0.5) fails to simulate light interference of varying intensities (e.g., "slightly strong light" or "severely weak light"). The FLUX.1-Kontext model requires "light intensity gradient" samples (continuous light features from low to high intensity) to learn adaptive capabilities. A fixed intensity results in a "single dimension of light features" in the training data, causing a sharp drop in the model's ability to adapt to lighting conditions in scenes with intensities other than those trained for. Summary of the Invention

[0003] The technical problem to be solved by the present invention is to provide a method, apparatus, device and medium for processing commodity image light enhancement data for model training, which solves the problems of lack of commodity light samples, insufficient enhancement targeting, fixed mixing intensity and lack of model adaptation in the existing technology. In a first aspect, the present invention provides a method for processing product image light enhancement data for model training, comprising the following steps: S10. Obtain the product white background image and product category, and perform image cutout, size processing and product removal processing on the product white background image to obtain the product mask image; S20. The product mask image is subjected to positive light enhancement processing and negative light enhancement processing respectively using image processing algorithms, and a bidirectional light enhancement image is output. S30: Perform pixel ratio verification and edge integrity verification on the bidirectional light enhancement map; adjust the enhancement parameters of the bidirectional light enhancement map that fails the verification and repeat the processing of S20 until the verification is passed; output a valid mask; S40. Generate a random blending intensity value for each valid mask; based on the random blending intensity value, blend the valid mask with the corresponding product white background image to generate the final dataset. Secondly, the present invention provides a product image light enhancement data processing device for model training, comprising the following modules: The white background image processing module obtains the white background image of the product and the product category, performs image cutout, size processing, and sets product removal processing on the white background image of the product to obtain the product mask image; The bidirectional light enhancement module uses image processing algorithms to perform positive light enhancement processing and negative light enhancement processing on the product mask image, and outputs a bidirectional light enhancement image; The verification module performs pixel ratio verification and edge integrity verification on the bidirectional light enhancement map; adjusts the enhancement parameters of the bidirectional light enhancement map that fails the verification and re-processes S20 until the verification is passed; and outputs a valid mask. The layer blending module generates a random blending intensity value for each valid mask; based on the random blending intensity value, the valid mask is blended with the corresponding product white background image to generate the final dataset. Thirdly, the present invention provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method described in the first aspect. Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in the first aspect. One or more technical solutions provided by this invention have at least the following technical effects or advantages: Focusing on the product mask (rather than the entire image), positive and negative light enhancements are performed. Data quality is ensured through batch processing verification. Light feature gradients are generated by combining random mixed intensities. Finally, the model is adapted to the FLUX.1-Kontext model format and annotation requirements, providing the model with high-quality training samples of "product + diverse light features" and solving the problem of non-adaptive lighting when generating product scenes. The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description The present invention will be further described below with reference to the accompanying drawings and embodiments. Figure 1 This is a flowchart of the method in Embodiment 1 of the present invention; Figure 2 This is a schematic diagram of the device in Embodiment 2 of the present invention. Detailed Implementation This application provides a method, apparatus, device, and medium for processing commodity image lighting enhancement data for model training, overcoming the shortcomings of existing image generation models such as lack of commodity lighting samples, insufficient enhancement targeting, fixed mixing intensity, and lack of model adaptation. Example 1 like Figure 1As shown, this embodiment provides a method for processing product image light enhancement data for model training, including the following steps: S10. Obtain the product white background image and product category, and perform image cutout, size processing and product removal processing on the product white background image to obtain the product mask image; S20. The product mask image is subjected to positive light enhancement processing and negative light enhancement processing respectively using image processing algorithms, and a bidirectional light enhancement image is output. S30: Perform pixel ratio verification and edge integrity verification on the bidirectional light enhancement map; adjust the enhancement parameters of the bidirectional light enhancement map that fails the verification and repeat the processing of S20 until the verification is passed; output a valid mask; S40. Generate a random blending intensity value for each valid mask; based on the random blending intensity value, blend the valid mask with the corresponding product white background image to generate the final dataset. Specifically, S10 is: S11. Obtain a product background image with a pure white background, and perform image matting using the Birefnet algorithm. Set the pixel value of the product area in the product background image to 255 and the pixel value of the background area to 0 to generate a matting mask image. S12. Use bilinear interpolation algorithm to uniformly scale the product white background image and the cutout mask image to a preset size; S13. Calculate the pixel percentage of the product area in the scaled-down cutout mask. If the pixel percentage is less than 10%, remove the corresponding product background image and cutout mask. If the pixel percentage is greater than 10%, output the product mask. Specifically, S20 is: S21. Using OpenCV's image processing algorithm, perform positive light enhancement processing on the product mask image to simulate product features under strong light illumination; S211. Call the cv2.convertScaleAbs function to increase the brightness of the product mask image by 10%, thereby increasing the exposure value by 1; S212. Call the cv2.addWeighted function to increase the contrast of the product mask image by 10; S213. Convert the product mask image to the HSV color space, and perform a brightness reduction of 5 on the highlight areas with pixel values ​​greater than 200 in the V channel. S214. Perform a brightness increment of 10 operation on the shadow areas in the V channel where the pixel value is less than 50; S215. Adjust the white threshold of the V channel to 250 and the black threshold to 5; S216. Call the cv2.Laplacian function to perform a 3×3 kernel Laplacian filter on the product mask image to achieve texture enhancement 5; S217. Convert the product mask image back to BGR format to obtain a positively enhanced mask; S22. Using an image processing algorithm based on OpenCV, negative light enhancement processing is performed on the product mask image to simulate product features under low light illumination. S221. Call the cv2.convertScaleAbs function to reduce the brightness of the product mask image by 10%, thereby reducing the exposure value by 1. S222. Call the cv2.addWeighted function to reduce the contrast of the product mask image by 10. S223. Convert the product mask image to the HSV color space, and perform a brightness increase of 5 operation on the highlight areas with pixel values ​​greater than 200 in the V channel. S224. Perform a brightness reduction operation of 10 on the shadow areas in the V channel where the pixel value is less than 50; S225. Adjust the white threshold of the V channel to 255 and the black threshold to 0; S226. Call the cv2.GaussianBlur function to apply a 5×5 kernel Gaussian blur with σ=2.0 to the product mask image to reduce texture. S227. Convert the product mask image back to BGR format to obtain a negative enhancement mask; S23. Store the positive enhancement mask and the negative enhancement mask as a bidirectional optical enhancement map. Specifically, S30 is: S31. Perform pixel ratio verification on the bidirectional light enhancement image, calculate the pixel ratio of the product area in the product mask image and the bidirectional light enhancement image respectively. If the pixel ratio of the product area in the bidirectional light enhancement image is less than 0.8 times the pixel ratio of the original product area in the product mask image, then the bidirectional light enhancement image verification is determined to be unsuccessful. S32. Perform edge integrity verification on the bidirectional light enhancement map. Perform Canny edge detection on the product mask map and the bidirectional light enhancement map respectively, and calculate the edge overlap between the product mask map and the bidirectional light enhancement map. If the edge overlap is less than 0.75, the bidirectional light enhancement map verification is determined to be unsuccessful. S33. For bidirectional light enhancement maps that fail the verification, adjust the parameters according to the set adjustment values ​​and re-execute step S20. If it still fails after re-execution twice, record it as an unrepairable invalid mask and end the step. S34. Record the verified bidirectional optical enhancement pattern as a valid mask; Specifically, S40 is: S41. Generate a random mixing intensity value for each valid mask; S42. Based on the random mixing intensity value, the effective mask and the product white background image are mixed using the cv2.addWeighted function to generate the final dataset. Based on the same inventive concept, this application also provides an apparatus corresponding to the method in Embodiment 1, as detailed in Embodiment 2. Example 2 like Figure 2 As shown, this embodiment provides a product image light enhancement data processing device for model training, including the following modules: The white background image processing module obtains the white background image of the product and the product category, performs image cutout, size processing, and sets product removal processing on the white background image of the product to obtain the product mask image; The bidirectional light enhancement module uses image processing algorithms to perform positive light enhancement processing and negative light enhancement processing on the product mask image, and outputs a bidirectional light enhancement image; The verification module performs pixel ratio verification and edge integrity verification on the bidirectional light enhancement map; adjusts the enhancement parameters of the bidirectional light enhancement map that fails the verification and re-processes S20 until the verification is passed; and outputs a valid mask. The layer blending module generates a random blending intensity value for each valid mask; based on the random blending intensity value, the valid mask is blended with the corresponding product white background image to generate the final dataset. The white background image processing module specifically includes: The image matting unit acquires a product background image with a pure white background and performs image matting using the Birefnet algorithm. The pixel values ​​of the product area in the product background image are set to 255, and the pixel values ​​of the background area are set to 0, generating a matting mask image. The scaling unit uses a bilinear interpolation algorithm to uniformly scale the product white background image and the cutout mask image to a preset size; The product removal unit calculates the pixel percentage of the product area in the scaled cutout mask image. If the pixel percentage is less than 10%, the corresponding product background image and cutout mask image are removed. If the pixel percentage is greater than 10%, the product mask image is output. The bidirectional light enhancement module is specifically: The forward light enhancement unit uses OpenCV's image processing algorithm to perform forward light enhancement processing on the product mask image to simulate the product features under strong light illumination; The positive exposure value subunit calls the cv2.convertScaleAbs function to increase the brightness of the product mask image by 10%, thereby increasing the exposure value by 1; The positive contrast subunit calls the cv2.addWeighted function to increase the contrast of the product mask image by 10; The positive specular subunit converts the product mask image to the HSV color space and performs a brightness reduction of 5 operation on the specular areas with pixel values ​​greater than 200 in the V channel. The positive shadow sub-unit performs a brightness increment operation of 10 on shadow areas with pixel values ​​less than 50 in the V channel; For the positive V-channel sub-unit, adjust the white threshold of the V-channel to 250 and the black threshold to 5; The positive texture enhancement subunit calls the cv2.Laplacian function to perform a 3×3 kernel Laplacian filter on the product mask image to achieve texture enhancement 5; The forward output subunit converts the product mask image back to BGR format to obtain a forward enhanced mask; The negative light enhancement unit uses an OpenCV-based image processing algorithm to perform negative light enhancement processing on the product mask image to simulate product features under low light illumination. The negative exposure value subunit calls the cv2.convertScaleAbs function to reduce the brightness of the product mask image by 10%, thereby reducing the exposure value by 1. The negative contrast sub-unit calls the cv2.addWeighted function to reduce the contrast of the product mask image by 10. The negative highlight subunit converts the product mask to the HSV color space and performs a brightness increase of 5 operation on the highlight areas with pixel values ​​greater than 200 in the V channel. The negative shadow sub-unit performs a brightness reduction operation of 10 on shadow areas with pixel values ​​less than 50 in the V channel; For the negative V channel sub-unit, adjust the white threshold of the V channel to 255 and the black threshold to 0; The negative texture reduction subunit calls the cv2.GaussianBlur function to perform a 5×5 kernel Gaussian blur on the product mask image to achieve texture reduction. The negative output subunit converts the product mask image back to BGR format to obtain a negative enhancement mask; The storage unit stores the positive enhancement mask and the negative enhancement mask as a bidirectional light enhancement map. The verification module is specifically as follows: The pixel ratio verification unit performs pixel ratio verification on the bidirectional light enhancement image, calculates the pixel ratio of the product area in the product mask image and the bidirectional light enhancement image respectively. If the pixel ratio of the product area in the bidirectional light enhancement image is less than 0.8 times the pixel ratio of the original product area in the product mask image, the bidirectional light enhancement image verification is determined to be unsuccessful. The edge integrity verification unit performs edge integrity verification on the bidirectional light enhancement map, performs Canny edge detection on the product mask map and the bidirectional light enhancement map respectively, and calculates the edge overlap between the product mask map and the bidirectional light enhancement map. If the edge overlap is less than 0.75, the bidirectional light enhancement map verification is determined to be unsuccessful. If the processing unit fails, for bidirectional light enhancement maps that fail the verification, adjust the parameters according to the set adjustment values ​​and re-execute step S20. If it still fails after re-execution twice, it is recorded as an unrepairable invalid mask and the process ends. The output unit records the verified bidirectional optical enhancement pattern as a valid mask. The layer blending module specifically includes: The random unit generates a random mixing intensity value for each valid mask; The mixing unit, based on the random mixing intensity value, mixes the effective mask with the product white background image using the cv2.addWeighted function to generate the final dataset. Since the apparatus described in Embodiment 2 of the present invention is an apparatus used to implement the method of Embodiment 1 of the present invention, those skilled in the art can understand the specific structure and variations of the apparatus based on the method described in Embodiment 1 of the present invention, and therefore will not be described again here. All apparatuses used in the method of Embodiment 1 of the present invention fall within the scope of protection of the present invention. Example 3 The overall concept of the technical solution in this application is as follows: Focusing on the product mask (rather than the entire image), positive and negative light enhancements are performed. Data quality is ensured through batch processing verification. Light feature gradients are generated by combining random mixed intensities. Finally, the model is adapted to the FLUX.1-Kontext model format and annotation requirements, providing the model with high-quality training samples of "product + diverse light features" and solving the problem of non-adaptive lighting when generating product scenes. The method is executed step by step according to the logic of "data preparation - light enhancement - batch processing verification - hybrid fusion - model adaptation - output". The detailed implementation of each step is as follows: Step S1: Preparation and Standardization of Raw Training Data The core objective of this step is to provide "clean and consistent" raw data for subsequent augmentation processing, avoiding data quality issues that could affect the augmentation results. Data acquisition standards: Product image with white background: Obtained from e-commerce platforms (such as Taobao, JD.com) or product photography systems. The background must be pure white (RGB (255,255,255)), without any background clutter (such as shooting stands, shadows), with the main product centered and a resolution ≥512×512 (ensuring that product details are not lost after scaling to 640×640). Product mask: Image matting is performed using the Birefnet algorithm to generate a binary mask (product area pixel value 255, background area pixel value 0); Size standardization: 1024×1024 pixels was selected as the uniform size, and bilinear interpolation algorithm was used to perform scaling. This algorithm balances the smoothness of product edges with the preservation of details, and avoids edge jaggedness caused by scaling. Removal of excessively small items: Calculate the pixel ratio of the product area in the mask (number of pixels in the product area = 10%). If the ratio is less than 10% (such as excessively small accessories, such as headphone charging cables), remove the data. The light features of such small objects are difficult for the model to capture and will interfere with the model's learning of normal products. Step S2: Two-way light enhancement treatment for product masks This step is one of the core innovations. It uses traditional image processing algorithms (algorithms implemented in the OpenCV traditional image processing library) to achieve "positive-negative" differentiated light enhancement, accurately simulating the diverse product lighting characteristics required by the FLUX.1-Kontext model. Algorithm selection criteria: The reason for choosing traditional image processing algorithms (rather than deep learning augmentation models, such as GANs) is that traditional algorithms have strong parameter controllability (they can precisely set specific values ​​such as exposure +1, contrast +10), fast processing speed (5 to 8 times faster than GANs, suitable for large-scale data processing), and no "generative noise" (avoiding deep learning models generating fake product textures, which would cause the model to learn incorrect features). The core dependency library is OpenCV (open source, cross-platform, mature algorithm), and all enhancement operations are implemented based on the basic functions of OpenCV to avoid compatibility issues caused by custom algorithms; Positive light enhancement (simulating product characteristics in a "strong light scene"): Objective: To generate a "product mask under strong light" that simulates strong light environments such as window spotlights and outdoor sunlight in e-commerce scenarios, so that the model can learn the characteristics of products under strong light, such as "high brightness, clear texture and weak shadow". Specific implementation (executed sequentially to avoid conflicting steps): Exposure +1: Call cv2.convertScaleAbs(mask, alpha=1.1, beta=0) — alpha is the brightness gain coefficient, 1.1 corresponds to a 10% increase in brightness, which is equivalent to "exposure +1" (which conforms to the human eye's perception of exposure changes); beta is the brightness offset, set to 0 to avoid additional brightness offset; Contrast +10: Call cv2.addWeighted(mask, 1.1, mask, 0, 0) — alpha is the contrast gain coefficient, 1.1 corresponds to a 10% increase in contrast; the contrast between the product and the background will increase in strong light, so the contrast of the mask needs to be increased so that the model can learn this feature; Highlights -5: Highlight areas of products under strong light (such as the metal frames of home appliances and the glossy materials of clothing) are prone to overexposure (pixel values ​​close to 255), resulting in loss of detail. Therefore: First, convert the mask from BGR format to HSV format (hsv=cv2.cvtColor(mask, cv2.COLOR_BGR2HSV)) — HSV format separates "brightness" into a separate V channel, which is convenient for targeted adjustment; Extract the V channel (v_channel = hsv[:, :, 2]), and for areas in the V channel with pixel values ​​> 200 (defined as highlight areas), perform v_channel[v_channel > 200] -= 5 to reduce the brightness of the highlight areas and preserve details; Shadow +10: Under strong light, the shadow areas of goods (such as the folds of clothing or the bottom of home appliances) have low brightness and are prone to being "dead black" (pixel values ​​close to 0). Therefore, v_channel[v_channel < 50] += 10 is performed on the areas with pixel values ​​< 50 in the V channel (defined as shadow areas) to increase the brightness of the shadow areas and preserve the shadow texture. White-5: Adjust the white threshold of the V channel (i.e., the upper limit of the "brightest area" in the product), reduce the white threshold from 255 to 250, and execute v_channel[v_channel >= 250] = 250 — to avoid overexposure and whitening of the white areas of the product (such as white T-shirts) under strong light, resulting in loss of texture details; Black +5: Adjust the black threshold of the V channel (i.e., the lower limit of the "darkest area" in the product), increase the black threshold from 0 to 5, and execute v_channel[v_channel <= 5] = 5 — to avoid the black areas of the product (such as black pants) being too "dead black" under strong light, and to preserve edge details; Texture +5: Under strong light, the surface texture of goods (such as the fabric texture of clothing and the brushed texture of home appliances) is clearer. Therefore, we call cv2.Laplacian(mask, cv2.CV_32F, ksize=3) - a 3×3 kernel Laplacian filter can enhance the image edges and textures. After filtering, it is converted to uint8 type by cv2.convertScaleAbs to complete the texture enhancement. CV_32F (32-bit floating-point) floating-point data typically includes negative values ​​(e.g., -100 to 100). OpenCV's imshow and imwrite functions only support uint8 type (0-255 range) by default. Enhanced post-processing: The adjusted V channel is put back into HSV format, converted back to BGR format, and a positive enhanced mask is obtained and stored in the "Product Category / Positive Mask / " folder; Negative light enhancement (simulating product characteristics in "low-light scenes"): Objective: To generate a "product mask under low light conditions" to simulate warehouse environments and indoor low-light environments in e-commerce scenarios, enabling the model to learn the "low brightness, blurred texture, and deep shadow" features of products under low light conditions. Specific implementation details (only the differences in steps are explained; identical steps are the same as those for forward enhancement): Exposure-1: Calling cv2.convertScaleAbs(mask, alpha=0.9, beta=0) — a 0.9x brightness gain corresponds to a 10% reduction in brightness, equivalent to "Exposure-1"; Highlights +5: In low light, the highlight areas of a product are low in brightness and easily blend into the background. Therefore, v_channel[v_channel > 200] += 5 is applied to areas with a V channel value greater than 200 to increase the brightness of the highlight areas and highlight the product outline. Shadow-10: The shadow areas of the product are darker in low light, so v_channel[v_channel < 50] -= 10 is executed for areas in the V channel < 50 to deepen the shadows and simulate the shadow characteristics in low light; White +5: In low light, the white area of ​​the product is easily too dark, so adjust the white threshold to 255 (because 255+5=260 exceeds the uint8 range, it is automatically truncated to 255), and execute v_channel[v_channel >= 255] = 255 to increase the brightness of the white area; Black-5: Under low light, the black areas of the product are prone to appearing grayish. Therefore, the black threshold is adjusted to 0 (because 0-5=-5 is out of range, it is truncated to 0), and v_channel[v_channel <= 0] = 0 is executed to deepen the black areas and enhance the contrast of the product. Texture-5: The surface texture of the product is blurred in low light. Therefore, calling cv2.GaussianBlur(mask, (5,5),2.0) - a 5×5 kernel Gaussian blur with σ=2.0 can reduce the texture and simulate the visual effect in low light. Enhancement effect verification: Randomly select 10 masks from each product category (such as clothing and home appliances), perform positive / negative enhancement, and then display a comparison chart of "original mask - positively enhanced mask - negatively enhanced mask" on the visualization interface; If over-enhancement is found (such as blurred product edges or loss of texture), fine-tune the parameters. For example, if the fabric texture becomes too sharp after adding 5 to the texture of a clothing mask, the Laplacian kernel can be changed from 3×3 to 1×1, or the gain coefficient can be reduced. After successful verification, the positive enhancement mask and the negative enhancement mask will be stored according to product category. Step S3: Enhance mask batch processing and two-dimensional validity validation This step addresses the issues of "efficiency in large-scale data processing" and "enhanced data quality control," and is a key design element in ensuring the reliability of FLUX.1-Kontext training data. Two-dimensional validity verification design: Core objective: To avoid issues such as "product area shrinkage" and "edge breakage" during the enhancement process, and to ensure the integrity of product features in the enhanced mask. If the product area or edges of the mask are damaged, the light features generated by subsequent blending will deviate from the real product, leading to model learning errors. First dimension: Pixel ratio verification: Calculate the pixel ratio of the product area in the original mask, original_ratio; Calculate the enhanced ratio of the product area pixels in the enhanced mask; Validation rule: If enhanced_ratio < original_ratio × 0.8 (i.e. the product area is shrunk by more than 20% after enhancement), it is considered invalid. This situation is often due to excessive shadow adjustment (such as the shadow of positive enhancement being too large +10, causing the product edge to be "swallowed"). Second dimension: Edge integrity verification: Edge extraction: Canny edge detection is performed on the original mask and the enhanced mask respectively. The low threshold of 50 and the high threshold of 150 are the optimal parameters for product edge extraction that have been verified by experiments. They can balance edge integrity and noise filtering. Edge overlap calculation: overlap_edge = cv2.bitwise_and(original_edge, enhanced_edge) (calculate overlapping edges), overlap_ratio = cv2.countNonZero(overlap_edge) / cv2.countNonZero(original_edge) (number of overlapping edge pixels / number of original edge pixels); Verification rule: If overlap_ratio < 0.75 (i.e., edge overlap is less than 75%), it is considered invalid - this situation is mostly due to excessive texture enhancement (such as positive enhancement of 3×3 Laplacian kernel causing product edge breakage). Invalid mask handling mechanism: Automatic repair: For masks that fail the verification, the "parameter fine-tuning - re-enhancement" process is automatically triggered - for example, if the pixel ratio is insufficient, the shadow adjustment parameter is reduced from +10 to +8, and if the edge overlap is insufficient, the Laplacian kernel is changed from 3×3 to 1×1; if the re-enhancement still fails after 2 times, it is judged as "unrepairable". Log recording: For unrepairable masks, logs are recorded to the log file (invalid_mask_log.txt), including the following fields: mask path, failure dimension (pixel percentage / edge integrity), original parameters, and suggested adjustment parameters (e.g., "tv_005_mask.png, edge integrity, texture +5, suggested texture +3"). Supports subsequent manual review; Valid data output: Store the validated augmented masks by category (e.g., "Home Appliances / Positive Masks / ", "Clothing / Negative Masks / ") to form a batch of valid augmented mask datasets. Product categories refer to the product classifications that already exist in the original product data. Product category information already exists when the original product images are obtained. For example, the dataset might contain folder structures like "Mobile / Product 1.jpg" and "Clothing / Product 2.jpg". Step S4: Enhance mask and white background image adaptive layer blending This step addresses the deficiency of "fixed mixed intensity" by generating "light feature gradient" samples required by the FLUX.1-Kontext model through "random intensity + adaptive optimization," thereby improving the model's adaptive generalization ability regarding light. Random mixed intensity generation logic: Blending intensity definition: It represents the proportion of the enhancement mask (light features) in the blended image—the higher the intensity, the more obvious the light features; the lower the intensity, the more prominent the original features of the white background image. The value range is chosen to be 0.5~1.0 for the following reasons: Below 0.5: The light features are too weak, the FLUX.1-Kontext model cannot capture effective light information, and it still cannot adapt to the scene lighting after training; Above 1.0: The enhanced mask completely covers the white background image, losing the original features of the product's white background image. The model learns "pure light features" instead of "product + light features". Generation method: Generate uniformly distributed random floating-point numbers (such as 0.623, 0.891, 0.512) using numpy.random.uniform(0.5, 1.0). It supports setting a random seed (such as numpy.random.seed(42)) - a fixed seed can ensure that the same mixed intensity sequence is generated each time, which is convenient for experimental reproduction; 1. Data preparation and standardization Get product images with a white background: Collect images containing a single product with a pure white background. Product mask cutout: Process each product image with a white background to separate the main body of the product and generate a corresponding mask image. Size unification: Adjust all original images and their masks to the same size (e.g., 1024×1024 pixels) for subsequent processing. Removing oversized items: Examine the resized product images and remove those that are too small or do not meet the minimum standards to ensure that the dataset contains only clearly identifiable products. 2. Product mask light enhancement Positive Light Enhancement (Strong Light): Simulates strong light conditions to enhance the light effects in the mask image, thereby increasing the model's recognition ability under high brightness conditions. Negative Light Enhancement (Low Light): Simulates low light or shadow conditions, correspondingly reducing the light effects in the mask image and improving the model's performance in low-light environments. 3. Enhance mask verification and processing Pixel ratio verification: Check the proportion of effective pixels in the enhanced mask image to ensure that it meets the expected standards. Edge integrity check: Evaluate whether the mask edges are smooth, intact, and without breaks or other defects. Automatically repair / record invalid masks: For masks that fail verification, attempt to repair them automatically; if repair is not possible, record them for manual review. 4. Mixing mask with white background image Randomly generate blending intensity: Generate a random blending ratio for each blending operation to give the final synthesized image diversity. Layer blending: Based on the generated blending ratio, the enhanced mask is merged with the original product white background image to create new training samples. The blending operation is implemented using OpenCV's cv2.addWeighted function. 5. Output the final dataset After the above series of processing steps, a high-quality dataset suitable for AI training is obtained. This data contains images of goods under various lighting conditions, which helps improve the robustness and accuracy of the model. Based on the same inventive concept, this application provides an electronic device embodiment corresponding to Embodiment 1, as detailed in Embodiment 4. Example 4 This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it can implement any of the implementation methods in Embodiment 1. Since the electronic device described in this embodiment is the device used to implement the method in Embodiment 1 of this application, those skilled in the art can understand the specific implementation method and various variations of the electronic device in this embodiment based on the method described in Embodiment 1 of this application. Therefore, how the electronic device implements the method in the embodiment of this application will not be described in detail here. Any device used by those skilled in the art to implement the method in the embodiment of this application falls within the scope of protection of this application. Based on the same inventive concept, this application provides a storage medium corresponding to Embodiment 1, as detailed in Embodiment 5. Example 5 This embodiment provides a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it can implement any of the implementation methods in Embodiment 1. The technical solutions provided in this application embodiment have at least the following technical effects or advantages: Focusing on the product mask (rather than the entire image), positive and negative light enhancements are performed. Data quality is ensured through batch processing verification. Light feature gradients are generated by combining random mixed intensities. Finally, the model is adapted to the FLUX.1-Kontext model format and annotation requirements, providing the model with high-quality training samples of "product + diverse light features" and solving the problem of non-adaptive lighting when generating product scenes. Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes. These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes. These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes. While specific embodiments of the present invention have been described above, those skilled in the art should understand that the specific embodiments described are merely illustrative and not intended to limit the scope of the invention. Equivalent modifications and variations made by those skilled in the art in accordance with the spirit of the invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. A method for processing product image light enhancement data during model training, characterized in that: Includes the following steps: S10. Obtain the product white background image and product category, and perform image cutout, size processing and product removal processing on the product white background image to obtain the product mask image; S20. The product mask image is subjected to positive light enhancement processing and negative light enhancement processing respectively using image processing algorithms, and a bidirectional light enhancement image is output. S30. Perform pixel ratio verification and edge integrity verification on the bidirectional light enhancement map; Adjust the enhancement parameters of the bidirectional light enhancement maps that failed the verification and reprocess S20 until the verification is passed; output a valid mask; S40. Generate a random mixing intensity value for each of the valid masks; Based on the random mixing intensity value, the effective mask is layer-blended with the corresponding product white background image to generate the final dataset.

2. The method for processing commodity image light enhancement data for model training according to claim 1, characterized in that: Specifically, S10 is: S11. Obtain a product background image with a pure white background, and perform image matting using the Birefnet algorithm. Set the pixel value of the product area in the product background image to 255 and the pixel value of the background area to 0 to generate a matting mask image. S12. Use bilinear interpolation algorithm to uniformly scale the product white background image and the cutout mask image to a preset size; S13. Calculate the pixel percentage of the product area in the scaled-down cutout mask. If the pixel percentage is less than 10%, remove the corresponding product background image and cutout mask. If the pixel percentage is greater than 10%, output the product mask.

3. The method for processing product image light enhancement data for model training according to claim 1, characterized in that: Specifically, S20 is: S21. Using OpenCV's image processing algorithm, perform positive light enhancement processing on the product mask image to simulate product features under strong light illumination; S211. Call the cv2.convertScaleAbs function to increase the brightness of the product mask image by 10%, thereby increasing the exposure value by 1; S212. Call the cv2.addWeighted function to increase the contrast of the product mask image by 10; S213. Convert the product mask image to the HSV color space, and perform a brightness reduction of 5 on the highlight areas with pixel values ​​greater than 200 in the V channel. S214. Perform a brightness increment of 10 operation on the shadow areas in the V channel where the pixel value is less than 50; S215. Adjust the white threshold of the V channel to 250 and the black threshold to 5; S216. Call the cv2.Laplacian function to perform a 3×3 kernel Laplacian filter on the product mask image to achieve texture enhancement 5; S217. Convert the product mask image back to BGR format to obtain a positively enhanced mask; S22. Using an image processing algorithm based on OpenCV, negative light enhancement processing is performed on the product mask image to simulate product features under low light illumination. S221. Call the cv2.convertScaleAbs function to reduce the brightness of the product mask image by 10%, thereby reducing the exposure value by 1. S222. Call the cv2.addWeighted function to reduce the contrast of the product mask image by 10. S223. Convert the product mask image to the HSV color space, and perform a brightness increase of 5 operation on the highlight areas with pixel values ​​greater than 200 in the V channel. S224. Perform a brightness reduction operation of 10 on the shadow areas in the V channel where the pixel value is less than 50; S225. Adjust the white threshold of the V channel to 255 and the black threshold to 0; S226. Call the cv2.GaussianBlur function to apply a 5×5 kernel Gaussian blur with σ=2.0 to the product mask image to reduce texture. S227. Convert the product mask image back to BGR format to obtain a negative enhancement mask; S23. Store the positive enhancement mask and the negative enhancement mask as a bidirectional optical enhancement map.

4. The method for processing product image light enhancement data for model training according to claim 1, characterized in that: Specifically, S30 is: S31. Perform pixel ratio verification on the bidirectional light enhancement image, calculate the pixel ratio of the product area in the product mask image and the bidirectional light enhancement image respectively. If the pixel ratio of the product area in the bidirectional light enhancement image is less than 0.8 times the pixel ratio of the original product area in the product mask image, then the bidirectional light enhancement image verification is determined to be unsuccessful. S32. Perform edge integrity verification on the bidirectional light enhancement map. Perform Canny edge detection on the product mask map and the bidirectional light enhancement map respectively, and calculate the edge overlap between the product mask map and the bidirectional light enhancement map. If the edge overlap is less than 0.75, the bidirectional light enhancement map verification is determined to be unsuccessful. S33. For bidirectional light enhancement maps that fail the verification, adjust the parameters according to the set adjustment values ​​and re-execute step S20. If it still fails after re-execution twice, record it as an unrepairable invalid mask and end the step. S34. Record the verified bidirectional optical enhancement pattern as a valid mask; Specifically, S40 is: S41. Generate a random mixing intensity value for each valid mask; S42. Based on the random mixing intensity value, the effective mask and the product white background image are mixed using the cv2.addWeighted function to generate the final dataset.

5. A device for processing product image light enhancement data during model training, characterized in that: Includes the following modules: The white background image processing module obtains the white background image of the product and the product category, performs image cutout, size processing, and sets product removal processing on the white background image of the product to obtain the product mask image; The bidirectional light enhancement module uses image processing algorithms to perform positive light enhancement processing and negative light enhancement processing on the product mask image, and outputs a bidirectional light enhancement image; The verification module performs pixel ratio verification and edge integrity verification on the bidirectional light enhancement map; Adjust the enhancement parameters of the bidirectional light enhancement maps that failed the verification and reprocess S20 until the verification is passed; output a valid mask; The layer blending module generates a random blending intensity value for each valid mask. Based on the random mixing intensity value, the effective mask is layer-blended with the corresponding product white background image to generate the final dataset.

6. The product image light enhancement data processing device for model training according to claim 5, characterized in that: The white background image processing module specifically includes: The image matting unit acquires a product background image with a pure white background and performs image matting using the Birefnet algorithm. The pixel values ​​of the product area in the product background image are set to 255, and the pixel values ​​of the background area are set to 0, generating a matting mask image. The scaling unit uses a bilinear interpolation algorithm to uniformly scale the product white background image and the cutout mask image to a preset size; The product removal unit calculates the pixel percentage of the product area in the scaled cutout mask image. If the pixel percentage is less than 10%, the corresponding product background image and cutout mask image are removed. If the pixel percentage is greater than 10%, the product mask image is output.

7. The product image light enhancement data processing device for model training according to claim 5, characterized in that: The bidirectional light enhancement module is specifically: The forward light enhancement unit uses OpenCV's image processing algorithm to perform forward light enhancement processing on the product mask image to simulate the product features under strong light illumination; The positive exposure value subunit calls the cv2.convertScaleAbs function to increase the brightness of the product mask image by 10%, thereby increasing the exposure value by 1; The positive contrast subunit calls the cv2.addWeighted function to increase the contrast of the product mask image by 10; The positive specular subunit converts the product mask image to the HSV color space and performs a brightness reduction of 5 operation on the specular areas with pixel values ​​greater than 200 in the V channel. The positive shadow sub-unit performs a brightness increment operation of 10 on shadow areas with pixel values ​​less than 50 in the V channel; For the positive V-channel sub-unit, adjust the white threshold of the V-channel to 250 and the black threshold to 5; The positive texture enhancement subunit calls the cv2.Laplacian function to perform a 3×3 kernel Laplacian filter on the product mask image to achieve texture enhancement 5; The forward output subunit converts the product mask image back to BGR format to obtain a forward enhanced mask; The negative light enhancement unit uses an OpenCV-based image processing algorithm to perform negative light enhancement processing on the product mask image to simulate product features under low light illumination. The negative exposure value subunit calls the cv2.convertScaleAbs function to reduce the brightness of the product mask image by 10%, thereby reducing the exposure value by 1. The negative contrast sub-unit calls the cv2.addWeighted function to reduce the contrast of the product mask image by 10. The negative highlight subunit converts the product mask to the HSV color space and performs a brightness increase of 5 operation on the highlight areas with pixel values ​​greater than 200 in the V channel. The negative shadow sub-unit performs a brightness reduction operation of 10 on shadow areas with pixel values ​​less than 50 in the V channel; For the negative V channel sub-unit, adjust the white threshold of the V channel to 255 and the black threshold to 0; The negative texture reduction subunit calls the cv2.GaussianBlur function to perform a 5×5 kernel Gaussian blur on the product mask image to achieve texture reduction. The negative output subunit converts the product mask image back to BGR format to obtain a negative enhancement mask; The storage unit stores the positive enhancement mask and the negative enhancement mask as a bidirectional light enhancement map.

8. The product image light enhancement data processing device for model training according to claim 5, characterized in that: The verification module is specifically as follows: The pixel ratio verification unit performs pixel ratio verification on the bidirectional light enhancement image, calculates the pixel ratio of the product area in the product mask image and the bidirectional light enhancement image respectively. If the pixel ratio of the product area in the bidirectional light enhancement image is less than 0.8 times the pixel ratio of the original product area in the product mask image, the bidirectional light enhancement image verification is determined to be unsuccessful. The edge integrity verification unit performs edge integrity verification on the bidirectional light enhancement map, performs Canny edge detection on the product mask map and the bidirectional light enhancement map respectively, and calculates the edge overlap between the product mask map and the bidirectional light enhancement map. If the edge overlap is less than 0.75, the bidirectional light enhancement map verification is determined to be unsuccessful. If the processing unit fails, for bidirectional light enhancement maps that fail the verification, adjust the parameters according to the set adjustment values ​​and re-execute step S20. If it still fails after re-execution twice, it is recorded as an unrepairable invalid mask and the process ends. The output unit records the verified bidirectional optical enhancement pattern as a valid mask. The layer blending module specifically includes: The random unit generates a random mixing intensity value for each valid mask; The mixing unit, based on the random mixing intensity value, mixes the effective mask with the product white background image using the cv2.addWeighted function to generate the final dataset.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method as described in any one of claims 1 to 4.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1 to 4.