import os from typing import List # Copied from https://github.com/huggingface/diffusers/blob/31be42209ddfdb69d9640a777b32e9b5c6259bf0/examples/text_to_image/train_text_to_image_lora.py#L55 def save_model_card( base_model=str, repo_folder=None, weight_paths: List = None, placeholder_token: str = None, ): yaml = f""" --- license: creativeml-openrail-m base_model: {base_model} tags: - stable-diffusion - stable-diffusion-diffusers - text-to-image - diffusers inference: true --- """ model_card = f""" # KerasCV Stable Diffusion in Diffusers 🧨🤗 The pipeline contained in this repository was created using [this Space](https://huggingface.co/spaces/sayakpaul/convert-kerascv-sd-diffusers). The purpose is to convert the KerasCV Stable Diffusion weights in a way that is compatible with [Diffusers](https://github.com/huggingface/diffusers). This allows users to fine-tune using KerasCV and use the fine-tuned weights in Diffusers taking advantage of its nifty features (like [schedulers](https://huggingface.co/docs/diffusers/main/en/using-diffusers/schedulers), [fast attention](https://huggingface.co/docs/diffusers/optimization/fp16), etc.).\n """ if len(weight_paths) > 0: model_card += f"Following weight paths (KerasCV) were used \n: {weight_paths}" if placeholder_token is not None: model_card += "\nFollowing `placeholder_token` was added to the tokenizer: {placeholder_token}." with open(os.path.join(repo_folder, "README.md"), "w") as f: f.write(yaml + model_card)