mapooon / BlendFace

[ICCV 2023] BlendFace: Re-designing Identity Encoders for Face-Swapping https://arxiv.org/abs/2307.10854
Other
170 stars 7 forks source link

RuntimeError: mat1 and mat2 shapes cannot be multiplied #12

Closed hanweikung closed 4 months ago

hanweikung commented 4 months ago

Is there a specific size requirement for the source and target images? I successfully swapped faces using the provided source (112x112) and target (256x256). However, when I resized the source image from 112x112 to 256x256, an error occurred.

I have no name!@cbf99791397b:/workspace/swapping$ python3 inference.py -w /workspace/checkpoints/blendswap.pth -s examples/source.png -t examples/target.png -o examples/output.png
Traceback (most recent call last):
  File "/workspace/swapping/inference.py", line 31, in <module>
    output = model(target_img, source_img)
  File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "/workspace/swapping/blendswap.py", line 60, in forward
    z_id = self.Z_e(source_img)
  File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/container.py", line 204, in forward
    input = module(input)
  File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "/workspace/swapping/model/iresnet.py", line 151, in forward
    x = self.fc(x.float() if self.fp16 else x)
  File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/torch/nn/modules/linear.py", line 114, in forward
    return F.linear(input, self.weight, self.bias)
RuntimeError: mat1 and mat2 shapes cannot be multiplied (1x131072 and 25088x512)
mapooon commented 4 months ago

Hi, As noted in README.md, you should follow the alignment setting for source and target images:

Note: source images should be aligned following InsightFace and target images should be aligned following FFHQ.

Also, after alignment, source image should be 112x112, and target image should be 256x256.

hanweikung commented 4 months ago

Hi, As noted in README.md, you should follow the alignment setting for source and target images:

Note: source images should be aligned following InsightFace and target images should be aligned following FFHQ.

Also, after alignment, source image should be 112x112, and target image should be 256x256.

Understood. Thank you for the clarification.