PhotoMaker icon indicating copy to clipboard operation
PhotoMaker copied to clipboard

RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 2 but got size 1 for tensor number 1 in the list.

Open gebaltso opened this issue 1 year ago • 5 comments

Can anyone help with this error? I used the default setting, didn't change anything.

gebaltso avatar Sep 11 '24 09:09 gebaltso

The issue might be as mentioned here: https://github.com/TencentARC/PhotoMaker/issues/182#issuecomment-2357733365 You could add the following line in the load_photomaker_adapter() in photomaker/pipeline.py: self.num_tokens =2 if pm_version =='v2'else 1 ## this seems ignore the compatibility with v1

Sooplex avatar Sep 23 '24 07:09 Sooplex

The issue might be as mentioned here: #182 (comment) You could add the following line in the load_photomaker_adapter() in photomaker/pipeline.py: self.num_tokens =2 if pm_version =='v2'else 1 ## this seems ignore the compatibility with v1

Thanks but unfortunately I get the same error.

gebaltso avatar Sep 23 '24 08:09 gebaltso

The issue might be as mentioned here: #182 (comment) You could add the following line in the load_photomaker_adapter() in photomaker/pipeline.py: self.num_tokens =2 if pm_version =='v2'else 1 ## this seems ignore the compatibility with v1

Thanks but unfortunately I get the same error.

You have to set the args to use v1:

pipe.load_photomaker_adapter(
    os.path.dirname(photomaker_path),
    subfolder="",
    weight_name=os.path.basename(photomaker_path),
    trigger_word="img",  # define the trigger word
    pm_version='v1',
)    

Hzzone avatar Oct 23 '24 18:10 Hzzone

The issue might be as mentioned here: #182 (comment) You could add the following line in the load_photomaker_adapter() in photomaker/pipeline.py: self.num_tokens =2 if pm_version =='v2'else 1 ## this seems ignore the compatibility with v1

Thanks but unfortunately I get the same error.

You have to set the args to use v1:

pipe.load_photomaker_adapter(
    os.path.dirname(photomaker_path),
    subfolder="",
    weight_name=os.path.basename(photomaker_path),
    trigger_word="img",  # define the trigger word
    pm_version='v1',
)    

Thanks but keep getting the same error. I changed the args as you suggested.

gebaltso avatar Oct 29 '24 09:10 gebaltso

Solution:

  1. Open files: "photomaker/pipeline.py", "photomaker/pipeline_controlnet.py", "photomaker/pipeline_t2i_adapter.py"
  2. Find and replace: self.num_tokens = 2 to: self.num_tokens = 2 if pm_version == 'v2' else 1

This worked for me.

andchir avatar Dec 06 '24 09:12 andchir