lez-s / StereoDiffusion

Implementation of StereoDiffusion
https://arxiv.org/abs/2403.04965
60 stars 6 forks source link

SyntaxError: invalid syntax #1

Closed TomTomTommi closed 5 months ago

TomTomTommi commented 5 months ago

Hi,

I follow the command line in README to run img2stereo.py but an error occured:

  File "img2stereo.py", line 48
    def __call__(self, attn, is_cross: bool, place_in_unet: str):
                                     ^
SyntaxError: invalid syntax
TomTomTommi commented 5 months ago

Just to confirm, following the install command pip install -r prompt-to-prompt/requirements.txt, torch 2.2.2 is installed.

lez-s commented 5 months ago

try def __call__(self, attn, is_cross, place_in_unet):, maybe your python doesn't support this syntax?

TomTomTommi commented 5 months ago

Another problem appears:

  File "img2stereo.py", line 33, in <module>
    ldm_stable = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", use_auth_token=MY_TOKEN, scheduler=scheduler).to(device)
  File "/home/jj323/.local/lib/python3.8/site-packages/diffusers/pipeline_utils.py", line 373, in from_pretrained
    load_method = getattr(class_obj, load_method_name)
TypeError: getattr(): attribute name must be string
lez-s commented 5 months ago

please check the value of class_obj and load_method_name, it is bug from diffusers, it seems you have different version of diffusers. Mine is 0.21.2

TomTomTommi commented 5 months ago

After re-installing the diffusers, this is solved. It seems the overall pipeline is ok, while the final step to save the image has an error:

File "img2stereo.py", line 405, in <module>
    torchvision.utils.save_image(image_pair, os.path.join('outputs',f'{args.img_path.split("/")[-1]}'), normalize=True)
TypeError: tensor or list of tensors expected, got <class 'numpy.ndarray'>
lez-s commented 5 months ago

yes, I just found it, change the final line to Image.fromarray(image_pair).save(os.path.join('outputs',f'{args.img_path.split("/")[-1]}'))