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

[PPDiffusers] StableDiffusion Pipeline 升级 #390

Merged
merged 3 commits into from
Jan 22, 2024

Conversation

co63oc
Copy link
Contributor

@co63oc co63oc commented Jan 17, 2024

#377

完成1,2,3代码和单测,4和3单测相同
暂时测试可以,有其他问题再找时间修改

pytest test_stable_diffusion_img2img.py
image

pytest test_stable_diffusion_inpaint.py
image

pytest test_stable_diffusion_inpaint_legacy.py
image

Copy link

paddle-bot bot commented Jan 17, 2024

Thanks for your contribution!

@JunnYu
Copy link
Member

JunnYu commented Jan 18, 2024

ok, 我看看

@JunnYu JunnYu changed the title StableDiffusion Pipeline 升级 [PPDiffusers] StableDiffusion Pipeline 升级 Jan 18, 2024
@JunnYu
Copy link
Member

JunnYu commented Jan 18, 2024

不错,当前我这里测试的stable diffusion底下的单测都是正确的。
image

@co63oc 你好最后一个打错了,应该是这个文件,你可以再增加一下 https://github.com/huggingface/diffusers/blob/v0.24.0/tests/pipelines/stable_diffusion/test_stable_diffusion.py

@JunnYu
Copy link
Member

JunnYu commented Jan 18, 2024

然后可以再测一下对应的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)
Copy link
Member

Choose a reason for hiding this comment

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

torch_dtype改成paddle_dtype

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

@JunnYu
Copy link
Member

JunnYu commented Jan 18, 2024

代码中涉及到的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)
Copy link
Member

Choose a reason for hiding this comment

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

cast(dtype=xxx)

Copy link
Contributor Author

@co63oc co63oc Jan 19, 2024

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
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

@co63oc
Copy link
Contributor Author

co63oc commented Jan 19, 2024

然后可以再测一下对应的slow的单测文件,export RUN_SLOW=True export RUN_NIGHTLY=True

已修改测试
test_stable_diffusion_inpaint.py
image

test_stable_diffusion_img2img.py 和develop分支相同两项测试不通过
image

test_stable_diffusion.py
image

test_stable_diffusion_inpaint_legacy.py
image

@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Jan 19, 2024
@JunnYu
Copy link
Member

JunnYu commented Jan 22, 2024

OK, 你现在将最新的0.24.0(因为刚刚合入了一个新的关于scheduler和models单测的PR)合进去后,再重新跑一下题目中的4个文件对应的单测内容,跑完之后看看还有没有其他问题,如果没有就可以合入了(上面2个数值不通过的问题,可以忽略,这是nightly的)

@co63oc
Copy link
Contributor Author

co63oc commented Jan 22, 2024

OK, 你现在将最新的0.24.0(因为刚刚合入了一个新的关于scheduler和models单测的PR)合进去后,再重新跑一下题目中的4个文件对应的单测内容,跑完之后看看还有没有其他问题,如果没有就可以合入了(上面2个数值不通过的问题,可以忽略,这是nightly的)

合并后SLOW测试不通过,比如 test_stable_diffusion_img2img.py::StableDiffusionImg2ImgPipelineSlowTests::test_stable_diffusion_img2img_ddim,pipeline生成的数据是随机的

@JunnYu
Copy link
Member

JunnYu commented Jan 22, 2024

好的,我这里试一下

@JunnYu
Copy link
Member

JunnYu commented Jan 22, 2024

OK,就这两个问题,可以合入了,这两个问题稍后再一起解决。

@JunnYu JunnYu merged commit 64bfe32 into PaddlePaddle:upgrade_ppdiffusers0240 Jan 22, 2024
1 check passed
@co63oc co63oc deleted the test1 branch February 18, 2024 07:02
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.

3 participants