A method, apparatus, device, and medium for generating weak similarity based on style transfer

By combining Flux models, Redux tools, LoRA technology, and Florence models, the problems of detail loss and over-stylization caused by fixed weights in traditional image style transfer are solved. Adaptive style injection and multi-scale optimization are achieved, generating high-quality stylized images.

CN122134548APending Publication Date: 2026-06-02XIAMEN ZIXUN INFORMATION TECHNOLOGY CO LTD

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-02

AI Technical Summary

Technical Problem

Traditional image style transfer methods use fixed weights, which can lead to loss of detail or over-stylization, making it difficult to achieve natural style transfer while preserving the structure of the target content.

Method used

The Flux model is used for high-definition redrawing, the resolution is optimized by using flow matching and parallel diffusion Transformer blocks, adaptive style injection is performed by combining Redux tools, local detail optimization is performed by LoRA technology, and multi-scale semantic structure analysis and bilateral filtering are performed by using the Florence model to generate the final style image.

Benefits of technology

While maintaining the structure of the image content, it achieves high fidelity of style information and natural style fusion, avoiding loss of detail and over-stylization, and generating high-quality stylized images with rich details and natural transitions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122134548A_ABST
    Figure CN122134548A_ABST
Patent Text Reader

Abstract

This invention provides a method, apparatus, device, and medium for generating weak similarity based on style transfer. The method includes: S10, redrawing a style reference image to generate a clear style image; S20, extracting visual elements from the clear style image and mapping the visual elements to a target content image through an adaptive style injection mechanism to generate an initial result image; S30, optimizing the initial result image to generate an adjusted result image; S40, performing multi-scale optimization on the adjusted result image, the multi-scale optimization including image segmentation, semantic structure analysis, and semantically guided redrawing to obtain an optimized result image; S50, performing semantic region classification on the optimized result image and using bilateral filtering to assist optimization to generate a final style image. This invention solves the problem in the prior art where the use of fixed weights leads to loss of detail or over-stylization, making it difficult to achieve natural style transfer while preserving the target content structure.
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, device, and medium for generating weak similarity based on style transfer. Background Technology

