-
Notifications
You must be signed in to change notification settings - Fork 177
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
新增StableDiffusionXL Reference Control支持 #369
Conversation
Thanks for your contribution! |
请问readme里面的输出图像应该传到哪里 |
"stabilityai/stable-diffusion-xl-base-1.0", | ||
torch_dtype=paddle.float16, | ||
use_safetensors=True, | ||
variant="fp16").to('gpu:0') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.to('gpu:0') 这些to其实都不需要,可以删了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
if hasattr(self, "final_offload_hook") and self.final_offload_hook is not None: | ||
self.final_offload_hook.offload() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的代码当前都没有可以删了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
"stabilityai/stable-diffusion-xl-base-1.0", | ||
torch_dtype=paddle.float16, | ||
use_safetensors=True, | ||
variant="fp16").to('gpu:0') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.to('gpu:0')删了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
这里有跟diffusers的输出结果的对比吗?提供一下相同输入的情况下输出图片的对比 |
readme里面的图片比如直接拖拽到这个回复聊天框里面,然后里面就有上传的地址了 (https://github.com/PaddlePaddle/PaddleMIX/assets/50394665/a668321a-9caf-40aa-9aa9-4107b54b3a40) |
已经添加到了上面的comment里面 |
@Ligoml 梦姐能麻烦打个快乐开源的标签吗 |
哈喽,正常来说,torch的输出结果跟paddle的结果应该大体上一模一样的,你这里需要固定所有的随机因素,然后让两边出个相同结果的图片。当前看你提供的两个图片差距还是很大的,需要再确定一下是哪里从存在问题? |
这个随机生成的noise影响还挺大的,我本地一直加载不了huggingface上预训练的模型,一直显示connect timeout,我这里是直接用的github上的图。此外,paddle的seed跟torch的manual_seed有区别,我不太知道怎么让二者的随机种子统一。huggingface diffuser这个pipeline的样例也没有设置随机种子,可能重新跑一次diffuser的样例结果也不是这个。我目前把paddle的seed设置为149生成的图像是这样的,我认为这张图像的质量是超过了diffuser官网给出的图的。 |
你可以提供一下你使用对比的两个代码,torch和paddle的。然后我可以告诉你哪里需要对齐,比如 generator 设置的不一样,可能你torch用的是cpu的,paddle用的是gpu的。可能你两边都没有注意到这些细节的区别,正常来说是一样的。 |
torch 的代码 import torch
from PIL import Image
from diffusers.utils import load_image
from stable_diffusion_xl_reference import StableDiffusionXLReferencePipeline
from diffusers.schedulers import UniPCMultistepScheduler
input_image = load_image("https://github.com/PaddlePaddle/PaddleMIX/assets/68105073/9c8e5c53-dc9a-46bb-9504-3d75a7c22ed2")
pipe = StableDiffusionXLReferencePipeline.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0",
torch_dtype=torch.float16,
use_safetensors=True,
variant="fp16").to('cuda:0')
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
result_img = pipe(ref_image=input_image,
prompt="a dog",
num_inference_steps=20,
reference_attn=True,
reference_adain=False).images[0]
result_img.save("result.png") paddle的代码 import paddle
from PIL import Image
from ppdiffusers.utils import load_image
from pipline_stable_diffusion_xl_reference import StableDiffusionXLReferencePipeline
from ppdiffusers.schedulers import UniPCMultistepScheduler
input_image = load_image("https://github.com/PaddlePaddle/PaddleMIX/assets/68105073/9c8e5c53-dc9a-46bb-9504-3d75a7c22ed2")
pipe = StableDiffusionXLReferencePipeline.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0",
use_safetensors=True,
variant="fp16")
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
result_img = pipe(ref_image=input_image,
prompt="a dog",
num_inference_steps=20,
reference_attn=True,
reference_adain=False).images[0]
result_img.save("output.png") |
这样比较一下 import torch
from PIL import Image
from diffusers.utils import load_image
from stable_diffusion_xl_reference import StableDiffusionXLReferencePipeline
from diffusers.schedulers import UniPCMultistepScheduler
input_image = load_image("https://github.com/PaddlePaddle/PaddleMIX/assets/68105073/9c8e5c53-dc9a-46bb-9504-3d75a7c22ed2")
pipe = StableDiffusionXLReferencePipeline.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0",
torch_dtype=torch.float16,
use_safetensors=True,
variant="fp16").to('cuda:0')
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
# 设置全局的gpu seed
torch.cuda.manual_seed(42)
result_img = pipe(ref_image=input_image,
prompt="a dog",
num_inference_steps=20,
reference_attn=True,
reference_adain=False).images[0]
result_img.save("result.png") import paddle
from PIL import Image
from ppdiffusers.utils import load_image
from pipline_stable_diffusion_xl_reference import StableDiffusionXLReferencePipeline
from ppdiffusers.schedulers import UniPCMultistepScheduler
input_image = load_image("https://github.com/PaddlePaddle/PaddleMIX/assets/68105073/9c8e5c53-dc9a-46bb-9504-3d75a7c22ed2")
pipe = StableDiffusionXLReferencePipeline.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0",
use_safetensors=True,
variant="fp16")
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
# 设置全局的gpu seed
paddle.seed(42)
result_img = pipe(ref_image=input_image,
prompt="a dog",
num_inference_steps=20,
reference_attn=True,
reference_adain=False).images[0]
result_img.save("output.png") |
可能随机种子还是没有完全对齐, PaddlePaddle/Paddle#26637 |
刚看到paddle的pipeline是用的fp32跑的,这会存在区别。要指定paddle_dtype=paddle.float16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
#252