Skip to content

refactor kandinsky img2img for ddpm - #3845

Closed
yiyixuxu wants to merge 1 commit into
mainfrom
kandinsky-img2img-refactor
Closed

refactor kandinsky img2img for ddpm#3845
yiyixuxu wants to merge 1 commit into
mainfrom
kandinsky-img2img-refactor

Conversation

@yiyixuxu

@yiyixuxuyiyixuxu commented Jun 21, 2023

Copy link
Copy Markdown
Collaborator

this PR refactor the img2img so that it's compatible with ddpm scheduler

fromdiffusersimportKandinskyImg2ImgPipeline, KandinskyPriorPipeline, DDPMSchedulerfromPILimportImageimporttorchREPO_PRIOR="kandinsky-community/kandinsky-2-1-prior"REPO="kandinsky-community/kandinsky-2-1"model_dtype=torch.float16prompt="A red cartoon frog, 4k"# create prior pipe_prior=KandinskyPriorPipeline.from_pretrained(REPO_PRIOR, torch_dtype=model_dtype)
pipe_prior.to("cuda")
# create img2img pipelinescheduler=DDPMScheduler.from_pretrained(REPO, subfolder="ddpm_scheduler")
pipe=KandinskyImg2ImgPipeline.from_pretrained(REPO, scheduler=scheduler, torch_dtype=model_dtype)
pipe.to("cuda")
# use prior to generate image_emb based on our promptgenerator=torch.Generator(device='cuda').manual_seed(0)
image_emb, zero_image_emb=pipe_prior(prompt, num_inference_steps=25, generator=generator,).to_tuple()
init_image=Image.open("frog.png")
generator=torch.Generator(device='cuda').manual_seed(0)
out=pipe(
prompt=prompt, image=init_image, height=768, width=768, num_inference_steps=100, generator=generator, image_embeds=image_emb, negative_image_embeds=zero_image_emb, strength=0.2,) out.images[0].save("frog_out.png")

yiyi_test_img2img_ddpm_out

@yiyixuxuyiyixuxu changed the title refactor refactor kandinsky img2imgJun 21, 2023
@yiyixuxuyiyixuxu changed the title refactor kandinsky img2img refactor kandinsky img2img for ddpmJun 21, 2023
@HuggingFaceDocBuilderDev

HuggingFaceDocBuilderDev commented Jun 21, 2023

Copy link
Copy Markdown

The documentation is not available anymore as the PR was closed or merged.

@patrickvonplatenpatrickvonplaten left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's maybe add a test here as well no?

@patrickvonplaten

Copy link
Copy Markdown
Contributor

@yiyixuxu let's try to get this in :-)

@github-actions

Copy link
Copy Markdown
Contributor

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

@github-actionsgithub-actionsBot added the stale Issues that haven't received updates label Jul 22, 2023
@patrickvonplaten

Copy link
Copy Markdown
Contributor

@yiyixuxu is this still open?

@yiyixuxu
yiyixuxu deleted the kandinsky-img2img-refactor branch July 14, 2024 19:28
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

staleIssues that haven't received updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@yiyixuxu@HuggingFaceDocBuilderDev@patrickvonplaten