(new_modelcard_path)
| 1835 | |
| 1836 | |
| 1837 | def _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 | |
| 1861 | def push_to_hf_hub( |
no test coverage detected
searching dependent graphs…