[0002] Traditional image style transfer methods (such as Neural Style Transfer) rely on preset, fixed parameters to balance content preservation and stylization during style fusion. They iteratively optimize under a fixed, global weight to generate a fused image. This fusion strategy fails to perceive the semantic information within the image, leading to over-stylization or under-stylization in complex scenes, resulting in a stiff and unnatural overall effect. This rigid global fusion weight lacks an understanding of the semantic structure of the image content, thus failing to intelligently and adaptively allocate appropriate style intensity to different image regions. Ultimately, it becomes difficult to achieve a balance between preserving the target content structure and achieving a natural and harmonious style effect. Weak similarity refers to extracting the core visual elements (such as color tone, brushstroke style, and artistic texture) from the style reference image and fusing them with the target content image. The generated image and the reference image only maintain a consistent style direction, allowing for significant differences in structure, color, and detail. Existing technologies generally suffer from the problem of losing details or over-stylizing due to the use of fixed weights, making it difficult to achieve natural style transfer while preserving the target content structure. 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 generating weak similarity based on style transfer, which solves the problem of loss of detail or over-stylization caused by the use of fixed weights in the prior art. In a first aspect, the present invention provides a weak similarity generation method based on style transfer, comprising the following steps: S10. Redraw the style reference image to generate a clear style image; S20. Extract the visual elements of the clear style map, and map the visual elements to the target content image through an adaptive style injection mechanism to generate an initial result image; S30. Optimize the initial result image to generate an adjusted result image; S40. Perform multi-scale optimization on the adjusted image. The multi-scale optimization includes image segmentation, semantic structure analysis, and semantic-guided redrawing to obtain the optimized image. S50. Perform semantic region classification on the optimized image, use bilateral filtering to assist in optimization, and generate the final style image. Secondly, the present invention provides a style transfer-based weak similarity generation device, comprising the following modules: The Clear Style Map module redraws the style reference map and generates a clear style map; The initial result image module extracts the visual elements of the clear style map, maps the visual elements to the target content image through an adaptive style injection mechanism, and generates the initial result image. The adjustment result image module optimizes the initial result image to generate an adjusted result image; The optimized result image module performs multi-scale optimization on the adjusted result image. The multi-scale optimization includes image segmentation, semantic structure analysis, and semantically guided redrawing to obtain the optimized result image. The final style image module performs semantic region classification on the optimized image, uses bilateral filtering to assist in optimization, and generates the final style image. 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 in the embodiments of the present invention have at least the following technical effects or advantages: 1. Traditional high-definition redrawing usually relies on a single resolution enhancement algorithm; the Flux model used in this invention is based on the diffusion model framework and is optimized through flow matching and parallel diffusion Transformer blocks. While improving the resolution, it specifically enhances the clarity of artistic features (such as brushstrokes and patterns) to ensure the integrity and fidelity of style information at high resolution. 2. Traditional style transfer (such as Neural Style Transfer) typically uses fixed weights to blend style and content, which can easily lead to loss of detail or over-stylization. The Redux tool used in this invention inherits the diffusion framework of the Flux model, which can dynamically adjust the weights of style injection in the latent space and adaptively balance the style intensity according to the content features of the target image, thereby effectively avoiding distortion of scene elements (such as object structure and perspective relationships); 3. Compared with traditional full-parameter fine-tuning, which is computationally expensive and prone to overfitting, the LoRA method used in this invention only requires inserting and training a small number of low-rank matrix parameters; for weakly similar scenes, specific style features are designed to adapt to training objectives (such as enhancing the coherence of texture details and the progressiveness of color levels) to achieve accurate local detail optimization and avoid unnecessary global style reshaping. 4. Traditional multi-scale block processing often lacks high-level semantic guidance; this invention guides the Flux redrawing process through the deep semantic understanding capabilities of the Florence model (such as identifying specific object categories in sub-blocks, such as trees, buildings, and their structural relationships), enabling it to optimize for features (such as textures and edges) of different semantic regions, effectively avoiding visual discontinuity or semantic inconsistency problems caused by simple block rendering and splicing. 5. Through parameter adaptation, this invention enhances the line contrast of woodblock prints and the brushstroke texture of oil paintings, thereby enhancing the artistic style and making the style integration more natural. 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 generating weak similarity based on style transfer, which solves the problem in the prior art where the use of fixed weights leads to loss of detail or over-stylization, making it difficult to achieve natural style transfer while preserving the target content structure. Example 1 This embodiment provides a weak similarity generation method based on style transfer, such as Figure 1 As shown, including The following steps: S10. Redraw the style reference image to generate a clear style image; S11. Adjust the diffusion process parameters of the Flux model according to preset conditions. The diffusion process parameters include classifier guidance and sampling steps. S12. The Flux model uses flow matching to input the style reference image into the Flux model to generate a preliminary refinement image; S13. Parallel diffusion is used to perform parallel image retouching on the preliminary refined image, and optimization is performed through Transformer block pairs to generate a clear style image. S20. Extract the visual elements of the clear style map, and map the visual elements to the target content image through an adaptive style injection mechanism to generate an initial result image; S21. Identify the sharp style map using the CLIP model to obtain the main body region and background region of the sharp style map; S22. Adjust the style features of the adaptive style injection mechanism in the latent space of the Flux-Redux tool, set the style feature weights of the main body region and the background region; adjust the strength of the adaptive style injection mechanism according to the semantic classification result of the target content image; S23. In the latent space of the Flux-Redux tool, adjust the style feature weights of the adaptive style injection mechanism, including: S231. Set the style feature weights of the main body region and the background region of the clear style map; the style feature weight of the main body region is less than the style feature weight of the background region; S232. Input the target content image into an image classification model to obtain the semantic category label of the target content image; adjust the style feature weights of the target content image according to the semantic category label; S24. Generate the initial result image; S30. Optimize the initial result image to generate an adjusted result image; S31. Input the initial result image and the target content image into the Florence model, compare the texture features of the initial result image and the target content image, and locate the texture misalignment problem points of the initial result image; S32. Using the layer feature visualization tool of the Flux-Redux model, the initial result image is divided into shallow model layer and medium model layer; the texture misalignment problem points are associated with the shallow model layer or the medium model layer to determine the model layer that needs intervention; The texture misalignment problem points and the model layers requiring intervention are generated as repair information; S33. Based on the repair information, optimize the initial result image using LoRA technology to generate an adjusted result image; S40. Perform multi-scale optimization on the adjusted image. The multi-scale optimization includes image segmentation, semantic structure analysis, and semantic-guided redrawing to obtain the optimized image. S41. The adjusted image is upsampled by 2 pixels, and the upsampled adjusted image is divided into blocks using TTP block segmentation technology to obtain image blocks; S42. Use the Florence model to extract the semantic structure information of each image patch; the semantic structure information includes object contours, region segmentation, and color distribution features; S43. Apply the Flux model to redraw each image block based on its semantic structure information, stitch together the redrawn image blocks, optimize the transition between each image block, and output the optimized result image. S50. Perform semantic region classification on the optimized image, use bilateral filtering to assist in optimization, and generate the final style image; S51. The Florence model is used to identify the semantic regions of the optimized image, and the semantic regions are divided into core structure regions, style expression regions and transition regions. Customized filtering parameters are applied to the semantic regions of the different classifications, and the filtering parameters include σ. d and σ r , σ d It is the spatial domain standard deviation, used to control the size of the filter window, σ r It is the standard deviation of the value range, used to control the tolerance for color differences; the specific filter parameters customized for the semantic regions of the different classifications are as follows: Core structural region: σ d1 and σ r1 Set as the first preset value; Style expression area: σ d2 and σ r2 Set to the second preset value; Transitional connection area: σ d3 and σ r3 Set to the third preset value; The first preset value is less than the third preset value; the third set threshold is less than the second preset value; S52. Calculate the spatial proximity weight w using the aforementioned filter parameters. s (i,j):

