MCPcopy
hub / github.com/huggingface/diffusers / load_or_create_model_card

Function load_or_create_model_card

src/diffusers/utils/hub_utils.py:98–185  ·  view source on GitHub ↗

Loads or creates a model card. Args: repo_id_or_path (`str`): The repo id (e.g., "stable-diffusion-v1-5/stable-diffusion-v1-5") or local path where to look for the model card. token (`str`, *optional*): Authentication token. Will default

(
    repo_id_or_path: str = None,
    token: str | None = None,
    is_pipeline: bool = False,
    from_training: bool = False,
    model_description: str | None = None,
    base_model: str = None,
    prompt: str | None = None,
    license: str | None = None,
    widget: list[dict] | None = None,
    inference: bool | None = None,
    is_modular: bool = False,
    update_model_card: bool = False,
)

Source from the content-addressed store, hash-verified

96
97
98def load_or_create_model_card(
99 repo_id_or_path: str = None,
100 token: str | None = None,
101 is_pipeline: bool = False,
102 from_training: bool = False,
103 model_description: str | None = None,
104 base_model: str = None,
105 prompt: str | None = None,
106 license: str | None = None,
107 widget: list[dict] | None = None,
108 inference: bool | None = None,
109 is_modular: bool = False,
110 update_model_card: bool = False,
111) -> ModelCard:
112 """
113 Loads or creates a model card.
114
115 Args:
116 repo_id_or_path (`str`):
117 The repo id (e.g., "stable-diffusion-v1-5/stable-diffusion-v1-5") or local path where to look for the model
118 card.
119 token (`str`, *optional*):
120 Authentication token. Will default to the stored token. See https://huggingface.co/settings/token for more
121 details.
122 is_pipeline (`bool`):
123 Boolean to indicate if we're adding tag to a [`DiffusionPipeline`].
124 from_training: (`bool`): Boolean flag to denote if the model card is being created from a training script.
125 model_description (`str`, *optional*): Model description to add to the model card. Helpful when using
126 `load_or_create_model_card` from a training script.
127 base_model (`str`): Base model identifier (e.g., "stabilityai/stable-diffusion-xl-base-1.0"). Useful
128 for DreamBooth-like training.
129 prompt (`str`, *optional*): Prompt used for training. Useful for DreamBooth-like training.
130 license: (`str`, *optional*): License of the output artifact. Helpful when using
131 `load_or_create_model_card` from a training script.
132 widget (`list[dict]`, *optional*): Widget to accompany a gallery template.
133 inference: (`bool`, optional): Whether to turn on inference widget. Helpful when using
134 `load_or_create_model_card` from a training script.
135 is_modular: (`bool`, optional): Boolean flag to denote if the model card is for a modular pipeline.
136 When True, uses model_description as-is without additional template formatting.
137 update_model_card: (`bool`, optional): When True, regenerates the model card content even if one
138 already exists on the remote repo. Existing card metadata (tags, license, etc.) is preserved. Only
139 supported for modular pipelines (i.e., `is_modular=True`).
140 """
141 if not is_jinja_available():
142 raise ValueError(
143 "Modelcard rendering is based on Jinja templates."
144 " Please make sure to have `jinja` installed before using `load_or_create_model_card`."
145 " To install it, please run `pip install Jinja2`."
146 )
147
148 if update_model_card and not is_modular:
149 raise ValueError("`update_model_card=True` is only supported for modular pipelines (`is_modular=True`).")
150
151 try:
152 # Check if the model card is present on the remote repo
153 model_card = ModelCard.load(repo_id_or_path, token=token)
154 # For modular pipelines, regenerate card content when requested (preserve existing metadata)
155 if update_model_card and is_modular and model_description is not None:

Callers 15

save_model_cardFunction · 0.90
save_model_cardFunction · 0.90
save_model_cardFunction · 0.90
save_model_cardFunction · 0.90
save_model_cardFunction · 0.90
save_model_cardFunction · 0.90
save_model_cardFunction · 0.90
save_model_cardFunction · 0.90
save_model_cardFunction · 0.90
save_model_cardFunction · 0.90
save_model_cardFunction · 0.90

Calls 1

loadMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…