From 050e6282ef2e6baa2d5fd87e8762f8abdbbf7f27 Mon Sep 17 00:00:00 2001 From: linoytsaban Date: Wed, 23 Oct 2024 10:38:48 +0300 Subject: [PATCH 1/2] improve readme --- .../dreambooth/train_dreambooth_lora_sd3.py | 21 +++++++++++++------ examples/dreambooth/train_dreambooth_sd3.py | 18 +++++++++++----- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/examples/dreambooth/train_dreambooth_lora_sd3.py b/examples/dreambooth/train_dreambooth_lora_sd3.py index 8e33a5d32074..015ecd873f7c 100644 --- a/examples/dreambooth/train_dreambooth_lora_sd3.py +++ b/examples/dreambooth/train_dreambooth_lora_sd3.py @@ -86,6 +86,15 @@ def save_model_card( validation_prompt=None, repo_folder=None, ): + if "large" in base_model: + model_variant = "SD3.5-Large" + license_url = "https://huggingface.co/stabilityai/stable-diffusion-3.5-large/blob/main/LICENSE.md" + variant_tags = ["sd3.5-large", "sd3.5","sd3.5-diffusers"] + else: + model_variant = "SD3" + license_url = "https://huggingface.co/stabilityai/stable-diffusion-3-medium/blob/main/LICENSE.md" + variant_tags = ["sd3", "sd3-diffusers"] + widget_dict = [] if images is not None: for i, image in enumerate(images): @@ -95,7 +104,7 @@ def save_model_card( ) model_description = f""" -# SD3 DreamBooth LoRA - {repo_id} +# {model_variant} DreamBooth LoRA - {repo_id} @@ -120,7 +129,7 @@ def save_model_card( ```py from diffusers import AutoPipelineForText2Image import torch -pipeline = AutoPipelineForText2Image.from_pretrained('stabilityai/stable-diffusion-3-medium-diffusers', torch_dtype=torch.float16).to('cuda') +pipeline = AutoPipelineForText2Image.from_pretrained({base_model}, torch_dtype=torch.float16).to('cuda') pipeline.load_lora_weights('{repo_id}', weight_name='pytorch_lora_weights.safetensors') image = pipeline('{validation_prompt if validation_prompt else instance_prompt}').images[0] ``` @@ -135,7 +144,7 @@ def save_model_card( ## License -Please adhere to the licensing terms as described [here](https://huggingface.co/stabilityai/stable-diffusion-3-medium/blob/main/LICENSE). +Please adhere to the licensing terms as described [here]({license_url}). """ model_card = load_or_create_model_card( repo_id_or_path=repo_id, @@ -151,11 +160,11 @@ def save_model_card( "diffusers-training", "diffusers", "lora", - "sd3", - "sd3-diffusers", "template:sd-lora", ] + tags += variant_tags + model_card = populate_model_card(model_card, tags=tags) model_card.save(os.path.join(repo_folder, "README.md")) @@ -1920,4 +1929,4 @@ def get_sigmas(timesteps, n_dim=4, dtype=torch.float32): if __name__ == "__main__": args = parse_args() - main(args) + main(args) \ No newline at end of file diff --git a/examples/dreambooth/train_dreambooth_sd3.py b/examples/dreambooth/train_dreambooth_sd3.py index d5dfdfa218bc..2b6db1ecb906 100644 --- a/examples/dreambooth/train_dreambooth_sd3.py +++ b/examples/dreambooth/train_dreambooth_sd3.py @@ -77,6 +77,15 @@ def save_model_card( validation_prompt=None, repo_folder=None, ): + if "large" in base_model: + model_variant = "SD3.5-Large" + license_url = "https://huggingface.co/stabilityai/stable-diffusion-3.5-large/blob/main/LICENSE.md" + variant_tags = ["sd3.5-large", "sd3.5","sd3.5-diffusers"] + else: + model_variant = "SD3" + license_url = "https://huggingface.co/stabilityai/stable-diffusion-3-medium/blob/main/LICENSE.md" + variant_tags = ["sd3", "sd3-diffusers"] + widget_dict = [] if images is not None: for i, image in enumerate(images): @@ -86,7 +95,7 @@ def save_model_card( ) model_description = f""" -# SD3 DreamBooth - {repo_id} +# {model_variant} DreamBooth - {repo_id} @@ -113,7 +122,7 @@ def save_model_card( ## License -Please adhere to the licensing terms as described `[here](https://huggingface.co/stabilityai/stable-diffusion-3-medium/blob/main/LICENSE)`. +Please adhere to the licensing terms as described `[here]({license_url})`. """ model_card = load_or_create_model_card( repo_id_or_path=repo_id, @@ -128,10 +137,9 @@ def save_model_card( "text-to-image", "diffusers-training", "diffusers", - "sd3", - "sd3-diffusers", "template:sd-lora", ] + tags += variant_tags model_card = populate_model_card(model_card, tags=tags) model_card.save(os.path.join(repo_folder, "README.md")) @@ -1799,4 +1807,4 @@ def get_sigmas(timesteps, n_dim=4, dtype=torch.float32): if __name__ == "__main__": args = parse_args() - main(args) + main(args) \ No newline at end of file From 3afc3c87893d0ceedfa5feb698e4600126923d94 Mon Sep 17 00:00:00 2001 From: Linoy Date: Wed, 23 Oct 2024 15:00:56 +0000 Subject: [PATCH 2/2] style --- examples/dreambooth/train_dreambooth_lora_sd3.py | 4 ++-- examples/dreambooth/train_dreambooth_sd3.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/dreambooth/train_dreambooth_lora_sd3.py b/examples/dreambooth/train_dreambooth_lora_sd3.py index 015ecd873f7c..4b39dcfe41b0 100644 --- a/examples/dreambooth/train_dreambooth_lora_sd3.py +++ b/examples/dreambooth/train_dreambooth_lora_sd3.py @@ -89,7 +89,7 @@ def save_model_card( if "large" in base_model: model_variant = "SD3.5-Large" license_url = "https://huggingface.co/stabilityai/stable-diffusion-3.5-large/blob/main/LICENSE.md" - variant_tags = ["sd3.5-large", "sd3.5","sd3.5-diffusers"] + variant_tags = ["sd3.5-large", "sd3.5", "sd3.5-diffusers"] else: model_variant = "SD3" license_url = "https://huggingface.co/stabilityai/stable-diffusion-3-medium/blob/main/LICENSE.md" @@ -1929,4 +1929,4 @@ def get_sigmas(timesteps, n_dim=4, dtype=torch.float32): if __name__ == "__main__": args = parse_args() - main(args) \ No newline at end of file + main(args) diff --git a/examples/dreambooth/train_dreambooth_sd3.py b/examples/dreambooth/train_dreambooth_sd3.py index 2b6db1ecb906..5d10345304ab 100644 --- a/examples/dreambooth/train_dreambooth_sd3.py +++ b/examples/dreambooth/train_dreambooth_sd3.py @@ -80,7 +80,7 @@ def save_model_card( if "large" in base_model: model_variant = "SD3.5-Large" license_url = "https://huggingface.co/stabilityai/stable-diffusion-3.5-large/blob/main/LICENSE.md" - variant_tags = ["sd3.5-large", "sd3.5","sd3.5-diffusers"] + variant_tags = ["sd3.5-large", "sd3.5", "sd3.5-diffusers"] else: model_variant = "SD3" license_url = "https://huggingface.co/stabilityai/stable-diffusion-3-medium/blob/main/LICENSE.md" @@ -1807,4 +1807,4 @@ def get_sigmas(timesteps, n_dim=4, dtype=torch.float32): if __name__ == "__main__": args = parse_args() - main(args) \ No newline at end of file + main(args)