Just code snippet
- VRAM Usage: This method requires increased VRAM usage. The exact amount depends on the image resolution.
- Update three .py files in the comfy/ldm/flux directory. Note: Make sure to backup the original files before making any changes.
- Place the
variables.json
file in the root directory of the repository.
-
Set the mode in
variables.json
to "write" and use the write workflow. -
In the workflow:
- Add a reference image to the "Load Image" node.
- Add a black image of the same size as the reference image to the "Load Image (as mask)" node.
-
Queue the workflow. (This will create a "tensor data" folder containing latent images with added noise based on the reference image)
-
Change the mode in
variables.json
to "ref" and use the ref workflow. -
Add a reference image to the "Load Image" node. (It doesn't have to be the same reference image, but it should be the same size)
-
Input your prompt. (Accurate prompting is crucial. I personally use ChatGPT to describe the reference image in 150 words)
-
Queue the workflow.
mode
: Switch between "write", "ref", and "normal".kfactor
: Reference strength (1.1-1.3 is recommended. Small changes can significantly affect the result)vfactor
: Another reference strength (can be changed, but not recommended)tfactor_pairs
: Reference strength coefficient for each timestep- Other parameters are for internal processing and should not be changed.
- Image-to-image (i2i) is possible, but you need to run the write mode when changing the number of steps or denoise amount for the first time.
- This method may have difficulty processing images where there is a high ratio of background to subject (i.e., where the background contains a lot of information or the subject is small relative to the background).