Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add Checkpoint Merger Pipeline #485

Merged
merged 2 commits into from
Mar 27, 2024
Merged

Conversation

InsaneOnion
Copy link
Contributor

@InsaneOnion InsaneOnion commented Mar 25, 2024

#271 Checkpoint Merger
生成结果对齐:
CompVis/stable-diffusion-v1-4 + runwayml/stable-diffusion-v1-5

torch

CompVis_runwayml_1
代码如下:

from diffusers import DiffusionPipeline
import torch

pipe = DiffusionPipeline.from_pretrained(
    "CompVis/stable-diffusion-v1-4",
    custom_pipeline="checkpoint_merger",
)

merged_pipe = pipe.merge(
    ["CompVis/stable-diffusion-v1-4", "runwayml/stable-diffusion-v1-5"],
    interp="sigmoid",
    alpha=0.4,
)

prompt = "An astronaut riding a horse on Mars"
merged_pipe.to("cuda")

image = merged_pipe(prompt, generator=torch.Generator("cuda").manual_seed(102)).images[0]
image.save("CompVis_runwayml.jpg")

paddle

CompVis_runwayml
代码如下:

from ppdiffusers import DiffusionPipeline
import paddle

pipe = DiffusionPipeline.from_pretrained(
    "CompVis/stable-diffusion-v1-4",
    custom_pipeline="/home/onion/workspace/code/pp/PaddleMIX/ppdiffusers/examples/community/checkpoint_merger",
)

merged_pipe = pipe.merge(
    ["CompVis/stable-diffusion-v1-4", "runwayml/stable-diffusion-v1-5"],
    interp="sigmoid",
    alpha=0.4,
)

prompt = "An astronaut riding a horse on Mars"

image = merged_pipe(prompt, generator=paddle.Generator("cuda").manual_seed(102)).images[0]
image.save("CompVis_runwayml.jpg")

结果一致

Copy link

paddle-bot bot commented Mar 25, 2024

Thanks for your contribution!

@InsaneOnion InsaneOnion changed the title add Checkpoint Merger Pipeline Add Checkpoint Merger Pipeline Mar 25, 2024
@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Mar 26, 2024
@luotao1 luotao1 self-assigned this Mar 26, 2024
Copy link
Contributor

@westfish westfish left a comment

Choose a reason for hiding this comment

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

LGTM

@westfish westfish merged commit ab37bfa into PaddlePaddle:develop Mar 27, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor HappyOpenSource 快乐开源活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants