Skip to content

Commit fc3bfe3

Browse files
remove use_fast in AutoTokenizer (#747)
remote use_fast prarameter to adapt to paddlenlp 3.0.0.beta --------- Co-authored-by: nifeng <nemonameless@qq.com>
1 parent adfee07 commit fc3bfe3

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

ppdiffusers/examples/text_to_image/README_sdxl.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,25 @@ export FLAGS_npu_storage_format=0
119119
export FLAGS_use_stride_kernel=0
120120
```
121121

122+
注意NPU训练暂不支持enable_xformers_memory_efficient_attention选项,启动命令如下:
123+
```bash
124+
python -u train_text_to_image_sdxl.py \
125+
--pretrained_model_name_or_path=$MODEL_NAME \
126+
--pretrained_vae_model_name_or_path=$VAE_NAME \
127+
--dataset_name=$DATASET_NAME \
128+
--resolution=512 --center_crop --random_flip \
129+
--proportion_empty_prompts=0.2 \
130+
--train_batch_size=1 \
131+
--gradient_accumulation_steps=4 --gradient_checkpointing \
132+
--max_train_steps=10000 \
133+
--learning_rate=1e-06 --lr_scheduler="constant" --lr_warmup_steps=0 \
134+
--mixed_precision="fp16" \
135+
--report_to="wandb" \
136+
--validation_prompt="a cute Sundar Pichai creature" --validation_epochs 5 \
137+
--checkpointing_steps=5000 \
138+
--output_dir="sdxl-pokemon-model"
139+
```
140+
122141

123142
## Stable Diffusion XL (SDXL) LoRA 训练示例
124143

@@ -200,7 +219,7 @@ python -u train_text_to_image_lora_sdxl.py \
200219

201220
### 推理
202221

203-
一旦你使用上面的命令训练了一个模型,推理可以简单地使用 `StableDiffusionXLPipeline` 在加载训练好的 LoRA 权重后进行。你需要传递 `output_dir` 来加载 LoRA 权重,在这个案例中,是 `sd-pokemon-model-lora-sdxl`
222+
一旦你使用上面的命令训练了一个模型,推理可以简单地使用 `StableDiffusionXLPipeline` 在加载训练好的 LoRA 权重后进行。通过修改推理脚本中的model_path变量,可以传递需要加载的 LoRA 训练权重,在这个案例中,是 `sd-pokemon-model-lora-sdxl`
204223

205224
```python
206225
from ppdiffusers import StableDiffusionXLPipeline
@@ -224,6 +243,8 @@ import os
224243

225244
dir_name = "your-checkpoints-path/sd-pokemon-model-lora-sdxl/"
226245
for file_name in sorted(os.listdir(dir_name)):
246+
if 'checkpoint' not in file_name:
247+
continue
227248
print(file_name)
228249
model_path = os.path.join(dir_name, file_name)
229250
pipe = StableDiffusionXLPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", paddle_dtype=paddle.float16)

ppdiffusers/examples/text_to_image/train_text_to_image_lora_sdxl.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -566,16 +566,10 @@ def main(args):
566566

567567
# Load the tokenizers
568568
tokenizer_one = AutoTokenizer.from_pretrained(
569-
args.pretrained_model_name_or_path,
570-
subfolder="tokenizer",
571-
revision=args.revision,
572-
use_fast=False,
569+
args.pretrained_model_name_or_path, subfolder="tokenizer", revision=args.revision
573570
)
574571
tokenizer_two = AutoTokenizer.from_pretrained(
575-
args.pretrained_model_name_or_path,
576-
subfolder="tokenizer_2",
577-
revision=args.revision,
578-
use_fast=False,
572+
args.pretrained_model_name_or_path, subfolder="tokenizer_2", revision=args.revision
579573
)
580574

581575
# import correct text encoder classes

0 commit comments

Comments
 (0)