-
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
[PPDiffusers] StableDiffusion Pipeline 升级 #390
Conversation
Thanks for your contribution! |
ok, 我看看 |
ppdiffusers/ppdiffusers/schedulers/scheduling_k_dpm_2_discrete.py
Outdated
Show resolved
Hide resolved
不错,当前我这里测试的stable diffusion底下的单测都是正确的。 @co63oc 你好最后一个打错了,应该是这个文件,你可以再增加一下 https://github.com/huggingface/diffusers/blob/v0.24.0/tests/pipelines/stable_diffusion/test_stable_diffusion.py |
然后可以再测一下对应的slow的单测文件,export RUN_SLOW=True export RUN_NIGHTLY=True |
>>> from ppdiffusers import StableDiffusionImg2ImgPipeline | ||
|
||
>>> model_id_or_path = "runwayml/stable-diffusion-v1-5" | ||
>>> pipe = StableDiffusionImg2ImgPipeline.from_pretrained(model_id_or_path, torch_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.
torch_dtype改成paddle_dtype
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(dtype)改成cast dtype,因为paddle的to是inplace操作,跟torch的操作不一样,可能未来某些时候会产生隐藏bug |
else: | ||
prompt_embeds_dtype = prompt_embeds.dtype | ||
|
||
prompt_embeds = prompt_embeds.to(dtype=prompt_embeds_dtype) |
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.
cast(dtype=xxx)
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.
已修改,test_stable_diffusion_inpaint_legacy.py 中部分使用to,如果使用cast有类型错误
# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.encode_image | ||
def encode_image(self, image, num_images_per_prompt): | ||
# dtype = next(self.image_encoder.parameters()).dtype | ||
dtype = next(self.image_encoder.parameters())[1].dtype |
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.
这里不能跟torch一样,因为paddle的parameters()不是迭代器拿到,而named_parameters()是迭代器,不过多了个name
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.
已修改
OK, 你现在将最新的0.24.0(因为刚刚合入了一个新的关于scheduler和models单测的PR)合进去后,再重新跑一下题目中的4个文件对应的单测内容,跑完之后看看还有没有其他问题,如果没有就可以合入了(上面2个数值不通过的问题,可以忽略,这是nightly的) |
合并后SLOW测试不通过,比如 test_stable_diffusion_img2img.py::StableDiffusionImg2ImgPipelineSlowTests::test_stable_diffusion_img2img_ddim,pipeline生成的数据是随机的 |
好的,我这里试一下 |
OK,就这两个问题,可以合入了,这两个问题稍后再一起解决。 |
#377
完成1,2,3代码和单测,4和3单测相同
暂时测试可以,有其他问题再找时间修改
pytest test_stable_diffusion_img2img.py
![image](https://private-user-images.githubusercontent.com/4617245/297297118-1e5bbbef-7090-43e4-b0ba-c2bfd13e98aa.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0MzEwMTksIm5iZiI6MTczOTQzMDcxOSwicGF0aCI6Ii80NjE3MjQ1LzI5NzI5NzExOC0xZTViYmJlZi03MDkwLTQzZTQtYjBiYS1jMmJmZDEzZTk4YWEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTNUMDcxMTU5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NzQ4NTZhMzI3YjNjNjIyZWJhY2NhNGRhMjE4YTRlZTE5NTE3MWY4NWYzZjk1MjkyMWFhNTQ1ZDQ1MzExZTZlNSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ._OqU2LEHZZYuhpy8Kr0UIRM1h0l0zq8-3gAJhB-QInY)
pytest test_stable_diffusion_inpaint.py
![image](https://private-user-images.githubusercontent.com/4617245/297297124-7ca9d9b8-620d-4090-b09c-5b8653ab0d64.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0MzEwMTksIm5iZiI6MTczOTQzMDcxOSwicGF0aCI6Ii80NjE3MjQ1LzI5NzI5NzEyNC03Y2E5ZDliOC02MjBkLTQwOTAtYjA5Yy01Yjg2NTNhYjBkNjQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTNUMDcxMTU5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MTg4Y2QzZTlkN2NjZGRjNGM4OTIxYzcwNzhlOTYyNTQ4MDExZjcxNmVjMWJkZTUyMTY0YjA5MmQ0NTgwNjEzMCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.zvUGUMRvJOr0Db4LDHf6cRaLlReiwsal9J5QmU6bPrA)
pytest test_stable_diffusion_inpaint_legacy.py
![image](https://private-user-images.githubusercontent.com/4617245/297297136-cd08e49f-6e90-4b7d-8c7a-6cffe7e22b90.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0MzEwMTksIm5iZiI6MTczOTQzMDcxOSwicGF0aCI6Ii80NjE3MjQ1LzI5NzI5NzEzNi1jZDA4ZTQ5Zi02ZTkwLTRiN2QtOGM3YS02Y2ZmZTdlMjJiOTAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTNUMDcxMTU5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NWZlOTY5YTUyZGVhYWIzNDA0ZDk1NTIxNzk2MTBlMGVjYjlkMGNiZTJiZjlkYjQ1NmZhNTg5ZWQ2MTU4MDExNSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.vZS-GTlJzx5SRZ89u2Be82voS79O0KyTd1Q0UcMgkns)