peterwilli / sd-leap-booster

Fast finetuning using a booster model that puts the initial state to a local minimum
MIT License
113 stars 12 forks source link

UnboundLocalError: local variable 'grid' referenced before assignment #5

Closed poyo23 closed 1 year ago

poyo23 commented 1 year ago

Hello.

I am not familiar with this field, but this is very interesting.

I tried to use it without installing it

However, when I tried this, it did not work with the latest code. (f1a06465e4c5c35fc46b17c8a1e65668a6bd3027)

At least as of d29b8d3e09dd55d820c4d97c9a1fe6c0654a0e36 it was working. This did not work. It must have been an older code.

I can use the previous code but not sure if this is the right thing to do.

Thanks.

Traceback (most recent call last):
  File "~/sd-leap-booster/leap_textual_inversion.py", line 782, in <module>
    main()
  File "~/sd-leap-booster/leap_textual_inversion.py", line 541, in main
    boosted_embed = boost_embed(leap, args.train_data_dir)
  File "/conda/to/path/miniconda3/envs/leapenv4/lib/python3.10/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "~/sd-leap-booster/leap_textual_inversion.py", line 452, in boost_embed
    grid = grid.unsqueeze(0)
UnboundLocalError: local variable 'grid' referenced before assignment

The following is a postscript.

I managed to get this script to work. However, I ran into a different error again. RuntimeError: Given groups=1, weight of size [32, 3, 3, 3], expected input[1, 1, 128, 128] to have 3 channels, but got 1 channels instead

peterwilli commented 1 year ago

I forgot to update the code halfway @poyo23 ! I'm sorry for the late reply. I fixed it and also added a colab for easy testing: https://colab.research.google.com/drive/1-uBBQpPlt4k5YDNZiN4H4ICWlkVcitfP?usp=sharing