MCPcopy
hub / github.com/huggingface/transformers / __post_init__

Method __post_init__

src/transformers/modelcard.py:189–203  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

187 source: str | None = "trainer"
188
189 def __post_init__(self):
190 # Infer default license from the checkpoint used, if possible.
191 if (
192 self.license is None
193 and not is_offline_mode()
194 and self.finetuned_from is not None
195 and len(self.finetuned_from) > 0
196 ):
197 try:
198 info = hf_api().model_info(self.finetuned_from)
199 for tag in info.tags:
200 if tag.startswith("license:"):
201 self.license = tag[8:]
202 except (httpx.HTTPError, HFValidationError, OfflineModeIsEnabled):
203 pass
204
205 def create_model_index(self, metric_mapping):
206 model_index = {"name": self.model_name}

Callers

nothing calls this directly

Calls 1

hf_apiFunction · 0.85

Tested by

no test coverage detected