|
import huggingface_hub |
|
from huggingface_hub import ModelCard |
|
|
|
|
|
|
|
|
|
def check_model_card(repo_id: str) -> tuple[bool, str]: |
|
|
|
try: |
|
card = ModelCard.load(repo_id) |
|
except huggingface_hub.utils.EntryNotFoundError: |
|
return False, "Please add a model card to your model to explain how you trained/fine-tuned it." |
|
|
|
|
|
if card.data.license is None: |
|
if not ("license_name" in card.data and "license_link" in card.data): |
|
return False, ( |
|
"License not found. Please add a license to your model card using the `license` metadata or a" |
|
" `license_name`/`license_link` pair." |
|
) |
|
|
|
|
|
if len(card.text) < 200: |
|
return False, "Please add a description to your model card, it is too short." |
|
|
|
return True, "" |
|
|