Skip to content

Generated image pixels were very different from the original image #12

@DongxiaLiu15

Description

@DongxiaLiu15

hi!Thanks for your work.

When I edited with RF-inversion, the generated image pixels were very different from the original image. Here are my codes and results. I would like to know how to improve it.

  import torch
  import requests
  import PIL
  from io import BytesIO
  import yaml
  import os
  from PIL import Image
  from pipeline_flux_rf_inversion import RFInversionFluxPipeline
  from diffusers import FluxImg2ImgPipeline
  
  with open("/mnt/zhangjy80/liudx15/FlowEdit_multiobject/edits.yaml", "r") as f:
      config_list = yaml.safe_load(f)
  
  
  for idx, config in enumerate(config_list[1:]):
      input_img_path = config["input_img"]
      target_prompt = config["target_prompts"][0]
  
    
      image = Image.open(input_img_path).convert("RGB")
      image = image.resize((1024, 1024))
      pipe_invert = RFInversionFluxPipeline.from_pretrained(
      "../modelzoo_jiayu/FLUX.1-dev", torch_dtype=torch.float16).to('cuda:7')
      pipe_invert.enable_model_cpu_offload()
  
      # Inversion
      inverted_latents, image_latents, latent_image_ids = pipe_invert.invert(
          image=image, 
          num_inversion_steps=28, 
          gamma=0.5
)

# edit
edited_image = pipe_invert(
    prompt=target_prompt,
    inverted_latents=inverted_latents,
    image_latents=image_latents,
    latent_image_ids=latent_image_ids,
    start_timestep=0,
    stop_timestep=0.25,
    num_inference_steps=28,
    eta=0.9
).images[0]

# save
output_path = f"results/edited_image_{idx}.png"
os.makedirs(os.path.dirname(output_path), exist_ok=True)
edited_image.save(output_path)

print(f"✅ Saved edited image to {output_path}")`

Image

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions