-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Hi,
For my project, I'm trying to edit a natural image.
However, I noticed that the edited image looks nothing like the original.
Even when I try to restore the original image using the same prompt, the result is still completely different.
Could you help me understand what's going wrong?
The code:
import torch
from diffusers import FluxPipeline
import matplotlib.pyplot as plt
from PIL import Image
pipe = FluxPipeline.from_pretrained(
"black-forest-labs/FLUX.1-dev",
torch_dtype=torch.bfloat16,
custom_pipeline="pipeline_flux_rf_inversion")
pipe.to("cuda")
image = Image.open("_DSC9191.JPG")
new_width = 3312
new_height = 3312
width, height = image.size # Get dimensions
left = (width - new_width)/2
top = (height - new_height)/2
right = (width + new_width)/2
bottom = (height + new_height)/2
image = image.crop((left, top, right, bottom))
inverted_latents, image_latents, latent_image_ids = pipe.invert(
source_prompt='garden of flowers',
image=image,
num_inversion_steps=28,
gamma=1.0
)
edited_image = pipe(
prompt="garden of flowers",
inverted_latents=inverted_latents,
image_latents=image_latents,
latent_image_ids=latent_image_ids,
start_timestep=1/28,
stop_timestep=7/28,
num_inference_steps=28,
eta=0.9,
).images[0]
plt.imshow(edited_image); plt.show()