AttributeError: 'DDPMScheduler' object has no attribute 'get_velocity' (using stable-diffusion-2)
See original GitHub issueDescribe the bug
Running examples/dreambooth/train_dreambooth.py
fails:
[noob@server dreambooth]$ ./train.sh
You are using a model of type clip_text_model to instantiate a model of type . This is not supported for all configurations of models and can yield errors.
Steps: 0%| | 0/800 [00:00<?, ?it/s]
Traceback (most recent call last):
File "train_dreambooth.py", line 716, in <module>
main(args)
File "train_dreambooth.py", line 641, in main
target = noise_scheduler.get_velocity(latents, noise, timesteps)
AttributeError: 'DDPMScheduler' object has no attribute 'get_velocity'
Reproduction
I just followed the README.md, more precisely, I tried Training on a 16 GB GPU. First I downloaded the stable-diffusion-2 repo with:
[noob@server diffusers]$ git clone https://huggingface.co/stabilityai/stable-diffusion-2
Then, I did:
[noob@server diffusers]$ cd examples/dreambooth/
[noob@server dreambooth]$
python3.7 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
pip install bitsandbytes
accelerate config
accelerate launch train_dreambooth.py \
--pretrained_model_name_or_path=$MODEL_NAME \
--instance_data_dir=$INSTANCE_DIR \
--output_dir=$OUTPUT_DIR \
--instance_prompt="a photo of sks dog" \
--resolution=768 \
--train_batch_size=1 \
--gradient_accumulation_steps=2 --gradient_checkpointing \
--use_8bit_adam \
--learning_rate=5e-6 \
--lr_scheduler="constant" \
--lr_warmup_steps=0 \
--max_train_steps=800
with:
[noob@server dreambooth]$ cat requirements.txt
diffusers>==0.5.0
accelerate
torchvision
transformers>=4.22.1
ftfy
tensorboard
modelcards
Seems like the error is caused by prediction_type
in scheduler_config.json
:
[noob@server dreambooth]$ cat ../../stable-diffusion-2/scheduler/scheduler_config.json
{
"_class_name": "DDIMScheduler",
"_diffusers_version": "0.8.0",
"beta_end": 0.012,
"beta_schedule": "scaled_linear",
"beta_start": 0.00085,
"clip_sample": false,
"num_train_timesteps": 1000,
"prediction_type": "v_prediction",
"set_alpha_to_one": false,
"skip_prk_steps": true,
"steps_offset": 1,
"trained_betas": null
}
I saw "_diffusers_version": "0.8.0"
here so tried changing requirements and use >=0.8.0 rather than >=0.5.0, but still no luck.
Logs
No response
System Info
diffusers
version: 0.9.0- Platform: Linux-4.18.0-348.7.1.el8_5.x86_64-x86_64-with-centos-8.5.2111
- Python version: 3.7.9
- PyTorch version (GPU?): 1.13.0+cu117 (True)
- Huggingface_hub version: 0.11.1
- Transformers version: 4.25.1
- Using GPU in script?: Yes, RTX 3090
- Using distributed or parallel set-up in script?: No
Issue Analytics
- State:
- Created 10 months ago
- Reactions:4
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Friction log from new user · Issue #24 · huggingface/diffusers
I'm writing a friction log as a new user and someone with 0 ... AttributeError: module 'diffusers' has no attribute 'GaussianDDPMScheduler'.
Read more >AttributeError: 'GPT2LMHeadModel' object has no attribute ...
Hello guys, I fine-tuned a GPT2 model on some stable diffusion text and I'm trying to create a Gradio space for it but...
Read more >python - AttributeError: 'NoneType' object has no attribute 'shape'
I think I may have found the issue: My prompts looked like this, divided by so many (""). So I strung the prompt...
Read more >Why am I getting AttributeError: Object has no attribute?
PYTHON : Why am I getting AttributeError : Object has no attribute ? [ Gift : Animated Search Engine ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Try
pip install git+https://github.com/huggingface/diffusers
?I think this is because the pypi version is not up to date. Once I installed the library from git directly, the issue disappeared
+1 for the issue and the solve by pip installing via this repo.
Let’s get pypi up-to-date.