[0004] The (x,y) values ​​represent the target pixel coordinates. S53. Calculate the pixel value similarity weight w using the aforementioned filtering parameters. r (i,j):

[0005] (x,y) represents the target pixel coordinates, (i,j) represents the neighborhood pixel coordinates, and I(x,y)−I(i,j) represents the color difference between the target pixel and the neighborhood pixel. S54. Substitute the spatial proximity weight ws(i,j) and pixel value similarity weight wr(i,j) into the bilateral filtering calculation to obtain the pixel value Ifiltered(x,y) of the filtered image at the target pixel:

[0006] The Ω is a filtering window centered on the target pixel (x,y), and the filtering window is a set of neighboring pixels; I(i,j) is the pixel value of the optimized image at the neighboring pixel (i,j). ws(i,j) is the spatial proximity weight; The wr(i,j) is the pixel value similarity weight; S55. Use the Ifiltered(x,y) to synthesize the stylized result image. 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 This embodiment provides a style transfer-based weak similarity generation device, such as... Figure 2 As shown, it includes the following modules: The Clear Style Map module redraws the style reference map and generates a clear style map; The initial result image module extracts the visual elements of the clear style map, maps the visual elements to the target content image through an adaptive style injection mechanism, and generates the initial result image. The adjustment result image module optimizes the initial result image to generate an adjusted result image; The optimized result image module performs multi-scale optimization on the adjusted result image. The multi-scale optimization includes image segmentation, semantic structure analysis, and semantically guided redrawing to obtain the optimized result image. The final style image module performs semantic region classification on the optimized image, uses bilateral filtering to assist in optimization, and generates the final style image. The clear style map module includes the following units: The diffusion unit adjusts the diffusion process parameters of the Flux model according to preset conditions. The diffusion process parameters include classifier guidance and sampling steps. The flow matching unit uses flow matching to input the style reference image into the flow model to generate a preliminary refinement image; The block optimization unit uses parallel diffusion to perform parallel image retouching on the preliminary refined image, and optimizes it through Transformer block pairs to generate a clear style image; The initial result image module includes the following units: The recognition unit identifies the sharp style map using the CLIP model to obtain the main body region and background region of the sharp style map; The style feature unit adjusts the style features of the adaptive style injection mechanism in the latent space of the Flux-Redux tool, sets the style feature weights of the main body region and the background region, and adjusts the strength of the adaptive style injection mechanism according to the semantic classification results of the target content image. The latent space unit, within the latent space of the Flux-Redux tool, adjusts the style feature weights of the adaptive style injection mechanism, including: The region weighting subunit sets the style feature weights of the main body region and the background region of the clear style map; the style feature weight of the main body region is less than the style feature weight of the background region. The weight subunit is adjusted by inputting the target content image into the image classification model to obtain the semantic category label of the target content image; the style feature weights of the target content image are adjusted according to the semantic category label. The generation unit generates the initial result image; The adjusted image module specifically includes the following units: The problem point unit inputs the initial result image and the target content image into the Florence model, compares the texture features of the initial result image and the target content image, and locates the texture misalignment problem points in the initial result image; The model layer unit uses a layer feature visualization tool for the Flux-Redux model to divide the initial result image into shallow model layers and medium model layers; the texture misalignment problem points are associated with the shallow model layer or the medium model layer to determine the model layer that needs intervention; The texture misalignment problem points and the model layers requiring intervention are generated as repair information; The repair and optimization unit optimizes the initial result image based on the repair information using LoRA technology to generate an adjusted result image. The optimized result image module is specifically as follows: Image scaling and segmentation unit: Upsamples the adjusted image by 2 pixels, and segments the upsampled adjusted image into blocks using TTP segmentation technology to obtain image blocks; Semantic structure analysis unit: Uses the Florence model to extract the semantic structure information of each image patch; the semantic structure information includes object contours, region segmentation, and color distribution features; Semantic-guided redrawing unit: Applying the Flux model, redrawing each image block based on semantic structure information, stitching together the redrawn image blocks, optimizing the transition between each image block, and outputting the optimized result image. The final style image module is specifically: The semantic partitioning unit uses the Florence model to identify the semantic regions of the optimized image and divides the semantic regions into core structure regions, style expression regions, and transition regions. Customized filtering parameters are implemented for the semantic regions of the different classifications. These parameters include σd and σr, where σd is the spatial domain standard deviation used to control the size of the filtering window, and σr is the value domain standard deviation used to control the color difference tolerance. Specifically, the customized filtering parameters for the semantic regions of the different classifications are as follows: Core structural region: σd1 and σr1 are set to the first preset value; Style expression area: σd2 and σr2 are set to the second preset value; Transitional connection area: σd3 and σr3 are set to the third preset value; The first preset value is less than the third preset value; the third set threshold is less than the second preset value; The spatial proximity weights ws(i,j) of the ws(i,j) unit are calculated using the aforementioned filtering parameters:

