Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError AnnealedValue = list[float] #8

Open
RuihanGao opened this issue Apr 24, 2023 · 4 comments
Open

TypeError AnnealedValue = list[float] #8

RuihanGao opened this issue Apr 24, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@RuihanGao
Copy link

RuihanGao commented Apr 24, 2023

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
@RuihanGao RuihanGao added the bug Something isn't working label Apr 24, 2023
@RuihanGao
Copy link
Author

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'

@ManuelSerna
Copy link

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.

@RuihanGao
Copy link
Author

That works for me, thanks a lot!

@anandvarrier
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants