MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / _add_model_card_metadata

Function _add_model_card_metadata

monai/bundle/scripts.py:1837–1858  ·  view source on GitHub ↗
(new_modelcard_path)

Source from the content-addressed store, hash-verified

1835
1836
1837def _add_model_card_metadata(new_modelcard_path):
1838 # Extract license from LICENSE file
1839 license_name = "unknown"
1840 license_path = os.path.join(os.path.dirname(new_modelcard_path), "LICENSE")
1841 if os.path.exists(license_path):
1842 with open(license_path) as file:
1843 content = file.read()
1844 if "Apache License" in content and "Version 2.0" in content:
1845 license_name = "apache-2.0"
1846 elif "MIT License" in content:
1847 license_name = "mit"
1848 # Add relevant tags
1849 tags = "- monai\n- medical\nlibrary_name: monai\n"
1850 # Create tag section
1851 tag_content = f"---\ntags:\n{tags}license: {license_name}\n---"
1852
1853 # Update model card
1854 with open(new_modelcard_path) as file:
1855 content = file.read()
1856 new_content = tag_content + "\n" + content
1857 with open(new_modelcard_path, "w") as file:
1858 file.write(new_content)
1859
1860
1861def push_to_hf_hub(

Callers 1

push_to_hf_hubFunction · 0.85

Calls 2

readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…