Unverified Commit 98730c5d authored by Tolga Cangöz's avatar Tolga Cangöz Committed by GitHub
Browse files

Errata (#8322)

* Fix typos

* Trim trailing whitespaces

* Remove a trailing whitespace

* chore: Update MarigoldDepthPipeline checkpoint to prs-eth/marigold-lcm-v1-0

* Revert "chore: Update MarigoldDepthPipeline checkpoint to prs-eth/marigold-lcm-v1-0"

This reverts commit fd742b30b4258106008a6af4d0dd4664904f8595.

* pokemon -> naruto

* `DPMSolverMultistep` -> `DPMSolverMultistepScheduler`

* Improve Markdown stylization

* Improve style

* Improve style

* Refactor pipeline variable names for consistency

* up style
parent 7ebd3594
...@@ -115,7 +115,7 @@ accelerate launch train_lcm_distill_lora_sdxl_wds.py \ ...@@ -115,7 +115,7 @@ accelerate launch train_lcm_distill_lora_sdxl_wds.py \
We provide another version for LCM LoRA SDXL that follows best practices of `peft` and leverages the `datasets` library for quick experimentation. The script doesn't load two UNets unlike `train_lcm_distill_lora_sdxl_wds.py` which reduces the memory requirements quite a bit. We provide another version for LCM LoRA SDXL that follows best practices of `peft` and leverages the `datasets` library for quick experimentation. The script doesn't load two UNets unlike `train_lcm_distill_lora_sdxl_wds.py` which reduces the memory requirements quite a bit.
Below is an example training command that trains an LCM LoRA on the [Pokemons dataset](https://huggingface.co/datasets/lambdalabs/naruto-blip-captions): Below is an example training command that trains an LCM LoRA on the [Narutos dataset](https://huggingface.co/datasets/lambdalabs/naruto-blip-captions):
```bash ```bash
export MODEL_NAME="stabilityai/stable-diffusion-xl-base-1.0" export MODEL_NAME="stabilityai/stable-diffusion-xl-base-1.0"
...@@ -125,7 +125,7 @@ export VAE_PATH="madebyollin/sdxl-vae-fp16-fix" ...@@ -125,7 +125,7 @@ export VAE_PATH="madebyollin/sdxl-vae-fp16-fix"
accelerate launch train_lcm_distill_lora_sdxl.py \ accelerate launch train_lcm_distill_lora_sdxl.py \
--pretrained_teacher_model=${MODEL_NAME} \ --pretrained_teacher_model=${MODEL_NAME} \
--pretrained_vae_model_name_or_path=${VAE_PATH} \ --pretrained_vae_model_name_or_path=${VAE_PATH} \
--output_dir="pokemons-lora-lcm-sdxl" \ --output_dir="narutos-lora-lcm-sdxl" \
--mixed_precision="fp16" \ --mixed_precision="fp16" \
--dataset_name=$DATASET_NAME \ --dataset_name=$DATASET_NAME \
--resolution=1024 \ --resolution=1024 \
......
...@@ -315,13 +315,13 @@ gcloud alpha compute tpus tpu-vm ssh $VM_NAME --zone $ZONE -- \ ...@@ -315,13 +315,13 @@ gcloud alpha compute tpus tpu-vm ssh $VM_NAME --zone $ZONE -- \
When connected install JAX `0.4.5`: When connected install JAX `0.4.5`:
``` ```sh
pip install "jax[tpu]==0.4.5" -f https://storage.googleapis.com/jax-releases/libtpu_releases.html pip install "jax[tpu]==0.4.5" -f https://storage.googleapis.com/jax-releases/libtpu_releases.html
``` ```
To verify that JAX was correctly installed, you can run the following command: To verify that JAX was correctly installed, you can run the following command:
``` ```py
import jax import jax
jax.device_count() jax.device_count()
``` ```
...@@ -351,14 +351,14 @@ pip install wandb ...@@ -351,14 +351,14 @@ pip install wandb
Now let's downloading two conditioning images that we will use to run validation during the training in order to track our progress Now let's downloading two conditioning images that we will use to run validation during the training in order to track our progress
``` ```sh
wget https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet_training/conditioning_image_1.png wget https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet_training/conditioning_image_1.png
wget https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet_training/conditioning_image_2.png wget https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet_training/conditioning_image_2.png
``` ```
We encourage you to store or share your model with the community. To use huggingface hub, please login to your Hugging Face account, or ([create one](https://huggingface.co/docs/diffusers/main/en/training/hf.co/join) if you don’t have one already): We encourage you to store or share your model with the community. To use huggingface hub, please login to your Hugging Face account, or ([create one](https://huggingface.co/docs/diffusers/main/en/training/hf.co/join) if you don’t have one already):
``` ```sh
huggingface-cli login huggingface-cli login
``` ```
......
...@@ -34,7 +34,7 @@ For this example we want to directly store the trained LoRA embeddings on the Hu ...@@ -34,7 +34,7 @@ For this example we want to directly store the trained LoRA embeddings on the Hu
___ ___
### Pokemon example ### Naruto example
For all our examples, we will directly store the trained weights on the Hub, so we need to be logged in and add the `--push_to_hub` flag. In order to do that, you have to be a registered user on the 🤗 Hugging Face Hub, and you'll also need to use an access token for the code to work. For more information on access tokens, please refer to the [User Access Tokens](https://huggingface.co/docs/hub/security-tokens) guide. For all our examples, we will directly store the trained weights on the Hub, so we need to be logged in and add the `--push_to_hub` flag. In order to do that, you have to be a registered user on the 🤗 Hugging Face Hub, and you'll also need to use an access token for the code to work. For more information on access tokens, please refer to the [User Access Tokens](https://huggingface.co/docs/hub/security-tokens) guide.
...@@ -50,7 +50,7 @@ We also use [Weights and Biases](https://docs.wandb.ai/quickstart) logging by de ...@@ -50,7 +50,7 @@ We also use [Weights and Biases](https://docs.wandb.ai/quickstart) logging by de
pip install wandb pip install wandb
``` ```
To disable wandb logging, remove the `--report_to=="wandb"` and `--validation_prompts="A robot pokemon, 4k photo"` flags from below examples To disable wandb logging, remove the `--report_to=="wandb"` and `--validation_prompts="A robot naruto, 4k photo"` flags from below examples
#### Fine-tune decoder #### Fine-tune decoder
<br> <br>
...@@ -70,10 +70,10 @@ accelerate launch --mixed_precision="fp16" train_text_to_image_decoder.py \ ...@@ -70,10 +70,10 @@ accelerate launch --mixed_precision="fp16" train_text_to_image_decoder.py \
--max_grad_norm=1 \ --max_grad_norm=1 \
--checkpoints_total_limit=3 \ --checkpoints_total_limit=3 \
--lr_scheduler="constant" --lr_warmup_steps=0 \ --lr_scheduler="constant" --lr_warmup_steps=0 \
--validation_prompts="A robot pokemon, 4k photo" \ --validation_prompts="A robot naruto, 4k photo" \
--report_to="wandb" \ --report_to="wandb" \
--push_to_hub \ --push_to_hub \
--output_dir="kandi2-decoder-pokemon-model" --output_dir="kandi2-decoder-naruto-model"
``` ```
<!-- accelerate_snippet_end --> <!-- accelerate_snippet_end -->
...@@ -95,14 +95,14 @@ accelerate launch --mixed_precision="fp16" train_text_to_image_decoder.py \ ...@@ -95,14 +95,14 @@ accelerate launch --mixed_precision="fp16" train_text_to_image_decoder.py \
--max_grad_norm=1 \ --max_grad_norm=1 \
--checkpoints_total_limit=3 \ --checkpoints_total_limit=3 \
--lr_scheduler="constant" --lr_warmup_steps=0 \ --lr_scheduler="constant" --lr_warmup_steps=0 \
--validation_prompts="A robot pokemon, 4k photo" \ --validation_prompts="A robot naruto, 4k photo" \
--report_to="wandb" \ --report_to="wandb" \
--push_to_hub \ --push_to_hub \
--output_dir="kandi22-decoder-pokemon-model" --output_dir="kandi22-decoder-naruto-model"
``` ```
Once the training is finished the model will be saved in the `output_dir` specified in the command. In this example it's `kandi22-decoder-pokemon-model`. To load the fine-tuned model for inference just pass that path to `AutoPipelineForText2Image` Once the training is finished the model will be saved in the `output_dir` specified in the command. In this example it's `kandi22-decoder-naruto-model`. To load the fine-tuned model for inference just pass that path to `AutoPipelineForText2Image`
```python ```python
from diffusers import AutoPipelineForText2Image from diffusers import AutoPipelineForText2Image
...@@ -111,9 +111,9 @@ import torch ...@@ -111,9 +111,9 @@ import torch
pipe = AutoPipelineForText2Image.from_pretrained(output_dir, torch_dtype=torch.float16) pipe = AutoPipelineForText2Image.from_pretrained(output_dir, torch_dtype=torch.float16)
pipe.enable_model_cpu_offload() pipe.enable_model_cpu_offload()
prompt='A robot pokemon, 4k photo' prompt='A robot naruto, 4k photo'
images = pipe(prompt=prompt).images images = pipe(prompt=prompt).images
images[0].save("robot-pokemon.png") images[0].save("robot-naruto.png")
``` ```
Checkpoints only save the unet, so to run inference from a checkpoint, just load the unet Checkpoints only save the unet, so to run inference from a checkpoint, just load the unet
...@@ -127,8 +127,8 @@ unet = UNet2DConditionModel.from_pretrained(model_path + "/checkpoint-<N>/unet") ...@@ -127,8 +127,8 @@ unet = UNet2DConditionModel.from_pretrained(model_path + "/checkpoint-<N>/unet")
pipe = AutoPipelineForText2Image.from_pretrained("kandinsky-community/kandinsky-2-2-decoder", unet=unet, torch_dtype=torch.float16) pipe = AutoPipelineForText2Image.from_pretrained("kandinsky-community/kandinsky-2-2-decoder", unet=unet, torch_dtype=torch.float16)
pipe.enable_model_cpu_offload() pipe.enable_model_cpu_offload()
image = pipe(prompt="A robot pokemon, 4k photo").images[0] image = pipe(prompt="A robot naruto, 4k photo").images[0]
image.save("robot-pokemon.png") image.save("robot-naruto.png")
``` ```
#### Fine-tune prior #### Fine-tune prior
...@@ -151,10 +151,10 @@ accelerate launch --mixed_precision="fp16" train_text_to_image_prior.py \ ...@@ -151,10 +151,10 @@ accelerate launch --mixed_precision="fp16" train_text_to_image_prior.py \
--max_grad_norm=1 \ --max_grad_norm=1 \
--checkpoints_total_limit=3 \ --checkpoints_total_limit=3 \
--lr_scheduler="constant" --lr_warmup_steps=0 \ --lr_scheduler="constant" --lr_warmup_steps=0 \
--validation_prompts="A robot pokemon, 4k photo" \ --validation_prompts="A robot naruto, 4k photo" \
--report_to="wandb" \ --report_to="wandb" \
--push_to_hub \ --push_to_hub \
--output_dir="kandi2-prior-pokemon-model" --output_dir="kandi2-prior-naruto-model"
``` ```
<!-- accelerate_snippet_end --> <!-- accelerate_snippet_end -->
...@@ -170,7 +170,7 @@ prior_components = {"prior_" + k: v for k,v in pipe_prior.components.items()} ...@@ -170,7 +170,7 @@ prior_components = {"prior_" + k: v for k,v in pipe_prior.components.items()}
pipe = AutoPipelineForText2Image.from_pretrained("kandinsky-community/kandinsky-2-2-decoder", **prior_components, torch_dtype=torch.float16) pipe = AutoPipelineForText2Image.from_pretrained("kandinsky-community/kandinsky-2-2-decoder", **prior_components, torch_dtype=torch.float16)
pipe.enable_model_cpu_offload() pipe.enable_model_cpu_offload()
prompt='A robot pokemon, 4k photo' prompt='A robot naruto, 4k photo'
images = pipe(prompt=prompt, negative_prompt=negative_prompt).images images = pipe(prompt=prompt, negative_prompt=negative_prompt).images
images[0] images[0]
``` ```
...@@ -196,10 +196,10 @@ accelerate launch --mixed_precision="fp16" --multi_gpu train_text_to_image_deco ...@@ -196,10 +196,10 @@ accelerate launch --mixed_precision="fp16" --multi_gpu train_text_to_image_deco
--max_grad_norm=1 \ --max_grad_norm=1 \
--checkpoints_total_limit=3 \ --checkpoints_total_limit=3 \
--lr_scheduler="constant" --lr_warmup_steps=0 \ --lr_scheduler="constant" --lr_warmup_steps=0 \
--validation_prompts="A robot pokemon, 4k photo" \ --validation_prompts="A robot naruto, 4k photo" \
--report_to="wandb" \ --report_to="wandb" \
--push_to_hub \ --push_to_hub \
--output_dir="kandi2-decoder-pokemon-model" --output_dir="kandi2-decoder-naruto-model"
``` ```
...@@ -227,7 +227,7 @@ on consumer GPUs like Tesla T4, Tesla V100. ...@@ -227,7 +227,7 @@ on consumer GPUs like Tesla T4, Tesla V100.
### Training ### Training
First, you need to set up your development environment as explained in the [installation](#installing-the-dependencies). Make sure to set the `MODEL_NAME` and `DATASET_NAME` environment variables. Here, we will use [Kandinsky 2.2](https://huggingface.co/kandinsky-community/kandinsky-2-2-decoder) and the [Pokemons dataset](https://huggingface.co/datasets/lambdalabs/naruto-blip-captions). First, you need to set up your development environment as explained in the [installation](#installing-the-dependencies). Make sure to set the `MODEL_NAME` and `DATASET_NAME` environment variables. Here, we will use [Kandinsky 2.2](https://huggingface.co/kandinsky-community/kandinsky-2-2-decoder) and the [Narutos dataset](https://huggingface.co/datasets/lambdalabs/naruto-blip-captions).
#### Train decoder #### Train decoder
...@@ -244,7 +244,7 @@ accelerate launch --mixed_precision="fp16" train_text_to_image_decoder_lora.py \ ...@@ -244,7 +244,7 @@ accelerate launch --mixed_precision="fp16" train_text_to_image_decoder_lora.py \
--seed=42 \ --seed=42 \
--rank=4 \ --rank=4 \
--gradient_checkpointing \ --gradient_checkpointing \
--output_dir="kandi22-decoder-pokemon-lora" \ --output_dir="kandi22-decoder-naruto-lora" \
--validation_prompt="cute dragon creature" --report_to="wandb" \ --validation_prompt="cute dragon creature" --report_to="wandb" \
--push_to_hub \ --push_to_hub \
``` ```
...@@ -262,7 +262,7 @@ accelerate launch --mixed_precision="fp16" train_text_to_image_prior_lora.py \ ...@@ -262,7 +262,7 @@ accelerate launch --mixed_precision="fp16" train_text_to_image_prior_lora.py \
--learning_rate=1e-04 --lr_scheduler="constant" --lr_warmup_steps=0 \ --learning_rate=1e-04 --lr_scheduler="constant" --lr_warmup_steps=0 \
--seed=42 \ --seed=42 \
--rank=4 \ --rank=4 \
--output_dir="kandi22-prior-pokemon-lora" \ --output_dir="kandi22-prior-naruto-lora" \
--validation_prompt="cute dragon creature" --report_to="wandb" \ --validation_prompt="cute dragon creature" --report_to="wandb" \
--push_to_hub \ --push_to_hub \
``` ```
...@@ -274,7 +274,7 @@ accelerate launch --mixed_precision="fp16" train_text_to_image_prior_lora.py \ ...@@ -274,7 +274,7 @@ accelerate launch --mixed_precision="fp16" train_text_to_image_prior_lora.py \
#### Inference using fine-tuned LoRA checkpoint for decoder #### Inference using fine-tuned LoRA checkpoint for decoder
Once you have trained a Kandinsky decoder model using the above command, inference can be done with the `AutoPipelineForText2Image` after loading the trained LoRA weights. You need to pass the `output_dir` for loading the LoRA weights, which in this case is `kandi22-decoder-pokemon-lora`. Once you have trained a Kandinsky decoder model using the above command, inference can be done with the `AutoPipelineForText2Image` after loading the trained LoRA weights. You need to pass the `output_dir` for loading the LoRA weights, which in this case is `kandi22-decoder-naruto-lora`.
```python ```python
...@@ -285,9 +285,9 @@ pipe = AutoPipelineForText2Image.from_pretrained("kandinsky-community/kandinsky- ...@@ -285,9 +285,9 @@ pipe = AutoPipelineForText2Image.from_pretrained("kandinsky-community/kandinsky-
pipe.unet.load_attn_procs(output_dir) pipe.unet.load_attn_procs(output_dir)
pipe.enable_model_cpu_offload() pipe.enable_model_cpu_offload()
prompt='A robot pokemon, 4k photo' prompt='A robot naruto, 4k photo'
image = pipe(prompt=prompt).images[0] image = pipe(prompt=prompt).images[0]
image.save("robot_pokemon.png") image.save("robot_naruto.png")
``` ```
#### Inference using fine-tuned LoRA checkpoint for prior #### Inference using fine-tuned LoRA checkpoint for prior
...@@ -300,9 +300,9 @@ pipe = AutoPipelineForText2Image.from_pretrained("kandinsky-community/kandinsky- ...@@ -300,9 +300,9 @@ pipe = AutoPipelineForText2Image.from_pretrained("kandinsky-community/kandinsky-
pipe.prior_prior.load_attn_procs(output_dir) pipe.prior_prior.load_attn_procs(output_dir)
pipe.enable_model_cpu_offload() pipe.enable_model_cpu_offload()
prompt='A robot pokemon, 4k photo' prompt='A robot naruto, 4k photo'
image = pipe(prompt=prompt).images[0] image = pipe(prompt=prompt).images[0]
image.save("robot_pokemon.png") image.save("robot_naruto.png")
image image
``` ```
......
...@@ -10,7 +10,7 @@ By default, `n_guide_steps=2` to match the original implementation. ...@@ -10,7 +10,7 @@ By default, `n_guide_steps=2` to match the original implementation.
You will need some RL specific requirements to run the examples: You will need some RL specific requirements to run the examples:
``` ```sh
pip install -f https://download.pytorch.org/whl/torch_stable.html \ pip install -f https://download.pytorch.org/whl/torch_stable.html \
free-mujoco-py \ free-mujoco-py \
einops \ einops \
......
...@@ -6,7 +6,7 @@ Updating them to the most recent version of the library will require some work. ...@@ -6,7 +6,7 @@ Updating them to the most recent version of the library will require some work.
To use any of them, just run the command To use any of them, just run the command
``` ```sh
pip install -r requirements.txt pip install -r requirements.txt
``` ```
inside the folder of your choice. inside the folder of your choice.
......
...@@ -19,7 +19,7 @@ on consumer GPUs like Tesla T4, Tesla V100. ...@@ -19,7 +19,7 @@ on consumer GPUs like Tesla T4, Tesla V100.
### Training ### Training
First, you need to set up your development environment as is explained in the [installation section](#installing-the-dependencies). Make sure to set the `MODEL_NAME` and `DATASET_NAME` environment variables. Here, we will use [Stable Diffusion v1-4](https://hf.co/CompVis/stable-diffusion-v1-4) and the [Pokemons dataset](https://huggingface.co/datasets/lambdalabs/naruto-blip-captions). First, you need to set up your development environment as is explained in the [installation section](#installing-the-dependencies). Make sure to set the `MODEL_NAME` and `DATASET_NAME` environment variables. Here, we will use [Stable Diffusion v1-4](https://hf.co/CompVis/stable-diffusion-v1-4) and the [Narutos dataset](https://huggingface.co/datasets/lambdalabs/naruto-blip-captions).
**___Note: Change the `resolution` to 768 if you are using the [stable-diffusion-2](https://huggingface.co/stabilityai/stable-diffusion-2) 768x768 model.___** **___Note: Change the `resolution` to 768 if you are using the [stable-diffusion-2](https://huggingface.co/stabilityai/stable-diffusion-2) 768x768 model.___**
...@@ -48,7 +48,7 @@ accelerate launch --mixed_precision="fp16" train_text_to_image_lora.py \ ...@@ -48,7 +48,7 @@ accelerate launch --mixed_precision="fp16" train_text_to_image_lora.py \
--num_train_epochs=100 --checkpointing_steps=5000 \ --num_train_epochs=100 --checkpointing_steps=5000 \
--learning_rate=1e-04 --lr_scheduler="constant" --lr_warmup_steps=0 \ --learning_rate=1e-04 --lr_scheduler="constant" --lr_warmup_steps=0 \
--seed=42 \ --seed=42 \
--output_dir="sd-pokemon-model-lora" \ --output_dir="sd-naruto-model-lora" \
--validation_prompt="cute dragon creature" --report_to="wandb" --validation_prompt="cute dragon creature" --report_to="wandb"
--use_peft \ --use_peft \
--lora_r=4 --lora_alpha=32 \ --lora_r=4 --lora_alpha=32 \
...@@ -66,7 +66,7 @@ You can check some inference samples that were logged during the course of the f ...@@ -66,7 +66,7 @@ You can check some inference samples that were logged during the course of the f
### Inference ### Inference
Once you have trained a model using above command, the inference can be done simply using the `StableDiffusionPipeline` after loading the trained LoRA weights. You Once you have trained a model using above command, the inference can be done simply using the `StableDiffusionPipeline` after loading the trained LoRA weights. You
need to pass the `output_dir` for loading the LoRA weights which, in this case, is `sd-pokemon-model-lora`. need to pass the `output_dir` for loading the LoRA weights which, in this case, is `sd-naruto-model-lora`.
```python ```python
from diffusers import StableDiffusionPipeline from diffusers import StableDiffusionPipeline
...@@ -77,7 +77,7 @@ pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", ...@@ -77,7 +77,7 @@ pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4",
pipe.unet.load_attn_procs(model_path) pipe.unet.load_attn_procs(model_path)
pipe.to("cuda") pipe.to("cuda")
prompt = "A pokemon with green eyes and red legs." prompt = "A naruto with green eyes and red legs."
image = pipe(prompt, num_inference_steps=30, guidance_scale=7.5).images[0] image = pipe(prompt, num_inference_steps=30, guidance_scale=7.5).images[0]
image.save("pokemon.png") image.save("naruto.png")
``` ```
\ No newline at end of file
...@@ -32,7 +32,7 @@ And initialize an [🤗Accelerate](https://github.com/huggingface/accelerate/) e ...@@ -32,7 +32,7 @@ And initialize an [🤗Accelerate](https://github.com/huggingface/accelerate/) e
accelerate config accelerate config
``` ```
### Pokemon example ### Naruto example
You need to accept the model license before downloading or using the weights. In this example we'll use model version `v1-4`, so you'll need to visit [its card](https://huggingface.co/CompVis/stable-diffusion-v1-4), read the license and tick the checkbox if you agree. You need to accept the model license before downloading or using the weights. In this example we'll use model version `v1-4`, so you'll need to visit [its card](https://huggingface.co/CompVis/stable-diffusion-v1-4), read the license and tick the checkbox if you agree.
...@@ -51,7 +51,7 @@ If you have already cloned the repo, then you won't need to go through these ste ...@@ -51,7 +51,7 @@ If you have already cloned the repo, then you won't need to go through these ste
## Use ONNXRuntime to accelerate training ## Use ONNXRuntime to accelerate training
In order to leverage onnxruntime to accelerate training, please use train_text_to_image.py In order to leverage onnxruntime to accelerate training, please use train_text_to_image.py
The command to train a DDPM UNetCondition model on the Pokemon dataset with onnxruntime: The command to train a DDPM UNetCondition model on the Naruto dataset with onnxruntime:
```bash ```bash
export MODEL_NAME="CompVis/stable-diffusion-v1-4" export MODEL_NAME="CompVis/stable-diffusion-v1-4"
...@@ -68,7 +68,7 @@ accelerate launch --mixed_precision="fp16" train_text_to_image.py \ ...@@ -68,7 +68,7 @@ accelerate launch --mixed_precision="fp16" train_text_to_image.py \
--learning_rate=1e-05 \ --learning_rate=1e-05 \
--max_grad_norm=1 \ --max_grad_norm=1 \
--lr_scheduler="constant" --lr_warmup_steps=0 \ --lr_scheduler="constant" --lr_warmup_steps=0 \
--output_dir="sd-pokemon-model" --output_dir="sd-naruto-model"
``` ```
Please contact Prathik Rao (prathikr), Sunghoon Choi (hanbitmyths), Ashwini Khade (askhade), or Peng Wang (pengwa) on github with any questions. Please contact Prathik Rao (prathikr), Sunghoon Choi (hanbitmyths), Ashwini Khade (askhade), or Peng Wang (pengwa) on github with any questions.
\ No newline at end of file
...@@ -18,13 +18,13 @@ ...@@ -18,13 +18,13 @@
Upon having access to a TPU VM (TPUs higher than version 3), you should first install Upon having access to a TPU VM (TPUs higher than version 3), you should first install
a TPU-compatible version of JAX: a TPU-compatible version of JAX:
``` ```sh
pip install jax[tpu] -f https://storage.googleapis.com/jax-releases/libtpu_releases.html pip install jax[tpu] -f https://storage.googleapis.com/jax-releases/libtpu_releases.html
``` ```
Next, we can install [flax](https://github.com/google/flax) and the diffusers library: Next, we can install [flax](https://github.com/google/flax) and the diffusers library:
``` ```sh
pip install flax diffusers transformers pip install flax diffusers transformers
``` ```
......
...@@ -34,7 +34,7 @@ accelerate config ...@@ -34,7 +34,7 @@ accelerate config
Note also that we use PEFT library as backend for LoRA training, make sure to have `peft>=0.6.0` installed in your environment. Note also that we use PEFT library as backend for LoRA training, make sure to have `peft>=0.6.0` installed in your environment.
### Pokemon example ### Naruto example
You need to accept the model license before downloading or using the weights. In this example we'll use model version `v1-4`, so you'll need to visit [its card](https://huggingface.co/CompVis/stable-diffusion-v1-4), read the license and tick the checkbox if you agree. You need to accept the model license before downloading or using the weights. In this example we'll use model version `v1-4`, so you'll need to visit [its card](https://huggingface.co/CompVis/stable-diffusion-v1-4), read the license and tick the checkbox if you agree.
...@@ -71,7 +71,7 @@ accelerate launch --mixed_precision="fp16" train_text_to_image.py \ ...@@ -71,7 +71,7 @@ accelerate launch --mixed_precision="fp16" train_text_to_image.py \
--learning_rate=1e-05 \ --learning_rate=1e-05 \
--max_grad_norm=1 \ --max_grad_norm=1 \
--lr_scheduler="constant" --lr_warmup_steps=0 \ --lr_scheduler="constant" --lr_warmup_steps=0 \
--output_dir="sd-pokemon-model" --output_dir="sd-naruto-model"
``` ```
<!-- accelerate_snippet_end --> <!-- accelerate_snippet_end -->
...@@ -95,11 +95,11 @@ accelerate launch --mixed_precision="fp16" train_text_to_image.py \ ...@@ -95,11 +95,11 @@ accelerate launch --mixed_precision="fp16" train_text_to_image.py \
--learning_rate=1e-05 \ --learning_rate=1e-05 \
--max_grad_norm=1 \ --max_grad_norm=1 \
--lr_scheduler="constant" --lr_warmup_steps=0 \ --lr_scheduler="constant" --lr_warmup_steps=0 \
--output_dir="sd-pokemon-model" --output_dir="sd-naruto-model"
``` ```
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` Once the training is finished the model will be saved in the `output_dir` specified in the command. In this example it's `sd-naruto-model`. To load the fine-tuned model for inference just pass that path to `StableDiffusionPipeline`
```python ```python
import torch import torch
...@@ -110,7 +110,7 @@ pipe = StableDiffusionPipeline.from_pretrained(model_path, torch_dtype=torch.flo ...@@ -110,7 +110,7 @@ pipe = StableDiffusionPipeline.from_pretrained(model_path, torch_dtype=torch.flo
pipe.to("cuda") pipe.to("cuda")
image = pipe(prompt="yoda").images[0] image = pipe(prompt="yoda").images[0]
image.save("yoda-pokemon.png") image.save("yoda-naruto.png")
``` ```
Checkpoints only save the unet, so to run inference from a checkpoint, just load the unet Checkpoints only save the unet, so to run inference from a checkpoint, just load the unet
...@@ -126,7 +126,7 @@ pipe = StableDiffusionPipeline.from_pretrained("<initial model>", unet=unet, tor ...@@ -126,7 +126,7 @@ pipe = StableDiffusionPipeline.from_pretrained("<initial model>", unet=unet, tor
pipe.to("cuda") pipe.to("cuda")
image = pipe(prompt="yoda").images[0] image = pipe(prompt="yoda").images[0]
image.save("yoda-pokemon.png") image.save("yoda-naruto.png")
``` ```
#### Training with multiple GPUs #### Training with multiple GPUs
...@@ -150,7 +150,7 @@ accelerate launch --mixed_precision="fp16" --multi_gpu train_text_to_image.py \ ...@@ -150,7 +150,7 @@ accelerate launch --mixed_precision="fp16" --multi_gpu train_text_to_image.py \
--learning_rate=1e-05 \ --learning_rate=1e-05 \
--max_grad_norm=1 \ --max_grad_norm=1 \
--lr_scheduler="constant" --lr_warmup_steps=0 \ --lr_scheduler="constant" --lr_warmup_steps=0 \
--output_dir="sd-pokemon-model" --output_dir="sd-naruto-model"
``` ```
...@@ -166,7 +166,7 @@ You can find [this project on Weights and Biases](https://wandb.ai/sayakpaul/tex ...@@ -166,7 +166,7 @@ You can find [this project on Weights and Biases](https://wandb.ai/sayakpaul/tex
* Training with the Min-SNR weighting strategy (`snr_gamma` set to 5.0) * Training with the Min-SNR weighting strategy (`snr_gamma` set to 5.0)
* Training with the Min-SNR weighting strategy (`snr_gamma` set to 1.0) * Training with the Min-SNR weighting strategy (`snr_gamma` set to 1.0)
For our small Pokemons dataset, the effects of Min-SNR weighting strategy might not appear to be pronounced, but for larger datasets, we believe the effects will be more pronounced. For our small Narutos dataset, the effects of Min-SNR weighting strategy might not appear to be pronounced, but for larger datasets, we believe the effects will be more pronounced.
Also, note that in this example, we either predict `epsilon` (i.e., the noise) or the `v_prediction`. For both of these cases, the formulation of the Min-SNR weighting strategy that we have used holds. Also, note that in this example, we either predict `epsilon` (i.e., the noise) or the `v_prediction`. For both of these cases, the formulation of the Min-SNR weighting strategy that we have used holds.
...@@ -192,7 +192,7 @@ on consumer GPUs like Tesla T4, Tesla V100. ...@@ -192,7 +192,7 @@ on consumer GPUs like Tesla T4, Tesla V100.
### Training ### Training
First, you need to set up your development environment as is explained in the [installation section](#installing-the-dependencies). Make sure to set the `MODEL_NAME` and `DATASET_NAME` environment variables. Here, we will use [Stable Diffusion v1-4](https://hf.co/CompVis/stable-diffusion-v1-4) and the [Pokemons dataset](https://huggingface.co/datasets/lambdalabs/naruto-blip-captions). First, you need to set up your development environment as is explained in the [installation section](#installing-the-dependencies). Make sure to set the `MODEL_NAME` and `DATASET_NAME` environment variables. Here, we will use [Stable Diffusion v1-4](https://hf.co/CompVis/stable-diffusion-v1-4) and the [Narutos dataset](https://huggingface.co/datasets/lambdalabs/naruto-blip-captions).
**___Note: Change the `resolution` to 768 if you are using the [stable-diffusion-2](https://huggingface.co/stabilityai/stable-diffusion-2) 768x768 model.___** **___Note: Change the `resolution` to 768 if you are using the [stable-diffusion-2](https://huggingface.co/stabilityai/stable-diffusion-2) 768x768 model.___**
...@@ -221,7 +221,7 @@ accelerate launch --mixed_precision="fp16" train_text_to_image_lora.py \ ...@@ -221,7 +221,7 @@ accelerate launch --mixed_precision="fp16" train_text_to_image_lora.py \
--num_train_epochs=100 --checkpointing_steps=5000 \ --num_train_epochs=100 --checkpointing_steps=5000 \
--learning_rate=1e-04 --lr_scheduler="constant" --lr_warmup_steps=0 \ --learning_rate=1e-04 --lr_scheduler="constant" --lr_warmup_steps=0 \
--seed=42 \ --seed=42 \
--output_dir="sd-pokemon-model-lora" \ --output_dir="sd-naruto-model-lora" \
--validation_prompt="cute dragon creature" --report_to="wandb" --validation_prompt="cute dragon creature" --report_to="wandb"
``` ```
...@@ -236,7 +236,7 @@ You can check some inference samples that were logged during the course of the f ...@@ -236,7 +236,7 @@ You can check some inference samples that were logged during the course of the f
### Inference ### Inference
Once you have trained a model using above command, the inference can be done simply using the `StableDiffusionPipeline` after loading the trained LoRA weights. You Once you have trained a model using above command, the inference can be done simply using the `StableDiffusionPipeline` after loading the trained LoRA weights. You
need to pass the `output_dir` for loading the LoRA weights which, in this case, is `sd-pokemon-model-lora`. need to pass the `output_dir` for loading the LoRA weights which, in this case, is `sd-naruto-model-lora`.
```python ```python
from diffusers import StableDiffusionPipeline from diffusers import StableDiffusionPipeline
...@@ -247,9 +247,9 @@ pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", ...@@ -247,9 +247,9 @@ pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4",
pipe.unet.load_attn_procs(model_path) pipe.unet.load_attn_procs(model_path)
pipe.to("cuda") pipe.to("cuda")
prompt = "A pokemon with green eyes and red legs." prompt = "A naruto with green eyes and red legs."
image = pipe(prompt, num_inference_steps=30, guidance_scale=7.5).images[0] image = pipe(prompt, num_inference_steps=30, guidance_scale=7.5).images[0]
image.save("pokemon.png") image.save("naruto.png")
``` ```
If you are loading the LoRA parameters from the Hub and if the Hub repository has If you are loading the LoRA parameters from the Hub and if the Hub repository has
...@@ -293,7 +293,7 @@ python train_text_to_image_flax.py \ ...@@ -293,7 +293,7 @@ python train_text_to_image_flax.py \
--max_train_steps=15000 \ --max_train_steps=15000 \
--learning_rate=1e-05 \ --learning_rate=1e-05 \
--max_grad_norm=1 \ --max_grad_norm=1 \
--output_dir="sd-pokemon-model" --output_dir="sd-naruto-model"
``` ```
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). 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).
...@@ -312,7 +312,7 @@ python train_text_to_image_flax.py \ ...@@ -312,7 +312,7 @@ python train_text_to_image_flax.py \
--max_train_steps=15000 \ --max_train_steps=15000 \
--learning_rate=1e-05 \ --learning_rate=1e-05 \
--max_grad_norm=1 \ --max_grad_norm=1 \
--output_dir="sd-pokemon-model" --output_dir="sd-naruto-model"
``` ```
### Training with xFormers: ### Training with xFormers:
......
...@@ -70,7 +70,7 @@ accelerate launch train_text_to_image_sdxl.py \ ...@@ -70,7 +70,7 @@ accelerate launch train_text_to_image_sdxl.py \
--report_to="wandb" \ --report_to="wandb" \
--validation_prompt="a cute Sundar Pichai creature" --validation_epochs 5 \ --validation_prompt="a cute Sundar Pichai creature" --validation_epochs 5 \
--checkpointing_steps=5000 \ --checkpointing_steps=5000 \
--output_dir="sdxl-pokemon-model" \ --output_dir="sdxl-naruto-model" \
--push_to_hub --push_to_hub
``` ```
...@@ -91,9 +91,9 @@ model_path = "you-model-id-goes-here" # <-- change this ...@@ -91,9 +91,9 @@ model_path = "you-model-id-goes-here" # <-- change this
pipe = DiffusionPipeline.from_pretrained(model_path, torch_dtype=torch.float16) pipe = DiffusionPipeline.from_pretrained(model_path, torch_dtype=torch.float16)
pipe.to("cuda") pipe.to("cuda")
prompt = "A pokemon with green eyes and red legs." prompt = "A naruto with green eyes and red legs."
image = pipe(prompt, num_inference_steps=30, guidance_scale=7.5).images[0] image = pipe(prompt, num_inference_steps=30, guidance_scale=7.5).images[0]
image.save("pokemon.png") image.save("naruto.png")
``` ```
### Inference in Pytorch XLA ### Inference in Pytorch XLA
...@@ -108,11 +108,11 @@ pipe = DiffusionPipeline.from_pretrained(model_id) ...@@ -108,11 +108,11 @@ pipe = DiffusionPipeline.from_pretrained(model_id)
device = xm.xla_device() device = xm.xla_device()
pipe.to(device) pipe.to(device)
prompt = "A pokemon with green eyes and red legs." prompt = "A naruto with green eyes and red legs."
start = time() start = time()
image = pipe(prompt, num_inference_steps=inference_steps).images[0] image = pipe(prompt, num_inference_steps=inference_steps).images[0]
print(f'Compilation time is {time()-start} sec') print(f'Compilation time is {time()-start} sec')
image.save("pokemon.png") image.save("naruto.png")
start = time() start = time()
image = pipe(prompt, num_inference_steps=inference_steps).images[0] image = pipe(prompt, num_inference_steps=inference_steps).images[0]
...@@ -142,7 +142,7 @@ on consumer GPUs like Tesla T4, Tesla V100. ...@@ -142,7 +142,7 @@ on consumer GPUs like Tesla T4, Tesla V100.
### Training ### Training
First, you need to set up your development environment as is explained in the [installation section](#installing-the-dependencies). Make sure to set the `MODEL_NAME` and `DATASET_NAME` environment variables and, optionally, the `VAE_NAME` variable. Here, we will use [Stable Diffusion XL 1.0-base](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0) and the [Pokemons dataset](https://huggingface.co/datasets/lambdalabs/naruto-blip-captions). First, you need to set up your development environment as is explained in the [installation section](#installing-the-dependencies). Make sure to set the `MODEL_NAME` and `DATASET_NAME` environment variables and, optionally, the `VAE_NAME` variable. Here, we will use [Stable Diffusion XL 1.0-base](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0) and the [Narutos dataset](https://huggingface.co/datasets/lambdalabs/naruto-blip-captions).
**___Note: It is quite useful to monitor the training progress by regularly generating sample images during training. [Weights and Biases](https://docs.wandb.ai/quickstart) is a nice solution to easily see generating images during training. All you need to do is to run `pip install wandb` before training to automatically log images.___** **___Note: It is quite useful to monitor the training progress by regularly generating sample images during training. [Weights and Biases](https://docs.wandb.ai/quickstart) is a nice solution to easily see generating images during training. All you need to do is to run `pip install wandb` before training to automatically log images.___**
...@@ -172,7 +172,7 @@ accelerate launch train_text_to_image_lora_sdxl.py \ ...@@ -172,7 +172,7 @@ accelerate launch train_text_to_image_lora_sdxl.py \
--learning_rate=1e-04 --lr_scheduler="constant" --lr_warmup_steps=0 \ --learning_rate=1e-04 --lr_scheduler="constant" --lr_warmup_steps=0 \
--mixed_precision="fp16" \ --mixed_precision="fp16" \
--seed=42 \ --seed=42 \
--output_dir="sd-pokemon-model-lora-sdxl" \ --output_dir="sd-naruto-model-lora-sdxl" \
--validation_prompt="cute dragon creature" --report_to="wandb" \ --validation_prompt="cute dragon creature" --report_to="wandb" \
--push_to_hub --push_to_hub
``` ```
...@@ -237,7 +237,7 @@ accelerate launch --config_file $ACCELERATE_CONFIG_FILE train_text_to_image_lor ...@@ -237,7 +237,7 @@ accelerate launch --config_file $ACCELERATE_CONFIG_FILE train_text_to_image_lor
--max_train_steps=20 \ --max_train_steps=20 \
--validation_epochs=20 \ --validation_epochs=20 \
--seed=1234 \ --seed=1234 \
--output_dir="sd-pokemon-model-lora-sdxl" \ --output_dir="sd-naruto-model-lora-sdxl" \
--validation_prompt="cute dragon creature" --validation_prompt="cute dragon creature"
``` ```
...@@ -260,7 +260,7 @@ accelerate launch train_text_to_image_lora_sdxl.py \ ...@@ -260,7 +260,7 @@ accelerate launch train_text_to_image_lora_sdxl.py \
--num_train_epochs=2 --checkpointing_steps=500 \ --num_train_epochs=2 --checkpointing_steps=500 \
--learning_rate=1e-04 --lr_scheduler="constant" --lr_warmup_steps=0 \ --learning_rate=1e-04 --lr_scheduler="constant" --lr_warmup_steps=0 \
--seed=42 \ --seed=42 \
--output_dir="sd-pokemon-model-lora-sdxl-txt" \ --output_dir="sd-naruto-model-lora-sdxl-txt" \
--train_text_encoder \ --train_text_encoder \
--validation_prompt="cute dragon creature" --report_to="wandb" \ --validation_prompt="cute dragon creature" --report_to="wandb" \
--push_to_hub --push_to_hub
...@@ -269,18 +269,18 @@ accelerate launch train_text_to_image_lora_sdxl.py \ ...@@ -269,18 +269,18 @@ accelerate launch train_text_to_image_lora_sdxl.py \
### Inference ### Inference
Once you have trained a model using above command, the inference can be done simply using the `DiffusionPipeline` after loading the trained LoRA weights. You Once you have trained a model using above command, the inference can be done simply using the `DiffusionPipeline` after loading the trained LoRA weights. You
need to pass the `output_dir` for loading the LoRA weights which, in this case, is `sd-pokemon-model-lora-sdxl`. need to pass the `output_dir` for loading the LoRA weights which, in this case, is `sd-naruto-model-lora-sdxl`.
```python ```python
from diffusers import DiffusionPipeline from diffusers import DiffusionPipeline
import torch import torch
model_path = "takuoko/sd-pokemon-model-lora-sdxl" model_path = "takuoko/sd-naruto-model-lora-sdxl"
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16) pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16)
pipe.to("cuda") pipe.to("cuda")
pipe.load_lora_weights(model_path) pipe.load_lora_weights(model_path)
prompt = "A pokemon with green eyes and red legs." prompt = "A naruto with green eyes and red legs."
image = pipe(prompt, num_inference_steps=30, guidance_scale=7.5).images[0] image = pipe(prompt, num_inference_steps=30, guidance_scale=7.5).images[0]
image.save("pokemon.png") image.save("naruto.png")
``` ```
## Textual Inversion fine-tuning example for SDXL ## Textual Inversion fine-tuning example for SDXL
``` ```sh
export MODEL_NAME="stabilityai/stable-diffusion-xl-base-1.0" export MODEL_NAME="stabilityai/stable-diffusion-xl-base-1.0"
export DATA_DIR="./cat" export DATA_DIR="./cat"
......
...@@ -52,10 +52,10 @@ accelerate launch train_text_to_image_prior.py \ ...@@ -52,10 +52,10 @@ accelerate launch train_text_to_image_prior.py \
--max_grad_norm=1 \ --max_grad_norm=1 \
--checkpoints_total_limit=3 \ --checkpoints_total_limit=3 \
--lr_scheduler="constant" --lr_warmup_steps=0 \ --lr_scheduler="constant" --lr_warmup_steps=0 \
--validation_prompts="A robot pokemon, 4k photo" \ --validation_prompts="A robot naruto, 4k photo" \
--report_to="wandb" \ --report_to="wandb" \
--push_to_hub \ --push_to_hub \
--output_dir="wuerstchen-prior-pokemon-model" --output_dir="wuerstchen-prior-naruto-model"
``` ```
<!-- accelerate_snippet_end --> <!-- accelerate_snippet_end -->
...@@ -72,7 +72,7 @@ In a nutshell, LoRA allows adapting pretrained models by adding pairs of rank-de ...@@ -72,7 +72,7 @@ In a nutshell, LoRA allows adapting pretrained models by adding pairs of rank-de
### Prior Training ### Prior Training
First, you need to set up your development environment as explained in the [installation](#Running-locally-with-PyTorch) section. Make sure to set the `DATASET_NAME` environment variable. Here, we will use the [Pokemon captions dataset](https://huggingface.co/datasets/lambdalabs/naruto-blip-captions). First, you need to set up your development environment as explained in the [installation](#Running-locally-with-PyTorch) section. Make sure to set the `DATASET_NAME` environment variable. Here, we will use the [Naruto captions dataset](https://huggingface.co/datasets/lambdalabs/naruto-blip-captions).
```bash ```bash
export DATASET_NAME="lambdalabs/naruto-blip-captions" export DATASET_NAME="lambdalabs/naruto-blip-captions"
...@@ -89,5 +89,5 @@ accelerate launch train_text_to_image_lora_prior.py \ ...@@ -89,5 +89,5 @@ accelerate launch train_text_to_image_lora_prior.py \
--validation_prompt="cute dragon creature" \ --validation_prompt="cute dragon creature" \
--report_to="wandb" \ --report_to="wandb" \
--push_to_hub \ --push_to_hub \
--output_dir="wuerstchen-prior-pokemon-lora" --output_dir="wuerstchen-prior-naruto-lora"
``` ```
...@@ -85,10 +85,9 @@ EXAMPLE_DOC_STRING = """ ...@@ -85,10 +85,9 @@ EXAMPLE_DOC_STRING = """
>>> init_image = download_image(img_url).resize((768, 768)) >>> init_image = download_image(img_url).resize((768, 768))
>>> pipe = StableDiffusionDiffEditPipeline.from_pretrained( >>> pipeline = StableDiffusionDiffEditPipeline.from_pretrained(
... "stabilityai/stable-diffusion-2-1", torch_dtype=torch.float16 ... "stabilityai/stable-diffusion-2-1", torch_dtype=torch.float16
... ) ... )
>>> pipe = pipe.to("cuda")
>>> pipeline.scheduler = DDIMScheduler.from_config(pipeline.scheduler.config) >>> pipeline.scheduler = DDIMScheduler.from_config(pipeline.scheduler.config)
>>> pipeline.inverse_scheduler = DDIMInverseScheduler.from_config(pipeline.scheduler.config) >>> pipeline.inverse_scheduler = DDIMInverseScheduler.from_config(pipeline.scheduler.config)
...@@ -97,9 +96,9 @@ EXAMPLE_DOC_STRING = """ ...@@ -97,9 +96,9 @@ EXAMPLE_DOC_STRING = """
>>> mask_prompt = "A bowl of fruits" >>> mask_prompt = "A bowl of fruits"
>>> prompt = "A bowl of pears" >>> prompt = "A bowl of pears"
>>> mask_image = pipe.generate_mask(image=init_image, source_prompt=prompt, target_prompt=mask_prompt) >>> mask_image = pipeline.generate_mask(image=init_image, source_prompt=prompt, target_prompt=mask_prompt)
>>> image_latents = pipe.invert(image=init_image, prompt=mask_prompt).latents >>> image_latents = pipeline.invert(image=init_image, prompt=mask_prompt).latents
>>> image = pipe(prompt=prompt, mask_image=mask_image, image_latents=image_latents).images[0] >>> image = pipeline(prompt=prompt, mask_image=mask_image, image_latents=image_latents).images[0]
``` ```
""" """
...@@ -122,10 +121,9 @@ EXAMPLE_INVERT_DOC_STRING = """ ...@@ -122,10 +121,9 @@ EXAMPLE_INVERT_DOC_STRING = """
>>> init_image = download_image(img_url).resize((768, 768)) >>> init_image = download_image(img_url).resize((768, 768))
>>> pipe = StableDiffusionDiffEditPipeline.from_pretrained( >>> pipeline = StableDiffusionDiffEditPipeline.from_pretrained(
... "stabilityai/stable-diffusion-2-1", torch_dtype=torch.float16 ... "stabilityai/stable-diffusion-2-1", torch_dtype=torch.float16
... ) ... )
>>> pipe = pipe.to("cuda")
>>> pipeline.scheduler = DDIMScheduler.from_config(pipeline.scheduler.config) >>> pipeline.scheduler = DDIMScheduler.from_config(pipeline.scheduler.config)
>>> pipeline.inverse_scheduler = DDIMInverseScheduler.from_config(pipeline.scheduler.config) >>> pipeline.inverse_scheduler = DDIMInverseScheduler.from_config(pipeline.scheduler.config)
...@@ -133,7 +131,7 @@ EXAMPLE_INVERT_DOC_STRING = """ ...@@ -133,7 +131,7 @@ EXAMPLE_INVERT_DOC_STRING = """
>>> prompt = "A bowl of fruits" >>> prompt = "A bowl of fruits"
>>> inverted_latents = pipe.invert(image=init_image, prompt=prompt).latents >>> inverted_latents = pipeline.invert(image=init_image, prompt=prompt).latents
``` ```
""" """
......
...@@ -692,7 +692,7 @@ def print_tree_deps_of(module, all_edges=None): ...@@ -692,7 +692,7 @@ def print_tree_deps_of(module, all_edges=None):
def init_test_examples_dependencies() -> Tuple[Dict[str, List[str]], List[str]]: def init_test_examples_dependencies() -> Tuple[Dict[str, List[str]], List[str]]:
""" """
The test examples do not import from the examples (which are just scripts, not modules) so we need som extra The test examples do not import from the examples (which are just scripts, not modules) so we need some extra
care initializing the dependency map, which is the goal of this function. It initializes the dependency map for care initializing the dependency map, which is the goal of this function. It initializes the dependency map for
example files by linking each example to the example test file for the example framework. example files by linking each example to the example test file for the example framework.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment