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

Checkpoint Merger #271

Closed
chenjjcccc opened this issue Oct 31, 2023 · 0 comments
Closed

Checkpoint Merger #271

chenjjcccc opened this issue Oct 31, 2023 · 0 comments
Assignees
Labels
HappyOpenSource Pro 快乐开源issue与PR,更具挑战的任务

Comments

@chenjjcccc
Copy link

chenjjcccc commented Oct 31, 2023

Checkpoint Merger

任务描述

任务背景

  • PaddleMIX ppdiffusers新增 checkpoint merger pipeline。

完成步骤

1.参考代码,新增 checkpoint merger pipeline
2.支持合并和保存多个不同权重 ,保证合并后生成结果对齐

提交内容:

  1. 提交到目录
@shiyutang shiyutang added the HappyOpenSource Pro 快乐开源issue与PR,更具挑战的任务 label Oct 31, 2023
westfish pushed a commit that referenced this issue Mar 27, 2024
#271 Checkpoint Merger
生成结果对齐:
CompVis/stable-diffusion-v1-4 + runwayml/stable-diffusion-v1-5
## torch

![CompVis_runwayml_1](https://github.com/PaddlePaddle/PaddleMIX/assets/93063038/1b090fbc-4300-490a-b551-3b629bc17f9a)
代码如下:
```python
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](https://github.com/PaddlePaddle/PaddleMIX/assets/93063038/d3059125-b7a4-4506-8516-1407c14cde10)
代码如下:
```python
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")
```
结果一致
@luotao1 luotao1 closed this as completed Mar 27, 2024
westfish pushed a commit to westfish/PaddleMIX that referenced this issue Sep 25, 2024
PaddlePaddle#271 Checkpoint Merger
生成结果对齐:
CompVis/stable-diffusion-v1-4 + runwayml/stable-diffusion-v1-5
## torch

![CompVis_runwayml_1](https://github.com/PaddlePaddle/PaddleMIX/assets/93063038/1b090fbc-4300-490a-b551-3b629bc17f9a)
代码如下:
```python
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](https://github.com/PaddlePaddle/PaddleMIX/assets/93063038/d3059125-b7a4-4506-8516-1407c14cde10)
代码如下:
```python
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")
```
结果一致
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HappyOpenSource Pro 快乐开源issue与PR,更具挑战的任务
Projects
None yet
Development

No branches or pull requests

4 participants