Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions model_converter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ The configuration file is a JSON file with the following structure:
{
"model_short_name": "resnet50",
"license": "bsd-3-clause",
"license_name": "bsd-3-clause",
"license_link": "https://spdx.org/licenses/BSD-3-Clause.html",
Comment thread
tybulewicz marked this conversation as resolved.
"model_class_name": "torchvision.models.resnet.resnet50",
"model_full_name": "ResNet-50",
Expand Down
106 changes: 53 additions & 53 deletions model_converter/presets/config.json

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions model_converter/src/model_converter/converters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,25 @@
from model_converter.metrics import CocoDetectionMAP, Metric


def _get_human_license_name(name: str) -> str:
mapping = {
"agpl-3.0": "AGPL-3.0-only",
"apache-2.0": "Apache-2.0",
"bsd-3-clause": "BSD-3-Clause",
}

return mapping.get(name, name)


def _get_model_docs_page_name(url: str) -> str:
url = url.lower()
if "github" in url:
return "repository"
if "huggingface" in url:
return "card"
return "documentation"
Comment thread
tybulewicz marked this conversation as resolved.


class BaseConverter(ABC):
"""Abstract base class for model converters.

Expand Down Expand Up @@ -337,8 +356,12 @@ def copy_readme(
model_short_name = str(model_config.get("model_short_name", "")).strip()
model_library = str(model_config.get("model_library", "timm")).strip()
model_license = str(model_config.get("license", "")).strip()
model_license_name = _get_human_license_name(model_license)
model_license_link = str(model_config.get("license_link", "")).strip()
docs = str(model_config.get("docs", "")).strip()
model_docs_page_name = str(
model_config.get("model_docs_page_name", _get_model_docs_page_name(url=docs)),
).strip()

def template_placeholder(name: str) -> str:
return f"<<{name}>>"
Expand Down Expand Up @@ -373,11 +396,13 @@ def template_placeholder(name: str) -> str:

placeholders = {
template_placeholder("license"): model_license,
template_placeholder("license_name"): model_license_name,
template_placeholder("license_link"): model_license_link,
template_placeholder("model_name"): model_short_name,
template_placeholder("model_short_name"): model_short_name,
template_placeholder("variant"): variant,
template_placeholder("docs"): docs,
template_placeholder("model_docs_page_name"): model_docs_page_name,
}

# Handle tags list → YAML formatting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ tags:

# <<model_short_name>>-fp16-ov

- Model creator: [Geti™](https://github.com/open-edge-platform/training_extensions)
- Model creator: [Geti™](https://github.com/open-edge-platform/geti)
- Original model: [<<model_full_name>>](<<docs>>)

## Description

This is a [Geti™](https://github.com/open-edge-platform/training_extensions) version of [<<model_full_name>>](<<docs>>) model converted to the [OpenVINO™ IR](https://docs.openvino.ai/2026/documentation/openvino-ir-format.html) (Intermediate Representation) format with weights compressed to FP16.
This is a [Geti™](https://github.com/open-edge-platform/geti) version of [<<model_full_name>>](<<docs>>) model converted to the [OpenVINO™ IR](https://docs.openvino.ai/2026/documentation/openvino-ir-format.html) (Intermediate Representation) format with weights compressed to FP16.

To fine-tune your model with a custom dataset, you can use Geti™ to annotate data, perform fine-tuning, and export the resulting model.

Expand Down Expand Up @@ -57,11 +57,11 @@ For more examples and possible optimizations, refer to the [Model API Documentat

## Limitations

Check the original [model documentation](<<docs>>) for limitations.
Check the [original model documentation](<<docs>>) for limitations.

## Legal information

The original model is distributed under the [<<license>>](<<license_link>>) license. More details can be found in [training_extensions](https://github.com/open-edge-platform/training_extensions).
The original model is distributed under the [<<license_name>>](<<license_link>>) license. More details can be found in the [original model <<model_docs_page_name>>](<<docs>>).

## Disclaimer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ tags:

# <<model_short_name>>-int8-ov

- Model creator: [Geti™](https://github.com/open-edge-platform/training_extensions)
- Model creator: [Geti™](https://github.com/open-edge-platform/geti)
- Original model: [<<model_full_name>>](<<docs>>)

## Description

This is a [Geti™](https://github.com/open-edge-platform/training_extensions) version of [<<model_full_name>>](<<docs>>) model converted to the [OpenVINO™ IR](https://docs.openvino.ai/2026/documentation/openvino-ir-format.html) (Intermediate Representation) format with weights compressed to INT8.
This is a [Geti™](https://github.com/open-edge-platform/geti) version of [<<model_full_name>>](<<docs>>) model converted to the [OpenVINO™ IR](https://docs.openvino.ai/2026/documentation/openvino-ir-format.html) (Intermediate Representation) format with weights compressed to INT8.

To fine-tune your model with a custom dataset, you can use Geti™ to annotate data, perform fine-tuning, and export the resulting model.

Expand Down Expand Up @@ -66,11 +66,11 @@ For more examples and possible optimizations, refer to the [Model API Documentat

## Limitations

Check the original [model documentation](<<docs>>) for limitations.
Check the [original model documentation](<<docs>>) for limitations.

## Legal information

The original model is distributed under the [<<license>>](<<license_link>>) license. More details can be found in [training_extensions](https://github.com/open-edge-platform/training_extensions).
The original model is distributed under the [<<license_name>>](<<license_link>>) license. More details can be found in the [original model <<model_docs_page_name>>](<<docs>>).

## Disclaimer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ For more examples and possible optimizations, refer to the [Model API Documentat

## Limitations

Check the original [model card](https://huggingface.co/<<huggingface_repo>>) for limitations.
Check the [original model card](https://huggingface.co/<<huggingface_repo>>) for limitations.

## Legal information

The original model is distributed under the [<<license>>](<<license_link>>) license. More details can be found in [<<huggingface_repo>>](https://huggingface.co/<<huggingface_repo>>)
The original model is distributed under the [<<license_name>>](<<license_link>>) license. More details can be found in [<<huggingface_repo>>](https://huggingface.co/<<huggingface_repo>>)
Comment thread
tybulewicz marked this conversation as resolved.

## Disclaimer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ For more examples and possible optimizations, refer to the [Model API Documentat

## Limitations

Check the original [model card](https://huggingface.co/<<huggingface_repo>>) for limitations.
Check the [original model card](https://huggingface.co/<<huggingface_repo>>) for limitations.

## Legal information

The original model is distributed under the [<<license>>](<<license_link>>) license. More details can be found in [<<huggingface_repo>>](https://huggingface.co/<<huggingface_repo>>)
The original model is distributed under the [<<license_name>>](<<license_link>>) license. More details can be found in [<<huggingface_repo>>](https://huggingface.co/<<huggingface_repo>>)
Comment thread
tybulewicz marked this conversation as resolved.

## Disclaimer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ For more examples and possible optimizations, refer to the [Model API Documentat

## Limitations

Check the original [model implementation](https://github.com/pytorch/vision) for limitations.
Check the [original model implementation](https://github.com/pytorch/vision) for limitations.

## Legal information

The original model is distributed under the [<<license>>](<<license_link>>) license. More details can be found in [https://github.com/pytorch/vision](https://github.com/pytorch/vision).
The original model is distributed under the [<<license_name>>](<<license_link>>) license. More details can be found in [https://github.com/pytorch/vision](https://github.com/pytorch/vision).
Comment thread
tybulewicz marked this conversation as resolved.

## Disclaimer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ For more examples and possible optimizations, refer to the [Model API Documentat

## Limitations

Check the original [model implementation](https://github.com/pytorch/vision) for limitations.
Check the [original model implementation](https://github.com/pytorch/vision) for limitations.

## Legal information

The original model is distributed under the [<<license>>](<<license_link>>) license. More details can be found in [https://github.com/pytorch/vision](https://github.com/pytorch/vision).
The original model is distributed under the [<<license_name>>](<<license_link>>) license. More details can be found in [https://github.com/pytorch/vision](https://github.com/pytorch/vision).
Comment thread
tybulewicz marked this conversation as resolved.

## Disclaimer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ For more examples and possible optimizations, refer to the [Model API Documentat

## Limitations

Check the original [model card](https://huggingface.co/Ultralytics/YOLO11) for limitations.
Check the [original model card](https://huggingface.co/Ultralytics/YOLO11) for limitations.

## Legal information

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ For more examples and possible optimizations, refer to the [Model API Documentat

## Limitations

Check the original [model card](https://huggingface.co/Ultralytics/YOLO11) for limitations.
Check the [original model card](https://huggingface.co/Ultralytics/YOLO11) for limitations.

## Legal information

Expand Down
90 changes: 88 additions & 2 deletions model_converter/tests/unit/test_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ def test_renders_placeholders_and_tags_yaml(self, converter, template_dir, tmp_p
(template_dir / "README-torchvision-fp16.md").write_text(
"# <<model_short_name>>\n"
"License: <<license>>\n"
"License name: <<license_name>>\n"
"License link: <<license_link>>\n"
"Docs: <<docs>>\n"
"Docs page name: <<model_docs_page_name>>\n"
"Variant: <<variant>>\n"
"Tags:\n"
"<<tags_yaml>>",
Expand All @@ -46,7 +48,7 @@ def test_renders_placeholders_and_tags_yaml(self, converter, template_dir, tmp_p
{
"model_short_name": "test_model",
"model_library": "torchvision",
"license": "Apache-2.0",
"license": "apache-2.0",
"license_link": "https://apache.org/licenses/LICENSE-2.0",
"docs": "https://docs.example.com",
"tags": ["vision", "classification"],
Expand All @@ -57,13 +59,97 @@ def test_renders_placeholders_and_tags_yaml(self, converter, template_dir, tmp_p

content = (output_folder / "README.md").read_text()
assert "# test_model" in content
assert "License: Apache-2.0" in content
assert "License: apache-2.0" in content
assert "License name: Apache-2.0" in content
assert "License link: https://apache.org/licenses/LICENSE-2.0" in content
assert "Docs: https://docs.example.com" in content
assert "Docs page name: documentation" in content
assert "Variant: fp16" in content
assert " - vision" in content
assert " - classification" in content

@pytest.mark.parametrize(
("license_id", "license_name"),
[
("apache-2.0", "Apache-2.0"),
("rAnDoM", "rAnDoM"),
("agpl-3.0", "AGPL-3.0-only"),
("bsd-3-clause", "BSD-3-Clause"),
],
)
def test_selects_correct_license_name(
self,
converter,
template_dir,
tmp_path,
monkeypatch,
license_id,
license_name,
):
"""copy_readme fills placeholders from config and renders tags as YAML."""
_set_template_root(monkeypatch, template_dir)
(template_dir / "README-torchvision-fp16.md").write_text(
"License: <<license>>\nLicense name: <<license_name>>\n",
)
output_folder = tmp_path / "test_model-fp16-ov"
output_folder.mkdir()

converter.copy_readme(
{
"model_short_name": "test_model",
"model_library": "torchvision",
"license": license_id,
"license_link": "https://apache.org/licenses/LICENSE-2.0",
"docs": "https://docs.example.com",
},
output_folder,
variant="fp16",
)

content = (output_folder / "README.md").read_text()
assert f"License: {license_id}" in content
assert f"License name: {license_name}" in content

@pytest.mark.parametrize(
("docs_url", "docs_page_name"),
[
("https://docs.example.com", "documentation"),
("https://huggingface.com/foo/bar", "card"),
("https://github.com/foo/bar", "repository"),
],
)
def test_selects_correct_docs_page_name(
self,
converter,
template_dir,
tmp_path,
monkeypatch,
docs_url,
docs_page_name,
):
"""copy_readme fills placeholders from config and renders tags as YAML."""
_set_template_root(monkeypatch, template_dir)
(template_dir / "README-torchvision-fp16.md").write_text(
"Docs page name: <<model_docs_page_name>>\n",
)
output_folder = tmp_path / "test_model-fp16-ov"
output_folder.mkdir()

converter.copy_readme(
{
"model_short_name": "test_model",
"model_library": "torchvision",
"license": "apache-2.0",
"license_link": "https://apache.org/licenses/LICENSE-2.0",
"docs": docs_url,
},
output_folder,
variant="fp16",
)

content = (output_folder / "README.md").read_text()
assert f"Docs page name: {docs_page_name}" in content

@pytest.mark.parametrize(
("config", "expected"),
[
Expand Down