Skip to content

Commit 8e35ef0

Browse files
author
Mishig
authored
[doc wip] literalinclude (#2718)
1 parent a8315ce commit 8e35ef0

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

docs/source/en/training/text2image.mdx

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -74,25 +74,13 @@ To load a checkpoint to resume training, pass the argument `--resume_from_checkp
7474
<pt>
7575
Launch the [PyTorch training script](https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image.py) for a fine-tuning run on the [Pokémon BLIP captions](https://huggingface.co/datasets/lambdalabs/pokemon-blip-captions) dataset like this:
7676

77-
```bash
78-
export MODEL_NAME="CompVis/stable-diffusion-v1-4"
79-
export dataset_name="lambdalabs/pokemon-blip-captions"
80-
81-
accelerate launch train_text_to_image.py \
82-
--pretrained_model_name_or_path=$MODEL_NAME \
83-
--dataset_name=$dataset_name \
84-
--use_ema \
85-
--resolution=512 --center_crop --random_flip \
86-
--train_batch_size=1 \
87-
--gradient_accumulation_steps=4 \
88-
--gradient_checkpointing \
89-
--mixed_precision="fp16" \
90-
--max_train_steps=15000 \
91-
--learning_rate=1e-05 \
92-
--max_grad_norm=1 \
93-
--lr_scheduler="constant" --lr_warmup_steps=0 \
94-
--output_dir="sd-pokemon-model"
95-
```
77+
<literalinclude>
78+
{"path": "../../../../examples/text_to_image/README.md",
79+
"language": "bash",
80+
"start-after": "accelerate_snippet_start",
81+
"end-before": "accelerate_snippet_end",
82+
"dedent": 0}
83+
</literalinclude>
9684

9785
To finetune on your own dataset, prepare the dataset according to the format required by 🤗 [Datasets](https://huggingface.co/docs/datasets/index). You can [upload your dataset to the Hub](https://huggingface.co/docs/datasets/image_dataset#upload-dataset-to-the-hub), or you can [prepare a local folder with your files](https://huggingface.co/docs/datasets/image_dataset#imagefolder).
9886

examples/text_to_image/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ If you have already cloned the repo, then you won't need to go through these ste
5252
With `gradient_checkpointing` and `mixed_precision` it should be possible to fine tune the model on a single 24GB GPU. For higher `batch_size` and faster training it's better to use GPUs with >30GB memory.
5353

5454
**___Note: Change the `resolution` to 768 if you are using the [stable-diffusion-2](https://huggingface.co/stabilityai/stable-diffusion-2) 768x768 model.___**
55-
55+
<!-- accelerate_snippet_start -->
5656
```bash
5757
export MODEL_NAME="CompVis/stable-diffusion-v1-4"
5858
export dataset_name="lambdalabs/pokemon-blip-captions"
@@ -71,6 +71,7 @@ accelerate launch --mixed_precision="fp16" train_text_to_image.py \
7171
--lr_scheduler="constant" --lr_warmup_steps=0 \
7272
--output_dir="sd-pokemon-model"
7373
```
74+
<!-- accelerate_snippet_end -->
7475

7576

7677
To run on your own training files prepare the dataset according to the format required by `datasets`, you can find the instructions for how to do that in this [document](https://huggingface.co/docs/datasets/v2.4.0/en/image_load#imagefolder-with-metadata).

0 commit comments

Comments
 (0)