Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

image 2 image surpport #22

Open
zdxpan opened this issue Feb 13, 2025 · 1 comment
Open

image 2 image surpport #22

zdxpan opened this issue Feb 13, 2025 · 1 comment

Comments

@zdxpan
Copy link

zdxpan commented Feb 13, 2025

i have try input latents of image into Lumina2Text2ImgPipeline, and only run the last 30% percent of denoising process

`

strength = 0.30, # pass the param from call

4. Prepare latents.

is_i2i = latents is not None

...
timesteps, num_inference_steps = retrieve_timesteps(
self.scheduler,
num_inference_steps,
device,
sigmas=sigmas,
mu=mu,
)
if is_i2i:
sub_steps = min(int(num_inference_steps * strength), num_inference_steps)
start_step_idx = max(num_inference_steps - sub_steps, 0) * self.scheduler.order
timesteps = timesteps[start_step_idx:]
....

    # 6. Denoising loop
    with self.progress_bar(total=len(timesteps)) as progress_bar:
        for i, t in enumerate(timesteps):

....

`

inference code:
`
prompt_s = 'The image presents a serene and idyllic landscape, meticulously crafted to evoke a sense of tranquility and natural beauty. At the forefront, an array of vibrant wildflowers, including daisies with bright yellow centers and white petals, adds a splash of color against the lush green grass. The flowers are in sharp focus, suggesting they are closer to the viewer, while the background gradually fades into soft focus as it recedes into the distance.\n\nA calm pond occupies the center of the composition, its surface acting as a mirror that reflects the surrounding verdant hills, dotted with a variety of flowering plants. This reflection creates a symmetrical balance within the scene, enhancing its aesthetic appeal. A single butterfly is captured mid-flight above the water, adding a dynamic element to the otherwise still setting. Its wings are spread wide, showcasing a vivid pattern that contrasts with the smooth texture of the sky.\n\nThe sky itself is a canvas painted with broad strokes of blue, punctuated by fluffy white clouds that seem almost tangible. The sunlight filters through these clouds, casting gentle highlights on the landscape below and creating a play of light and shadow that adds depth to the scene. In the far distance, rolling hills fade into a misty haze, contributing to the sense of vastness and openness.\n\nThe overall style of the image is reminiscent of digital art or a high-quality illustration, characterized by its clarity, rich colors, and attention to detail. The use of perspective draws the eye from the foreground flowers towards the distant hills, inviting the viewer to explore this peaceful haven further. The absence of human presence emphasizes the untouched nature of this idyllic setting, making it feel like a hidden gem waiting to be discovered.'

sys_prompt = "You are an assistant designed to generate superior images with the superior degree of image-text alignment based on textual prompts or user prompts. "
with torch.no_grad():
i2i_generated_image = pipe(
prompt_s, system_prompt = sys_prompt, latents=out, strength = 0.30,
height=1024, width=1024, guidance_scale=7.5,
num_inference_steps=30, cfg_trunc_ratio=1, cfg_normalization=False,
generator=torch.Generator("cpu").manual_seed(0),
# output_type='latent'
).images[0]
# image# .save("lumina_demo.png")

from diffusers.utils import make_image_grid

make_image_grid(
[original_image, i2i_generated_image], 1, 2
)

`

and get the result like below, how to make it more detail?

Image
@zhuole1025
Copy link

Sorry, we do not support the Img2Img pipeline in diffusers right now. The above code has some problems: In the i2i setting, you should also add noise to the input image to the corresponding denoising strength. Please refer to img2img pipeline of flux: https://github.com/huggingface/diffusers/blob/97abdd2210a540c2e71aee63c80a22723031cd57/src/diffusers/pipelines/flux/pipeline_flux_img2img.py#L771

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants