Yujun-Shi / DragDiffusion

[CVPR2024, Highlight] Official code for DragDiffusion
https://yujun-shi.github.io/projects/dragdiffusion.html
Apache License 2.0
1.17k stars 88 forks source link

AttributeError: 'AttnProcessor2_0' object has no attribute 'to_q_lora' #37

Closed doogyhatts closed 1 year ago

doogyhatts commented 1 year ago

I am running the Colab version. When it reaches: DDIM Sampler: 24% 12/50 [00:00<00:00, 256.90it/s]

The following error appeared.

Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-packages/gradio/queueing.py", line 406, in call_prediction output = await route_utils.call_process_api( File "/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py", line 226, in call_process_api output = await app.get_blocks().process_api( File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1554, in process_api result = await self.call_function( File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1192, in call_function prediction = await anyio.to_thread.run_sync( File "/usr/local/lib/python3.10/dist-packages/anyio/to_thread.py", line 33, in run_sync return await get_asynclib().run_sync_in_worker_thread( File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread return await future File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 807, in run result = context.run(func, args) File "/usr/local/lib/python3.10/dist-packages/gradio/utils.py", line 659, in wrapper response = f(args, kwargs) File "/content/DragDiffusion/utils/ui_utils.py", line 270, in run_drag gen_image = model( File "/usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(*args, *kwargs) File "/content/DragDiffusion/drag_pipeline.py", line 399, in call noise_pred = self.unet(model_inputs, t, encoder_hidden_states=text_embeddings) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(args, kwargs) File "/content/DragDiffusion/drag_pipeline.py", line 130, in forward sample, res_samples = downsample_block( File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(*args, kwargs) File "/usr/local/lib/python3.10/dist-packages/diffusers/models/unet_2d_blocks.py", line 1086, in forward hidden_states = attn( File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(*args, *kwargs) File "/usr/local/lib/python3.10/dist-packages/diffusers/models/transformer_2d.py", line 315, in forward hidden_states = block( File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(args, kwargs) File "/usr/local/lib/python3.10/dist-packages/diffusers/models/attention.py", line 197, in forward attn_output = self.attn1( File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(*args, *kwargs) File "/content/DragDiffusion/utils/attn_utils.py", line 161, in forward query = attn.to_q(hidden_states) + lora_scale attn.processor.to_q_lora(hidden_states) AttributeError: 'AttnProcessor2_0' object has no attribute 'to_q_lora'

doogyhatts commented 1 year ago

Discovered a warning.

/usr/local/lib/python3.10/dist-packages/diffusers/models/attention_processor.py:1468: FutureWarning: LoRAAttnProcessor2_0 is deprecated and will be removed in version 0.26.0. Make sure use AttnProcessor2_0 instead by settingLoRA layers to self.{to_q,to_k,to_v,to_out[0]}.lora_layer respectively. This will be done automatically when using LoraLoaderMixin.load_lora_weights

Yujun-Shi commented 1 year ago

Hi thanks for your interests in our work and the information provided! Indeed, we recommend using the following command to ensure all configurations are aligned with ours:

image

We are using diffusers with version 0.17.1

uranusx86 commented 1 year ago

Here is the conda version without any problem in the Google Colab.

install condacolab package

!pip install -q condacolab
import condacolab
condacolab.install()
import sys
print(sys.executable)

clone the source code

!git clone https://github.com/Yujun-Shi/DragDiffusion.git

fix environment.yaml

%cd /content/DragDiffusion
# fix cudatoolkit not found error
!sed -i '4 a \ \ - nvidia' environment.yaml
!sed -i '4 a \ \ - conda-forge' environment.yaml

create runtime environment

!conda env create -f environment.yaml
!source /usr/local/etc/profile.d/conda.sh

install the missing package & run the demo

!source activate dragdiff && pip install ipykernel && python -m ipykernel install --user && python drag_ui.py
doogyhatts commented 1 year ago

Thank you! It works on Colab now!