Skip to content

restore and edit a natural image #13

@ohad204

Description

@ohad204

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()

The 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