portu-sim / sd-webui-bmab

Auto masking and inpainting for person, face, hand. Resizing image using detection model.
GNU Affero General Public License v3.0
307 stars 30 forks source link

RuntimeError: Sizes of tensors must match except in dimension 0. Expected size 1280 but got size 768 for tensor number 1 in the list #26

Open harpy2 opened 7 months ago

harpy2 commented 7 months ago

안녕하세요

현재 메인 이미지 생성은 sdxl모델로하고 bmab 통해서 얼굴만 sd1.5모델로 생성하려고 합니다

webui에서 bmab > context > checkpoint에 sd1.5모델 넣어서 face detailer 설정하면 원하는대로 생성이 잘 됩니다 근데 API로 진행하면 아래와 같은 오류가 나옵니다

Using already loaded model turbovisionxlSuperFastXLBasedOnNew_tvxlV431Bakedvae.safetensors [b62ddba1a6]: done in 0.1s Traceback (most recent call last): File "/stable-diffusion-webui/extensions/z_bmab/sd_bmab/pipeline/post/mainpipe.py", line 63, in process ret = proc.process(context, processed) File "/stable-diffusion-webui/extensions/z_bmab/sd_bmab/processors/detailer/face.py", line 184, in process img2img_imgage = process_img2img(context.sdprocessing, image, options=options) File "/stable-diffusion-webui/extensions/z_bmab/sd_bmab/base/process.py", line 106, in process_img2img processed = process_images(img2img) File "/stable-diffusion-webui/modules/processing.py", line 734, in process_images res = process_images_inner(p) File "/stable-diffusion-webui/extensions/sd-webui-controlnet/scripts/batch_hijack.py", line 41, in processing_process_images_hijack return getattr(processing, '__controlnet_original_process_images_inner')(p, *args, kwargs) File "/stable-diffusion-webui/modules/processing.py", line 857, in process_images_inner p.setup_conds() File "/stable-diffusion-webui/modules/processing.py", line 469, in setup_conds self.uc = self.get_conds_with_caching(prompt_parser.get_learned_conditioning, negative_prompts, total_steps, [self.cached_uc], self.extra_network_data) File "/stable-diffusion-webui/modules/processing.py", line 455, in get_conds_with_caching cache[1] = function(shared.sd_model, required_prompts, steps, hires_steps, shared.opts.use_old_scheduling) File "/stable-diffusion-webui/modules/prompt_parser.py", line 188, in get_learned_conditioning conds = model.get_learned_conditioning(texts) File "/stable-diffusion-webui/modules/sd_models_xl.py", line 31, in get_learned_conditioning c = self.conditioner(sdxl_conds, force_zero_embeddings=['txt'] if force_zero_negative_prompt else []) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1568, in _call_impl result = forward_call(args, kwargs) File "/stable-diffusion-webui/repositories/generative-models/sgm/modules/encoders/modules.py", line 141, in forward emb_out = embedder(batch[embedder.input_key]) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, kwargs) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(*args, *kwargs) File "/stable-diffusion-webui/modules/sd_hijack_clip.py", line 234, in forward z = self.process_tokens(tokens, multipliers) File "/stable-diffusion-webui/modules/sd_hijack_clip.py", line 273, in process_tokens z = self.encode_with_transformers(tokens) File "/stable-diffusion-webui/modules/sd_hijack_open_clip.py", line 57, in encode_with_transformers d = self.wrapped.encode_with_transformer(tokens) File "/stable-diffusion-webui/repositories/generative-models/sgm/modules/encoders/modules.py", line 467, in encode_with_transformer x = self.model.token_embedding(text) # [batch_size, n_ctx, d_model] File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(args, kwargs) File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(*args, **kwargs) File "/stable-diffusion-webui/modules/sd_hijack.py", line 359, in forward tensor = torch.cat([tensor[0:offset + 1], emb[0:emb_len], tensor[offset + 1 + emb_len:]]) RuntimeError: Sizes of tensors must match except in dimension 0. Expected size 1280 but got size 768 for tensor number 1 in the list.

아래는 API payload입니다

'BMAB': { 'args': [ { 'enabled': True, "preprocess_checkpoint": "salmonholic_real_v2.8.safetensors", "preprocess_vae": "vae-ft-mse-840000-ema-pruned.ckpt", 'face_detailing_enabled': True, "module_config": { "face_detailing_opt": { "best_quality": True, "sort_by": "Score", "limit": 1, "prompt0": ",korean idol mix, clean skin,", "negative_prompt0": "", "override_parameter": False, "sampler": "DPM++ 3M SDE Karras", "detection_model": "BMAB Face(Normal)", "dilation": 4, "box_threshold": 0.35, "skip_large_face": False, "large_face_pixels": 0.26 }, "face_detailing": { "width": 512, "height": 512, "cfg_scale": 4, "steps": 12, "mask_blur": 4, "inpaint_full_res": "Only masked", "inpaint_full_res_padding": 32, "denoising_strength": 0.38 }, } } ] }

webui에서 설정한 내용과 동일하게 API 구성한 것 같은데 왜 사이즈가 다르다는 오류가 나는지 모르겠습니다 도움 부탁드립니다!

portu-sim commented 7 months ago

check point 변경이 안되는 문제가 있을 것 같습니다. 확인 해보고 답변 드리겠습니다.

portu-sim commented 7 months ago

확인 해봤는데 sdxl을 이용해서, SD 1.5 checkpoint 를 load하는 부분이 문제가 되는 것 같습니다. 아무래도 SD-WEBUI 버그로 보이는데, 이 부분은 계속 추적해보겠습니다.

harpy2 commented 7 months ago

신경써주셔서 감사합니다 bmab과는 상관없는 오류였군요