[0007] The (x,y) values ​​represent the target pixel coordinates. The wr(i,j) unit calculates the pixel value similarity weight wr(i,j) using the aforementioned filtering parameters:

[0008] (x,y) represents the target pixel coordinates, (i,j) represents the neighborhood pixel coordinates, and I(x,y)−I(i,j) represents the color difference between the target pixel and the neighborhood pixel. For the pixel value unit, the spatial proximity weight ws(i,j) and pixel value similarity weight wr(i,j) are substituted into the bilateral filtering calculation to obtain the pixel value Ifiltered(x,y) of the filtered image at the target pixel:

[0009] The Ω is a filtering window centered on the target pixel (x,y), and the filtering window is a set of neighboring pixels; I(i,j) is the pixel value of the optimized image at the neighboring pixel (i,j). ws(i,j) is the spatial proximity weight; The wr(i,j) is the pixel value similarity weight; The final optimization unit uses Ifiltered(x,y) to synthesize the stylized result image. 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. Based on the same inventive concept, this application provides an electronic device embodiment corresponding to Embodiment 1, as detailed in Embodiment 3. Example 3 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 4. Example 4 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. Example 5 Terminology Explanation: FLUX is an advanced text-based image generation model developed by Black Forest Labs (founded by the core team of Stable Diffusion). It aims to generate high-quality images from text descriptions. Its technology is based on a diffusion model framework, combining multiple techniques (such as flow matching and parallel diffusion Transformer blocks), resulting in outstanding performance in image quality, cue word adherence, and generation speed. LoRA (Low-Rank Adaptation) is an efficient model fine-tuning method that reduces the number of trainable parameters and computational cost by inserting a low-rank matrix into the pre-trained model, while maintaining fine-tuning effectiveness. In image generation, it is often used to optimize details in style-transferred images, such as adjusting local texture, color consistency, or structural accuracy. FLUX.1 Redux is a style transfer and image variant reshaping tool developed by Black Forest Labs for the FLUX.1 text-based image model. It combines diffusion models with deep learning style transfer techniques, introducing an adaptive style injection mechanism based on the FLUX.1 diffusion model framework. This dynamically embeds target style features into the latent space of the diffusion process. It allows users to stylize the generated results or generate diverse variants while preserving the core content of the image. Tile-based texture processing (TP) is a tile-based processing technique for high-resolution images, primarily used to address memory limitations and computational efficiency issues when generating or editing large images. Directly loading the entire image can lead to memory overflow or model crashes, while tile processing can cut the image into multiple small tiles, optimize each tile, and then seamlessly stitch them together to achieve efficient, stable, and high-quality output. Zoe Depth Anything: Zoe Depth is a monocular depth estimation model developed by Intel. It combines relative depth and metric depth estimation, supports zero-shot transfer learning, and achieves good generalization performance in depth prediction across different scenarios (such as indoors and outdoors). Depth Anything, developed by the University of Hong Kong, ByteDance, and other institutions, is trained using 1.5 million labeled images and 62 million unlabeled images. It provides multi-scale models (such as small, medium, and large), surpasses MiDaS in accuracy and robustness, and supports tasks such as ControlNet depth control. The main implementation of the weak similarity algorithm is as follows: Step 1: Flux Model (High-Resolution Redrawing Stage) Integration method: Directly redraw the style reference image in high definition, focusing on enhancing its texture details (such as line clarity and color transition smoothness) to provide a high-fidelity foundation for subsequent style transfer. Traditional high-definition redrawing typically relies on a single resolution enhancement algorithm. Here, the Flux model is based on a diffusion model framework and is optimized through flow matching and parallel diffusion Transformer blocks. While improving resolution, it specifically enhances the clarity of artistic features (such as brushstrokes and patterns), ensuring the integrity and fidelity of style information at high resolution. Model tuning: Adjust the diffusion process parameters of the Flux model (such as sampling steps and noise scheduling) to better suit the artistic feature extraction requirements of style maps, such as enhancing the model's ability to generate high-frequency texture details. The parameters of the diffusion process in the Flux model are adjusted as follows: Style transfer scenario: CFG=2-3; Basic style (such as flat design): 15 steps; Complex styles (such as oil painting / watercolor): 20-30 steps; The flow matching process first guides the blurred style draft step by step to the preliminary refined image, ensuring that the style is not lost; then, parallel diffusion allows multiple assistants to divide the retouching work, which speeds up the process; finally, the Transformer block acts as the "chief designer" to ensure that every detail is accurate and the overall image is coordinated. Step 2: Redux tools (style transfer stage) Integration method: Using the redrawn style map, extract its core visual elements (color distribution, texture features, brushstroke style), and map these elements to the target content image through an adaptive style injection mechanism, so as to achieve style fusion while preserving the structure of the target main content. Traditional style transfer (such as Neural Style Transfer) typically uses fixed weights to blend style and content, which can easily lead to loss of detail or over-stylization. The Redux tool here inherits the diffusion framework of the Flux model, dynamically adjusting the style injection weights in the latent space. It adaptively balances style intensity based on the content features of the target image, effectively avoiding distortion of scene elements (such as object structure and perspective relationships). First, it uses CLIP to find the immovable main subject. Then, in the Redux latent space, it assigns low style weights to the subject and high style weights to the background. It can also automatically adjust weights according to content changes. Finally, the verification and correction essentially only adds style to areas that do not affect the structure. Verification involves checking and correcting the initial image. Insufficient / excessive style injection (e.g., background style is too faint): Adjust the style feature weights of the corresponding region (background / subject): increase the weights for insufficient style injection and decrease the weights for excessive style injection, then regenerate the local region. The semantic classification results mentioned in the process come from two sources: The first step is independent semantic classification of the target content image (used in step 2 to adjust the style injection intensity). Secondly, the refined semantic analysis of the adjusted and optimized images using the Florence model is unrelated to the recognition results of the CLIP model. Automatic weighting essentially involves the model dynamically adjusting the intensity of style injection based on the semantic classification results of the target content image (the semantic classification results of the target content image are semantic category labels obtained after processing the target content image through an image classification model). Finally, style features (from a style reference image) are added, and style weights control the injection intensity of style features in different content regions. The core (feature vector) of the latent space comes from the image feature module of Flux-Redux, where Redux is only responsible for managing the style weights in the latent space. Step 3: LoRA Model (Fine-tuning Stage) Combination method: For the initial result image after style transfer, low-rank adaptation (LoRA) technology is applied for fine-tuning, focusing on optimizing the local texture consistency, color transition naturalness and other details of fit. First, identify the problem points of texture misalignment and the corresponding model layers → interpolate low-rank matrices to fine-tune the weights, which is LoRA model training (preserving content texture and controlling style texture) → train the matrix with target data to fit the content pattern – essentially, it is to give the texture misalignment areas special treatment: without changing the overall model, only repair the details in a targeted manner, so that the style texture follows the pattern of the content texture, and finally achieve the effect of local texture continuity, no breakage, and conformity to the essence of the content. 1. Establish a target content texture baseline → compare with the initial result texture → locate problem points; 2. Visualize the model layer feature map → associate problem points with shallow / medium-level model layers. Provide the LoRA model with the repair range (problem points) and insertion position (model layer), enabling precise local fine-tuning and correcting texture misalignment. Compared to traditional full-parameter fine-tuning, which is computationally expensive and prone to overfitting, the LoRA method only requires inserting and training a small number of low-rank matrix parameters. For weakly similar scenes, specific style features are designed to adapt to the training objectives (e.g., enhancing the coherence of texture details and the progressiveness of color levels), achieving precise local detail optimization and avoiding unnecessary global style reshaping. Model tuning: Using the target style map data, the LoRA model is conditionally fine-tuned so that LoRA only learns the detailed patterns of the target content (such as the texture direction and color distribution of the target image) and does not generalize other data, so that the adjusted initial result image closely matches the target content. The LoRA technique is used to fine-tune the model to enhance the preservation of content textures and the control of style textures; LoRA itself reduces training parameters through low-rank matrix factorization. It does not directly include weights for content-preserving textures and style-controlling textures, but achieves these effects by adjusting these weights. Step 4: TTP block segmentation + Florence model + Flux redraw (multi-scale optimization stage) Connection method: i. Image scaling and segmentation: The image to be processed is upsampled by 2 pixels (upsampling by 2 pixels is equivalent to linearly enlarging the size by 2), and then it is divided into manageable sub-blocks using TTP (Token-to-Patch) segmentation technology to avoid the video memory limitations of large-size image processing. ii. Semantic structure analysis: Using the Florence model (or its visual foundation model capabilities) to infer the deep semantic structure information (such as object contours, region segmentation, and color distribution features) of each image sub-block. iii. Semantic-guided redrawing: Based on the semantic understanding provided by the Florence model, the Flux algorithm is applied to redraw each sub-block in a targeted manner, optimizing its internal structure and style fusion effect, and paying special attention to optimizing the visual transition between blocks (avoiding seams). Traditional multi-scale tile processing often lacks high-level semantic guidance. Here, the deep semantic understanding capabilities of the Florence model (such as identifying specific object categories in sub-tiles, such as trees, buildings, and their structural relationships) are used to guide the Flux redrawing process, enabling it to optimize for features (such as textures and edges) of different semantic regions. This effectively avoids visual discontinuity or semantic inconsistencies caused by simple tile rendering and stitching. After identifying the "semantic region" using the Florence model, its core function is to provide accurate regionalization basis for subsequent bilateral filtering optimization, ensuring that the filtering is no longer biased towards the entire region. Figure 1 Instead of a simple cut, the filtering parameters are customized for different semantic regions (such as a person's face, a sky background, or a building outline). The filtering parameters are (σ_d) and (σ_r). Step 5: Bilateral Filtering Assistance Input image: The multi-scale optimized image (output of step 4). Art style classification: using the Florence model to identify semantic regions of images (such as "woodblock print style", "oil painting brushstrokes", "natural scene").

