MCPcopy Create free account
hub / github.com/TencentARC/BrushNet / save_model_card

Function save_model_card

examples/custom_diffusion/train_custom_diffusion.py:76–110  ·  view source on GitHub ↗
(repo_id: str, images=None, base_model=str, prompt=str, repo_folder=None)

Source from the content-addressed store, hash-verified

74
75
76def save_model_card(repo_id: str, images=None, base_model=str, prompt=str, repo_folder=None):
77 img_str = ""
78 for i, image in enumerate(images):
79 image.save(os.path.join(repo_folder, f"image_{i}.png"))
80 img_str += f"![img_{i}](./image_{i}.png)\n"
81
82 model_description = f"""
83# Custom Diffusion - {repo_id}
84
85These are Custom Diffusion adaption weights for {base_model}. The weights were trained on {prompt} using [Custom Diffusion](https://www.cs.cmu.edu/~custom-diffusion). You can find some example images in the following. \n
86{img_str}
87
88\nFor more details on the training, please follow [this link](https://github.com/huggingface/diffusers/blob/main/examples/custom_diffusion).
89"""
90 model_card = load_or_create_model_card(
91 repo_id_or_path=repo_id,
92 from_training=True,
93 license="creativeml-openrail-m",
94 base_model=base_model,
95 prompt=prompt,
96 model_description=model_description,
97 inference=True,
98 )
99
100 tags = [
101 "text-to-image",
102 "diffusers",
103 "stable-diffusion",
104 "stable-diffusion-diffusers",
105 "custom-diffusion",
106 "diffusers-training",
107 ]
108 model_card = populate_model_card(model_card, tags=tags)
109
110 model_card.save(os.path.join(repo_folder, "README.md"))
111
112
113def import_model_class_from_model_name_or_path(pretrained_model_name_or_path: str, revision: str):

Callers 1

mainFunction · 0.70

Calls 2

populate_model_cardFunction · 0.90

Tested by

no test coverage detected