From 1160bae68ab2c176a6a87acea156f0fb94eae60e Mon Sep 17 00:00:00 2001 From: Yudong Jin Date: Mon, 18 Dec 2023 15:50:00 +0800 Subject: [PATCH 1/2] Update examples/text_to_image/README.md --- examples/text_to_image/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/text_to_image/README.md b/examples/text_to_image/README.md index 94fd63f33067..c824d9efa660 100644 --- a/examples/text_to_image/README.md +++ b/examples/text_to_image/README.md @@ -101,8 +101,8 @@ accelerate launch --mixed_precision="fp16" train_text_to_image.py \ Once the training is finished the model will be saved in the `output_dir` specified in the command. In this example it's `sd-pokemon-model`. To load the fine-tuned model for inference just pass that path to `StableDiffusionPipeline` - ```python +import torch from diffusers import StableDiffusionPipeline model_path = "path_to_saved_model" @@ -114,12 +114,13 @@ image.save("yoda-pokemon.png") ``` Checkpoints only save the unet, so to run inference from a checkpoint, just load the unet + ```python +import torch from diffusers import StableDiffusionPipeline, UNet2DConditionModel model_path = "path_to_saved_model" - -unet = UNet2DConditionModel.from_pretrained(model_path + "/checkpoint-/unet") +unet = UNet2DConditionModel.from_pretrained(model_path + "/checkpoint-5000/unet", torch_dtype=torch.float16) pipe = StableDiffusionPipeline.from_pretrained("", unet=unet, torch_dtype=torch.float16) pipe.to("cuda") From 49e808bf793465ad5ed34c3b9e94e9aa6086d454 Mon Sep 17 00:00:00 2001 From: Yudong Jin Date: Mon, 18 Dec 2023 17:38:29 +0800 Subject: [PATCH 2/2] Update examples/text_to_image/README.md Co-authored-by: Sayak Paul --- examples/text_to_image/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/text_to_image/README.md b/examples/text_to_image/README.md index c824d9efa660..a56cccbcf5d7 100644 --- a/examples/text_to_image/README.md +++ b/examples/text_to_image/README.md @@ -120,7 +120,7 @@ import torch from diffusers import StableDiffusionPipeline, UNet2DConditionModel model_path = "path_to_saved_model" -unet = UNet2DConditionModel.from_pretrained(model_path + "/checkpoint-5000/unet", torch_dtype=torch.float16) +unet = UNet2DConditionModel.from_pretrained(model_path + "/checkpoint-/unet", torch_dtype=torch.float16) pipe = StableDiffusionPipeline.from_pretrained("", unet=unet, torch_dtype=torch.float16) pipe.to("cuda")