[0010] The core formula for bilateral filtering is as follows:

[0011] Ifiltered(x,y): The pixel value of the filtered image at coordinates (x,y); (i,j): Neighboring pixel coordinates within the filter window Ω; Ω: A filtering window (a set of neighboring pixels) centered on the target pixel (x,y); I(i,j): The pixel value of the original image at the neighboring pixel (i,j); ws(i,j) spatial proximity weights (calculated based on pixel location distance); wr(i,j) pixel value similarity weight (calculated based on pixel color difference); The effectiveness of bilateral filtering is controlled by two core parameters: spatial proximity weight (σ_d, which controls the size of the filtering window) and pixel value similarity weight (σ_r, which controls the tolerance for color differences). Core structural areas (such as building outlines): σ_d (spatial window): set to a small value (such as 3-5 pixels), the filtering window only covers a small local area, avoiding large-scale blurring of details; σ_r (color tolerance): set to a small value (such as 10-20), only filters pixels with extremely small color differences (such as subtle color differences in human skin), preserving the edges of key structures (such as eye outlines, building lines). Style representation area (e.g., sky, grass) σ_d (spatial window): Set to a large value (e.g., 7-11 pixels) to cover a larger area of ​​the filter window, making style textures (e.g., oil painting brushstrokes, watercolor washes) softer and more coherent; σ_r (color tolerance): Set to a large value (e.g., 30-50) - allows greater color differences to participate in the filter, making color transitions more natural (e.g., the gradient from blue to white in the sky becomes smoother). Transitional areas (such as the boundary between the person and the background) σ_d (space window): set to a middle value (such as 5-7 pixels) to balance structure preservation and "style integration"; σ_r (color tolerance): set to a middle value (such as 20-30) to allow the colors / textures at the boundary to blend naturally (such as the boundary between the person's hair and the sky is not abrupt). σ_d is the spatial domain standard deviation, ws(i,j) is the spatial proximity weight, σ_r is the value domain standard deviation, and wr(i,j) is the pixel value similarity weight. σ_d determines the magnitude of ws(i,j), and σ_r determines the magnitude of wr(i,j). Spatial proximity weight ws(i,j): σ_d controls the size of the filtering window. The larger σ_d is, the wider the edge is retained.

[0012]

[0013] Pixel similarity weight wr(i,j): σ_r controls the tolerance for color differences. The smaller σ_r is, the stronger the color contrast is preserved.

[0014]

[0015] σd: Spatial domain standard deviation, which controls the effective range of the filtering window. The larger the value, the higher the weight of distant pixels within the window. Σr: Standard deviation of the range, which controls the tolerance for pixel color differences. The smaller the value, the more likely pixels with similar colors are to participate in the filtering. I(x,y)−I(i,j): Color difference between the target pixel and its neighboring pixels (brightness difference in grayscale image, multi-channel color difference in color image). Once Ifiltered(x,y) for all pixels in the entire image has been calculated, the resulting filtered image preserves the core structure of the image; optimizes the details of the style representation areas; smooths the transitions between areas; and generates a high-quality final style image. Parameter adaptation: Woodblock prints: σ_d=15, σ_r=5. Oil painting: σ_d=10, σ_r=20. Natural scene: σ_d=10, σ_r=15. Artistic Style Enhancement: Through parameter adaptation, the line contrast of woodblock prints and the brushstroke texture of oil paintings are enhanced. The technical solutions provided in this application embodiment have at least the following technical effects or advantages: The style transfer weak similarity generation method, device, equipment and medium provided in this application embodiment, by introducing semantically guided adaptive style injection and multi-stage refined processing mechanism, successfully solves the fundamental contradiction in traditional style transfer that it is difficult to balance "preserving structure" and "integrating style", and can generate high-quality stylized images with rich details and natural transitions under the premise of eliminating content structure distortion. 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 1The 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 present invention. Equivalent modifications and variations made by those skilled in the art in accordance with the spirit of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. A weak similarity generation method based on style transfer, characterized in that, Includes the following steps: S10. Redraw the style reference image to generate a clear style image; S20. Extract the visual elements of the clear style map, and map the visual elements to the target content image through an adaptive style injection mechanism to generate an initial result image; S30. Optimize the initial result image to generate an adjusted result image; S40. Perform multi-scale optimization on the adjusted image. The multi-scale optimization includes image segmentation, semantic structure analysis, and semantic-guided redrawing to obtain the optimized image. S50. Perform semantic region classification on the optimized image, use bilateral filtering to assist in optimization, and generate the final style image.

2. The style transfer-based weak similarity generation method according to claim 1, characterized in that, Specifically, S10 is: S11. Adjust the diffusion process parameters of the Flux model according to preset conditions. The diffusion process parameters include classifier guidance and sampling steps. S12. The Flux model uses flow matching to input the style reference image into the Flux model to generate a preliminary refinement image; S13. Parallel diffusion is used to perform parallel image retouching on the preliminary refined image, and optimization is performed through Transformer block pairs to generate a clear style image. Specifically, S20 is: S21. Identify the sharp style map using the CLIP model to obtain the main body region and background region of the sharp style map; S22. Adjust the style features of the adaptive style injection mechanism in the latent space of the Flux-Redux tool, and set the style feature weights of the main body region and the background region; The strength of the adaptive style injection mechanism is adjusted based on the semantic classification result of the target content image; S23. In the latent space of the Flux-Redux tool, adjust the style feature weights of the adaptive style injection mechanism, including: S231. Set the style feature weights of the main body region and the background region of the clear style map; the style feature weight of the main body region is less than the style feature weight of the background region; S232. Input the target content image into an image classification model to obtain the semantic category label of the target content image; adjust the style feature weights of the target content image according to the semantic category label; S24. Generate the initial result image; Specifically, S30 is: S31. Input the initial result image and the target content image into the Florence model, compare the texture features of the initial result image and the target content image, and locate the texture misalignment problem points of the initial result image; S32. Using the layer feature visualization tool of the Flux-Redux model, the initial result image is divided into shallow model layer and medium model layer; the texture misalignment problem points are associated with the shallow model layer or the medium model layer to determine the model layer that needs intervention; The texture misalignment problem points and the model layers requiring intervention are generated as repair information; S33. Based on the repair information, optimize the initial result image using LoRA technology to generate an adjusted result image.

3. The method for generating weak similarity based on style transfer according to claim 1, characterized in that, Specifically, S40 is as follows: S41. The adjusted image is upsampled by 2 pixels, and the upsampled adjusted image is divided into blocks using TTP block segmentation technology to obtain image blocks; S42. Use the Florence model to extract the semantic structure information of each image patch; the semantic structure information includes object contours, region segmentation, and color distribution features; S43. Apply the Flux model to redraw each image block based on its semantic structure information, stitch together the redrawn image blocks, optimize the transition between each image block, and output the optimized result image.

4. The style transfer-based weak similarity generation method according to claim 1, characterized in that, Specifically, S50 is as follows: S51. The Florence model is used to identify the semantic regions of the optimized image, and the semantic regions are divided into core structure regions, style expression regions and transition regions. Customized filtering parameters are applied to the semantic regions of the different classifications, and the filtering parameters include σ. d and σ r , σ d It is the spatial domain standard deviation, used to control the size of the filter window, σ r It is the standard deviation of the value range, used to control the tolerance for color differences; the specific filter parameters customized for the semantic regions of the different classifications are as follows: Core structural region: σ d1 and σ r1 Set as the first preset value; Style expression area: σ d2 and σ r2 Set to the second preset value; Transitional connection area: σ d3 and σ r3 Set to the third preset value; The first preset value is less than the third preset value; the third set threshold is less than the second preset value; S52. Calculate the spatial proximity weight w using the aforementioned filter parameters. s (i,j): The (x,y) values ​​represent the target pixel coordinates. S53. Calculate the pixel value similarity weight w using the aforementioned filtering parameters. r (i,j): (x,y) represents the target pixel coordinates, (i,j) represents the neighborhood pixel coordinates, and I(x,y)−I(i,j) represents the color difference between the target pixel and the neighborhood pixel. S54. Substitute the spatial proximity weight ws(i,j) and pixel value similarity weight wr(i,j) into the bilateral filtering calculation to obtain the pixel value Ifiltered(x,y) of the filtered image at the target pixel: The Ω is a filtering window centered on the target pixel (x,y), and the filtering window is a set of neighboring pixels; I(i,j) is the pixel value of the optimized image at the neighboring pixel (i,j). ws(i,j) is the spatial proximity weight; The wr(i,j) is the pixel value similarity weight; S55. Use the Ifiltered(x,y) to synthesize the stylized result image.

5. A weak similarity generation device based on style transfer, characterized in that, Includes the following modules: The Clear Style Map module redraws the style reference map and generates a clear style map; The initial result image module extracts the visual elements of the clear style map, maps the visual elements to the target content image through an adaptive style injection mechanism, and generates the initial result image. The adjustment result image module optimizes the initial result image to generate an adjusted result image; The optimized result image module performs multi-scale optimization on the adjusted result image. The multi-scale optimization includes image segmentation, semantic structure analysis, and semantically guided redrawing to obtain the optimized result image. The final style image module performs semantic region classification on the optimized image, uses bilateral filtering to assist in optimization, and generates the final style image.

6. The style transfer-based weak similarity generation device according to claim 5, characterized in that, The clear style map module includes the following units: The diffusion unit adjusts the diffusion process parameters of the Flux model according to preset conditions. The diffusion process parameters include classifier guidance and sampling steps. The flow matching unit uses flow matching to input the style reference image into the flow model to generate a preliminary refinement image; The block optimization unit uses parallel diffusion to perform parallel image retouching on the preliminary refined image, and optimizes it through Transformer block pairs to generate a clear style image; The initial result image module includes the following units: The recognition unit identifies the sharp style map using the CLIP model to obtain the main body region and background region of the sharp style map; The style feature unit adjusts the style features of the adaptive style injection mechanism in the latent space of the Flux-Redux tool, and sets the style feature weights of the main body region and the background region. The strength of the adaptive style injection mechanism is adjusted based on the semantic classification result of the target content image; The latent space unit, within the latent space of the Flux-Redux tool, adjusts the style feature weights of the adaptive style injection mechanism, including: The region weighting subunit sets the style feature weights of the main body region and the background region of the clear style map; the style feature weight of the main body region is less than the style feature weight of the background region. The weight subunit is adjusted by inputting the target content image into the image classification model to obtain the semantic category label of the target content image; the style feature weights of the target content image are adjusted according to the semantic category label. The generation unit generates the initial result image; The adjusted image module specifically includes the following units: The problem point unit inputs the initial result image and the target content image into the Florence model, compares the texture features of the initial result image and the target content image, and locates the texture misalignment problem points in the initial result image; The model layer unit uses a layer feature visualization tool for the Flux-Redux model to divide the initial result image into shallow model layers and medium model layers; the texture misalignment problem points are associated with the shallow model layer or the medium model layer to determine the model layer that needs intervention; The texture misalignment problem points and the model layers requiring intervention are generated as repair information; The repair and optimization unit optimizes the initial result image based on the repair information using LoRA technology to generate an adjusted result image.

7. The style transfer-based weak similarity generation device according to claim 5, characterized in that, The optimized result image module is specifically as follows: Image scaling and segmentation unit: Upsamples the adjusted image by 2 pixels, and segments the upsampled adjusted image into blocks using TTP segmentation technology to obtain image blocks; Semantic structure analysis unit: Uses the Florence model to extract the semantic structure information of each image patch; the semantic structure information includes object contours, region segmentation, and color distribution features; Semantic-guided redrawing unit: Applying the Flux model, redrawing each image block based on semantic structure information, stitching together the redrawn image blocks, optimizing the transition between each image block, and outputting the optimized result image.

8. The style transfer-based weak similarity generation device according to claim 5, characterized in that, The final style image module is specifically: The semantic partitioning unit uses the Florence model to identify the semantic regions of the optimized image and divides the semantic regions into core structure regions, style expression regions, and transition regions. Customized filtering parameters are implemented for the semantic regions of the different classifications. These parameters include σd and σr, where σd is the spatial domain standard deviation used to control the size of the filtering window, and σr is the value domain standard deviation used to control the color difference tolerance. Specifically, the customized filtering parameters for the semantic regions of the different classifications are as follows: Core structural region: σd1 and σr1 are set to the first preset value; Style expression area: σd2 and σr2 are set to the second preset value; Transitional connection area: σd3 and σr3 are set to the third preset value; The first preset value is less than the third preset value; the third set threshold is less than the second preset value; The spatial proximity weights ws(i,j) of the ws(i,j) unit are calculated using the aforementioned filtering parameters: The (x,y) values ​​represent the target pixel coordinates. The wr(i,j) unit calculates the pixel value similarity weight wr(i,j) using the aforementioned filtering parameters: (x,y) represents the target pixel coordinates, (i,j) represents the neighborhood pixel coordinates, and I(x,y)−I(i,j) represents the color difference between the target pixel and the neighborhood pixel. For the pixel value unit, the spatial proximity weight ws(i,j) and pixel value similarity weight wr(i,j) are substituted into the bilateral filtering calculation to obtain the pixel value Ifiltered(x,y) of the filtered image at the target pixel: The Ω is a filtering window centered on the target pixel (x,y), and the filtering window is a set of neighboring pixels; I(i,j) is the pixel value of the optimized image at the neighboring pixel (i,j). ws(i,j) is the spatial proximity weight; The wr(i,j) is the pixel value similarity weight; The final optimization unit uses Ifiltered(x,y) to synthesize the stylized result image.

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.