lucidrains / deep-daze

Simple command line tool for text to image generation using OpenAI's CLIP and Siren (Implicit neural representation network). Technique was originally created by https://twitter.com/advadnoun
MIT License
4.37k stars 327 forks source link

Method 'forward' is not defined #67

Closed Binbose closed 3 years ago

Binbose commented 3 years ago

I installed the module via

$ pip install deep-daze

and just tried the provided example with

$ imagine "a house in the forest"

but after it loaded something for a few minutes (the first time I run the command) it throws this error

Traceback (most recent call last):
  File "/home/luca/anaconda3/bin/imagine", line 5, in <module>
    from deep_daze.cli import main
  File "/home/luca/anaconda3/lib/python3.7/site-packages/deep_daze/__init__.py", line 1, in <module>
    from deep_daze.deep_daze import DeepDaze, Imagine
  File "/home/luca/anaconda3/lib/python3.7/site-packages/deep_daze/deep_daze.py", line 39, in <module>
    perceptor, normalize_image = load()
  File "/home/luca/anaconda3/lib/python3.7/site-packages/deep_daze/clip.py", line 192, in load
    model.apply(patch_device)
  File "/home/luca/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 473, in apply
    module.apply(fn)
  File "/home/luca/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 473, in apply
    module.apply(fn)
  File "/home/luca/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 473, in apply
    module.apply(fn)
  [Previous line repeated 3 more times]
  File "/home/luca/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 474, in apply
    fn(self)
  File "/home/luca/anaconda3/lib/python3.7/site-packages/deep_daze/clip.py", line 183, in patch_device
    graphs = [module.graph] if hasattr(module, "graph") else []
  File "/home/luca/anaconda3/lib/python3.7/site-packages/torch/jit/_script.py", line 449, in graph
    return self._c._get_method("forward").graph
RuntimeError: Method 'forward' is not defined.

My system is:

Ubuntu 18.04.4 LTS GeForce RTX 2070 pytorch 1.7.1 python version 3.7.1

Ryboii commented 3 years ago

Did you try the command from the Anaconda Prompt?

Binbose commented 3 years ago

I tried it from the Ubuntu terminal

Jeffrey0Liao commented 3 years ago

Same problem.

Environment: Windows 10 GeForce GTX1060 6G pytorch 1.8.0+cu111 python 3.7.0

EPA1257 commented 3 years ago

I'm also having this issue. Windows 10, RTX 2060, using Torch 1.8.0 with CUDA 11.1 support, and Python 3.9.2.

lucidrains commented 3 years ago

it turns out the released OpenAI code has some issues with the JIT version https://github.com/openai/CLIP/issues/49 I've submitted a new issue asking for them to make CLIP pip-installable, and I'll fix it so it uses the non-JIT version instead once they do https://github.com/openai/CLIP/issues/60

aicrumb commented 3 years ago

I found the same problem in google colab, but it's fixed by just restarting and running all, I don't know if that helps at all

constantupgrade commented 3 years ago

So does this mean it won't work until the package is pip installable? is there any way around it until that happens?

lucidrains commented 3 years ago

@constantupgrade I decided to just copy over all of their code to fix this issue https://github.com/lucidrains/deep-daze/commit/9435bcb903044a90320d9676b70e4909d82c827d I'll clean things up once they pick up the ball on their end

lucidrains commented 3 years ago

@constantupgrade let me know if 0.7.1 works for you!

constantupgrade commented 3 years ago

Yep, using the updated files worked for me. Thanks for being so responsive and quick to solving these issues!