Skip to content

Commit

Permalink
[train text to image] add note to loading from checkpoint (huggingfac…
Browse files Browse the repository at this point in the history
…e#3806)

add note to loading from checkpoint
  • Loading branch information
williamberman authored Jun 16, 2023
1 parent d49e2dd commit 3ddc2b7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions examples/text_to_image/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,21 @@ image = pipe(prompt="yoda").images[0]
image.save("yoda-pokemon.png")
```

Checkpoints only save the unet, so to run inference from a checkpoint, just load the unet
```python
from diffusers import StableDiffusionPipeline, UNet2DConditionModel

model_path = "path_to_saved_model"

unet = UNet2DConditionModel.from_pretrained(model_path + "/checkpoint-<N>/unet")

pipe = StableDiffusionPipeline.from_pretrained("<initial model>", unet=unet, torch_dtype=torch.float16)
pipe.to("cuda")

image = pipe(prompt="yoda").images[0]
image.save("yoda-pokemon.png")
```

#### Training with multiple GPUs

`accelerate` allows for seamless multi-GPU training. Follow the instructions [here](https://huggingface.co/docs/accelerate/basic_tutorials/launch)
Expand Down

0 comments on commit 3ddc2b7

Please sign in to comment.