lukemelas / realfusion

Official code for "RealFusion: 360° Reconstruction of Any Object from a Single Image" (CVPR 2023)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError AnnealedValue = list[float]

RuihanGao opened this issue · comments

Description

Running python main.py --0 gives an error with TypeError.

  File "main.py", line 9, in <module>
    from nerf.provider_image import NeRFDataset as ImageOnlyNeRFDataset
  File "/data/ruihan/projects/realfusion/nerf/provider_image.py", line 13, in <module>
    from .options import Options
  File "/data/ruihan/projects/realfusion/nerf/options.py", line 13, in <module>
    AnnealedValue = list[float]
TypeError: 'type' object is not subscriptable```

### Steps to Reproduce

python main.py --0

### Expected Behavior

Run the code. 

### Environment

Ubuntu 20.04, cudatoolkit 11.3.1, pytorch 1.11.0, transformers 4.28.1, diffusers 0.15.1

I tried from typing import List, Tuple and changed

AnnealedValue = list[float]
radius_range: tuple[float, float] = [1.0, 1.5]
fovy_range: tuple[float, float] = [40, 70]

to

AnnealedValue = List[float]
radius_range: Tuple[float, float] = [1.0, 1.5]
fovy_range: Tuple[float, float] = [40, 70]

It passed the syntax check but got error

 /data/ruihan/projects/realfusion/sd/utils.py:15 in add_tokens_to_model                           │
│                                                                                                  │
│   12 │   # Loop over learned embeddings                                                          │
│   13 │   new_tokens = []                                                                         │
│   14 │   for token, embedding in learned_embeds.items():                                         │
│ ❱ 15 │   │   embedding = embedding.to(text_encoder.get_input_embeddings().weight.dtype)          │
│   16 │   │   if override_token is not None:                                                      │
│   17 │   │   │   token = override_token if isinstance(override_token, str) else override_toke    │
│   18                                                                                             │

AttributeError: 'tuple' object has no attribute 'get_input_embeddings'

I also ran into this same issue (the tuple object having no attribute error).

What solved it for me was to downgrade the diffusers library from the latest version (0.15.1 as of the time I'm writing this) down to version 0.12.0. I ran the below command (and it should not affect other project dependencies):

pip install diffusers==0.12.0

I suppose the reason this happened is some functionality of the library became deprecated or was changed, returning incorrect objects. I narrowed it down to the class StableDiffusionModel in the sd custom module, where something goes wrong with newer versions.

That works for me, thanks a lot!

Hey @ManuelSerna and @RuihanGao,
I am facing few issues #16. If you have successfully implemented the code, could you kindly take a look at issue #16 and assist me.

Thank you.

Regards,
Anand Varrier