-
Notifications
You must be signed in to change notification settings - Fork 167
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] add photomaker & InstantID model #401
[PPDiffusers] add photomaker & InstantID model #401
Conversation
这么多图片,其实不太想在repo里面存放,你可以存到别的地方啥的 |
self.trigger_word = trigger_word | ||
|
||
|
||
id_encoder = PhotoMakerIDEncoder() |
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.
这个encoder看看ip adapter里面的设置就差不多了
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
from ppdiffusers.models.attention_processor import Attention | ||
from ppdiffusers.utils import USE_PEFT_BACKEND | ||
|
||
class AttnProcessor(paddle.nn.Layer): |
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.
这应该没必要重写吧,直接参考ip adapter训练的那个,因为可能未来版本会变,里面的__call__会变化
Args: | ||
x (torch.Tensor): image features | ||
shape (b, n1, D) | ||
latent (torch.Tensor): latent features |
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
ppdiffusers/examples/InstantID/pipeline_stable_diffusion_xl_instantid.py
Outdated
Show resolved
Hide resolved
|
||
if needs_upcasting: | ||
self.upcast_vae() | ||
latents = latents.to(next(iter(self.vae.post_quant_conv.parameters())).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.
这个应该不对吧, latents.to(next(iter(self.vae.post_quant_conv.named_parameters())[1]).dtype),
因为 named_parameters 才是迭代器返回的东西,迭代器是lazy的
而 parameters 直接返回一个list,然后消耗的资源不一样,list要所有都返回
ppdiffusers/examples/InstantID/pipeline_stable_diffusion_xl_instantid.py
Outdated
Show resolved
Hide resolved
可以加个gradio,加个readme啥的 |
ppdiffusers/examples/InstantID/pipeline_stable_diffusion_xl_instantid.py
Outdated
Show resolved
Hide resolved
ppdiffusers/examples/InstantID/pipeline_stable_diffusion_xl_instantid.py
Outdated
Show resolved
Hide resolved
提交的时候使用 pre-commit 格式化一下代码,详细参考 这种使用方式。https://github.com/PaddlePaddle/PaddleNLP/blob/develop/CONTRIBUTING.md#6-commit |
|
||
|
||
def main(pretrained_model_name_or_path="wangqixun/YamerMIX_v8", enable_lcm_arg=False): | ||
vae = AutoencoderKL.from_pretrained(pretrained_model_name_or_path, subfolder="vae", from_hf_hub=True, |
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.
这个模型是基于sdxl 1.0的,在pipe直接加载vae也有问题,只能手动加载
|
||
base_model_path = "stabilityai/stable-diffusion-xl-base-1.0" | ||
|
||
vae = AutoencoderKL.from_pretrained(base_model_path, subfolder="vae") |
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.
这
文档跟代码的写法都同步统一改一下,发现可能文档的代码跟实际的代码稍微有点出入 |
hi, @JiehangXie
|
No description provided.