chengzhag / PanFusion

🍳 [CVPR'24 Highlight] Pytorch implementation of "Taming Stable Diffusion for Text to 360° Panorama Image Generation"
https://chengzhag.github.io/publication/panfusion/
MIT License
137 stars 14 forks source link

KeyError: 'model_id' #6

Open saadjumani opened 2 weeks ago

saadjumani commented 2 weeks ago

Hi, I am trying to run the model on my local machine (windows 10 PC with AMD Ryzen 5 CPU, Nvidia 2060S GPU). I dont need to train the model, just to try and run with last checkpoint.

I try to run this the following way: python main.py predict --data=Matterport3D --model=PanFusion --ckpt_path=last

I get the following error traceback

WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. xFormers was built for:
    PyTorch 2.0.1+cu118 with CUDA 1108 (you have 2.0.1+cpu)
    Python  3.9.13 (you have 3.9.19)
  Please reinstall xformers (see https://github.com/facebookresearch/xformers#installing-xformers)
  Memory-efficient attention, SwiGLU, sparse and more won't be available.
  Set XFORMERS_MORE_DETAILS=1 for more details
Seed set to 0
Traceback (most recent call last):
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\lightning\fabric\utilities\data.py", line 487, in __getattr__
    return self[key]
KeyError: 'model_id'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\jsonargparse\_typehints.py", line 952, in adapt_typehints
    val = adapt_class_type(val, serialize, instantiate_classes, sub_add_kwargs, prev_val=prev_val)
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\jsonargparse\_typehints.py", line 1184, in adapt_class_type
    return instantiator_fn(val_class, **{**init_args, **dict_kwargs})
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\jsonargparse\_common.py", line 158, in __call__
    return instantiator(class_type, *args, **kwargs)
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\lightning\pytorch\cli.py", line 798, in __call__
    return class_type(*args, **kwargs)
  File "D:\Softwares\VRImagegenerators\PanFusion\PanFusion\models\pano\PanFusion.py", line 20, in __init__
    super().__init__(**kwargs)
  File "D:\Softwares\VRImagegenerators\PanFusion\PanFusion\models\pano\PanoGenerator.py", line 84, in __init__
    self.load_shared()
  File "D:\Softwares\VRImagegenerators\PanFusion\PanFusion\models\pano\PanoGenerator.py", line 118, in load_shared
    self.hparams.model_id, subfolder="tokenizer", torch_dtype=torch.float16, use_safetensors=True)
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\lightning\fabric\utilities\data.py", line 489, in __getattr__
    raise AttributeError(f"'{type(self).__name__}' object has no attribute '{key}'") from e
AttributeError: 'AttributeDict' object has no attribute 'model_id'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\Softwares\VRImagegenerators\PanFusion\PanFusion\main.py", line 76, in <module>
    cli_main()
  File "D:\Softwares\VRImagegenerators\PanFusion\PanFusion\main.py", line 57, in cli_main
    cli = MyLightningCLI(
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\lightning\pytorch\cli.py", line 391, in __init__
    self.instantiate_classes()
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\lightning\pytorch\cli.py", line 557, in instantiate_classes
    self.config_init = self.parser.instantiate_classes(self.config)
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\jsonargparse\_deprecated.py", line 141, in patched_instantiate_classes
    cfg = self._unpatched_instantiate_classes(cfg, **kwargs)
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\jsonargparse\_core.py", line 1191, in instantiate_classes
    cfg[subcommand] = subparser.instantiate_classes(cfg[subcommand], instantiate_groups=instantiate_groups)
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\jsonargparse\_deprecated.py", line 141, in patched_instantiate_classes
    cfg = self._unpatched_instantiate_classes(cfg, **kwargs)
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\jsonargparse\_core.py", line 1182, in instantiate_classes
    parent[key] = component.instantiate_classes(value)
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\jsonargparse\_typehints.py", line 565, in instantiate_classes
    value[num] = adapt_typehints(
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\jsonargparse\_typehints.py", line 956, in adapt_typehints
    raise_unexpected_value(f"Problem with given class_path {class_path!r}:\n{error}", exception=ex)
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\jsonargparse\_typehints.py", line 634, in raise_unexpected_value
    raise ValueError(message) from exception
ValueError: Problem with given class_path 'models.PanFusion':
  'AttributeDict' object has no attribute 'model_id'
YacratesWyh commented 2 weeks ago

same

YacratesWyh commented 2 weeks ago

I've solved this. Two problems potential:

  1. You may not using python 3.9. 3.12 would make xformers not compatible, it's fatal when I tried to install it only with torch 2.3.0, not worked as it claimed.
  2. u need to install huggingface_hub or else to lanch this transformers install. Just try any diffusers start tutorial would solve this, before running it. It may work for someone because they've already downloaded this in .cache so it wouldn't be a problem. But I've done it in another directory. I think it's solved. Key is not to install the loose requirement.txt.

In your log, it's clear that you install not the correct way.

WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. xFormers was built for:
    PyTorch 2.0.1+cu118 with CUDA 1108 (you have 2.0.1+cpu)
    Python  3.9.13 (you have 3.9.19)

This shows that you are using cpu And xformers and huggingface may not working. In my case this hints 2.3.0+cu121 and python 3.12