From a09eed237d6a0dc0e82bda201134fff5f0fedc1a Mon Sep 17 00:00:00 2001 From: Patrick von Platen Date: Tue, 18 Apr 2023 15:30:10 +0100 Subject: [PATCH 1/2] Update README.md --- examples/textual_inversion/README.md | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/examples/textual_inversion/README.md b/examples/textual_inversion/README.md index 3a7c96be69fb..c634ea4528e0 100644 --- a/examples/textual_inversion/README.md +++ b/examples/textual_inversion/README.md @@ -39,29 +39,31 @@ accelerate config ### Cat toy example -You need to accept the model license before downloading or using the weights. In this example we'll use model version `v1-5`, so you'll need to visit [its card](https://huggingface.co/runwayml/stable-diffusion-v1-5), read the license and tick the checkbox if you agree. - -You have to be a registered user in 🤗 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 [this section of the documentation](https://huggingface.co/docs/hub/security-tokens). - -Run the following command to authenticate your token +First, let's login so that we can upload the checkpoint to the Hub during training: ```bash huggingface-cli login ``` -If you have already cloned the repo, then you won't need to go through these steps. +Now let's get our dataset. For this example we will use some cat images: https://huggingface.co/datasets/diffusers/cat_toy_example . -
+Let's first download it locally: -Now let's get our dataset.Download 3-4 images from [here](https://drive.google.com/drive/folders/1fmJMs25nxS_rSNqS5hTcRdLem_YQXbq5) and save them in a directory. This will be our training data. +```py +from huggingface_hub import snapshot_download -And launch the training using +local_dir = "./cat" +snapshot_download("diffusers/cat_toy_example", local_dir=local_dir, repo_type="dataset") +``` + +This will be our training data. +Now we can launch the training using **___Note: Change the `resolution` to 768 if you are using the [stable-diffusion-2](https://huggingface.co/stabilityai/stable-diffusion-2) 768x768 model.___** ```bash export MODEL_NAME="runwayml/stable-diffusion-v1-5" -export DATA_DIR="path-to-dir-containing-images" +export DATA_DIR="./cat" accelerate launch textual_inversion.py \ --pretrained_model_name_or_path=$MODEL_NAME \ @@ -75,6 +77,7 @@ accelerate launch textual_inversion.py \ --learning_rate=5.0e-04 --scale_lr \ --lr_scheduler="constant" \ --lr_warmup_steps=0 \ + --push_to_hub \ --output_dir="textual_inversion_cat" ``` From 54ba858de841f150c6d0b5d13174aca2400f259f Mon Sep 17 00:00:00 2001 From: Patrick von Platen Date: Tue, 18 Apr 2023 16:04:40 +0100 Subject: [PATCH 2/2] Apply suggestions from code review --- examples/textual_inversion/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/textual_inversion/README.md b/examples/textual_inversion/README.md index c634ea4528e0..4d420b284f38 100644 --- a/examples/textual_inversion/README.md +++ b/examples/textual_inversion/README.md @@ -53,7 +53,7 @@ Let's first download it locally: from huggingface_hub import snapshot_download local_dir = "./cat" -snapshot_download("diffusers/cat_toy_example", local_dir=local_dir, repo_type="dataset") +snapshot_download("diffusers/cat_toy_example", local_dir=local_dir, repo_type="dataset", ignore_patterns=".gitattributes") ``` This will be our training data.