Skip to content

How to specify the target image #37

Description

@LOUYWEI

I'm using the following code to achieve the "image-to-image" function. I hope to learn the logo information in the reference image based on the prompt words and edit it on the target image, but it seems that the editing is only done on image1 each time. I want to know how to modify it?

import torch
from PIL import Image
from diffusers import Flux2KleinPipeline
pipe = Flux2KleinPipeline.from_pretrained("/FLUX.2/FLUX.2-klein-9B", torch_dtype=torch.bfloat16)

pipe.enable_attention_slicing()
pipe.vae.enable_slicing()
pipe.vae.enable_tiling()
pipe.enable_model_cpu_offload() 

image1 = Image.open("/images/prompt.png").convert("RGB").resize((640, 480))
image2 = Image.open("/images/target.png").convert("RGB").resize((640, 480))

prompt = "Add a signal marker on the right wall that matches the style, shape and color of the reference marker."\
"Correct the overexposed lighting at the top so the marker is clearly visible."\
"The scene should remain realistic and consistent with an underground mine."

image = pipe(
    image=[image1, image2],
    prompt=prompt,
    height=480,
    width=640,
    guidance_scale=1.0,
    num_inference_steps=4,
    generator=torch.Generator(device=device).manual_seed(0)
).images[0]
image.save("flux-klein.png")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions