From 562405923f037042007cfa33052ec8b1d89eb53e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?apolin=C3=A1rio?= Date: Fri, 30 Aug 2024 17:34:28 -0500 Subject: [PATCH] Update README.md for `push_to_hub` (#143) Add diffusers examples and clarify how to use the model locally --- jobs/process/BaseSDTrainProcess.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/jobs/process/BaseSDTrainProcess.py b/jobs/process/BaseSDTrainProcess.py index 0392933c..455f28bb 100644 --- a/jobs/process/BaseSDTrainProcess.py +++ b/jobs/process/BaseSDTrainProcess.py @@ -1865,6 +1865,7 @@ class BaseSDTrainProcess(BaseTrainProcess): "lora", "diffusers", "template:sd-lora", + "ai-toolkit", ] ) @@ -1899,7 +1900,7 @@ class BaseSDTrainProcess(BaseTrainProcess): }, } ) - + dtype = "torch.bfloat16" if self.model_config.is_flux else "torch.float16" # Construct the README content readme_content = f"""--- tags: @@ -1921,10 +1922,25 @@ Model trained with [AI Toolkit by Ostris](https://github.com/ostris/ai-toolkit) {"You should use `" + instance_prompt + "` to trigger the image generation." if instance_prompt else "No trigger words defined."} -## Download model +## Download model and use it with ComfyUI, AUTOMATIC1111, SD.Next, Invoke AI, etc. Weights for this model are available in Safetensors format. [Download](/{repo_id}/tree/main) them in the Files & versions tab. + +## Use it with the [🧨 diffusers library](https://github.com/huggingface/diffusers) + +```py +from diffusers import AutoPipelineForText2Image +import torch + +pipeline = AutoPipelineForText2Image.from_pretrained('{base_model}', torch_dtype={dtype}).to('cuda') +pipeline.load_lora_weights('{repo_id}', weight_name='{self.job.name}') +image = pipeline('{instance_prompt if not widgets else self.sample_config.prompts[0]}').images[0] +image.save("my_image.png") +``` + +For more details, including weighting, merging and fusing LoRAs, check the [documentation on loading LoRAs in diffusers](https://huggingface.co/docs/diffusers/main/en/using-diffusers/loading_adapters) + """ return readme_content