facechain icon indicating copy to clipboard operation
facechain copied to clipboard

gradio.exceptions.Error: '没有人物LoRA,请先训练(There is no character LoRA, please train first)

Open mzxhzhp opened this issue 2 years ago • 2 comments

问题描述: 在 Windows web-ui 本地部署时, 人物形象训练阶段,基础模型选择 “AI-ModelScope/stable-diffusion-v1-5”,则在 “无限风格形象写真” 阶段只能选择 “写实模型(Realistic sd_1.5 model)”,选择 “写真模型(Photorealistic_sd_1.5 model)” 则会报错: gradio.exceptions.Error: '没有人物LoRA,请先训练(There is no character LoRA, please train first)

观察 app.py 中的代码发现,当选择写真模型时,它就会去 AI-ModelScope/stable-diffusion-xl-base-1.0/ 目录下查找 pytorch_lora_weights.bin 文件,当然就找不到了。 我的疑问是:

  1. 为啥 sd 1.5 model 的基础模型,选择写真风格时,要去 AI-ModelScope/stable-diffusion-xl-base-1.0/ 目录找模型文件?
  2. 为啥只有本地部署时才会有这个问题?我使用官网的在线体验,基础模型是 sd 1.5 model 时,在无限风格形象写真那里是可以选择写真模型的。

此外, 而如果在人物形象训练阶段,基础模型选择 AI-ModelScope/stable-diffusion-xl-base-1.0,则在无限风格写真那里选择写真模型时,由于存在 AI-ModelScope/stable-diffusion-xl-base-1.0/ 目录,所以报不会报 gradio.exceptions.Error: '没有人物LoRA,请先训练(There is no character LoRA, please train first) 的错误,但是却发生另一个错误: File "D:\workspace\xxxxx\extensions\facechain\facechain\merge_lora.py", line 85, in merge_lora curr_layer.weight.data += multiplier * alpha * torch.mm(weight_up, weight_down) RuntimeError: The size of tensor a (768) must match the size of tensor b (2048) at non-singleton dimension 1 提示:Python 运行时抛出了一个异常。请检查疑难解答页面。

这又是怎么回事呢?

有没有大神可以指点迷津一下,非常感谢!

mzxhzhp avatar Dec 19 '23 09:12 mzxhzhp

[DDDDD] ================================================================ [DDDDD] weight_up shape: torch.Size([640, 4]) [DDDDD] weight_down shape: torch.Size([4, 2048]) [DDDDD] curr_layer.weight.data shape: torch.Size([640, 768]) [DDDDD] else, weight_up shape: torch.Size([640, 4]) [DDDDD] else, weight_down shape: torch.Size([4, 2048]) [DDDDD] else, alpha: 1.0 [DDDDD] else, multiplier: 0.9 concurrent.futures.process._RemoteTraceback: """ Traceback (most recent call last): File "D:\workspace\xxxxx\python\lib\concurrent\futures\process.py", line 246, in _process_worker r = call_item.fn(*call_item.args, **call_item.kwargs) File "D:\workspace\xxxxx\extensions\facechain\facechain\inference.py", line 559, in call gen_results = main_model_inference(self.pose_model_path, self.pose_image, self.use_depth_control, File "D:\workspace\xxxxx\extensions\facechain\facechain\inference.py", line 438, in main_model_inference return main_diffusion_inference(pos_prompt, neg_prompt, input_img_dir, base_model_path, File "D:\workspace\xxxxx\extensions\facechain\facechain\inference.py", line 195, in main_diffusion_inference pipe = merge_lora(pipe, lora_human_path, multiplier_human, from_safetensor=lora_human_path.endswith('safetensors'), device='cuda') File "D:\workspace\xxxxx\extensions\facechain\facechain\merge_lora.py", line 92, in merge_lora curr_layer.weight.data += multiplier * alpha * torch.mm(weight_up, weight_down) RuntimeError: The size of tensor a (768) must match the size of tensor b (2048) at non-singleton dimension 1

显然,报错的原因是 curr_layer.weight.data 的形状是 [640, 768],无法与 [640, 2048] 的矩阵相加。

mzxhzhp avatar Dec 19 '23 09:12 mzxhzhp

做了对比测试,发现只有 web-ui 中才会遇到这种问题,单纯的 Linux 本地部署则是正常的。

mzxhzhp avatar Dec 26 '23 01:12 mzxhzhp

please try out the newest train-free, 10s inference version facechain-fact.

sunbaigui avatar Jun 04 '24 09:06 sunbaigui