Skip to content

remove use_fast in AutoTokenizer #747

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion ppdiffusers/examples/text_to_image/README_sdxl.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,25 @@ export FLAGS_npu_storage_format=0
export FLAGS_use_stride_kernel=0
```

注意NPU训练暂不支持enable_xformers_memory_efficient_attention选项,启动命令如下:
```bash
python -u train_text_to_image_sdxl.py \
--pretrained_model_name_or_path=$MODEL_NAME \
--pretrained_vae_model_name_or_path=$VAE_NAME \
--dataset_name=$DATASET_NAME \
--resolution=512 --center_crop --random_flip \
--proportion_empty_prompts=0.2 \
--train_batch_size=1 \
--gradient_accumulation_steps=4 --gradient_checkpointing \
--max_train_steps=10000 \
--learning_rate=1e-06 --lr_scheduler="constant" --lr_warmup_steps=0 \
--mixed_precision="fp16" \
--report_to="wandb" \
--validation_prompt="a cute Sundar Pichai creature" --validation_epochs 5 \
--checkpointing_steps=5000 \
--output_dir="sdxl-pokemon-model"
```


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

Expand Down Expand Up @@ -200,7 +219,7 @@ python -u train_text_to_image_lora_sdxl.py \

### 推理

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

```python
from ppdiffusers import StableDiffusionXLPipeline
Expand All @@ -224,6 +243,8 @@ import os

dir_name = "your-checkpoints-path/sd-pokemon-model-lora-sdxl/"
for file_name in sorted(os.listdir(dir_name)):
if 'checkpoint' not in file_name:
continue
print(file_name)
model_path = os.path.join(dir_name, file_name)
pipe = StableDiffusionXLPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", paddle_dtype=paddle.float16)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,16 +566,10 @@ def main(args):

# Load the tokenizers
tokenizer_one = AutoTokenizer.from_pretrained(
args.pretrained_model_name_or_path,
subfolder="tokenizer",
revision=args.revision,
use_fast=False,
args.pretrained_model_name_or_path, subfolder="tokenizer", revision=args.revision
)
tokenizer_two = AutoTokenizer.from_pretrained(
args.pretrained_model_name_or_path,
subfolder="tokenizer_2",
revision=args.revision,
use_fast=False,
args.pretrained_model_name_or_path, subfolder="tokenizer_2", revision=args.revision
)

# import correct text encoder classes
Expand Down