Skip to content

Commit 54c8e06

Browse files
authored
add models to model_converter with hf card templates (#507)
* Add support for YOLO11 * save model_converter changes * precommit fixes * fix linter issues * yolo fixes * use revision for hf models * small improvements * template fix * license link * pyproj * lock
1 parent e765a76 commit 54c8e06

13 files changed

Lines changed: 2497 additions & 345 deletions

pyproject.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,21 @@ onnx = [
4141
ovms = [
4242
"tritonclient[http]<2.59",
4343
]
44+
tools = [
45+
"ultralytics",
46+
"torch",
47+
"torchvision",
48+
"transformers",
49+
"timm",
50+
"nncf",
51+
"huggingface-hub",
52+
]
4453
tests = [
4554
"httpx",
4655
"pytest",
4756
"pytest-cov",
4857
"pytest-mock",
58+
"defusedxml",
4959
"ultralytics>=8.0.114,<=8.0.205",
5060
"onnx",
5161
"onnxruntime",

tools/model_converter/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This tool reads a JSON configuration file containing model specifications, downl
2121

2222
```bash
2323
# Required packages
24-
uv pip install torch torchvision openvino
24+
uv sync --extra tools
2525

2626
```
2727

@@ -91,6 +91,8 @@ The configuration file is a JSON file with the following structure:
9191
"models": [
9292
{
9393
"model_short_name": "resnet50",
94+
"license": "bsd-3-clause",
95+
"license_link": "https://spdx.org/licenses/BSD-3-Clause.html",
9496
"model_class_name": "torchvision.models.resnet.resnet50",
9597
"model_full_name": "ResNet-50",
9698
"description": "ResNet-50 image classification model",
@@ -119,13 +121,21 @@ Common `model_type` values:
119121
#### Required Fields
120122

121123
- **`model_short_name`** (string): Short identifier for the model (used for output filename)
124+
- **`license`** (string): SPDX license identifier for the upstream model (for example `bsd-3-clause` or `apache-2.0`)
125+
- **`license_link`** (string): URL to the upstream license text used in generated README files
122126
- **`model_class_name`** (string): Full Python path to the model class (e.g., `torchvision.models.resnet.resnet50`)
123127
- **`weights_url`** (string): URL to download the PyTorch weights (.pth file)
124128

129+
For Hugging Face-backed models, use these required fields instead of `model_class_name` / `weights_url`:
130+
131+
- **`huggingface_repo`** (string): Hugging Face repository ID (for example `timm/mobilenetv2_100.ra_in1k`)
132+
- **`huggingface_revision`** (string): Immutable commit SHA to pin the download and model load to a specific repository state
133+
125134
#### Optional Fields
126135

127136
- **`model_full_name`** (string): Full descriptive name of the model
128137
- **`description`** (string): Description of the model
138+
- **`docs`** (string): Documentation URL for the model
129139
- **`input_shape`** (array of integers): Input tensor shape (default: `[1, 3, 224, 224]`)
130140
- **`input_names`** (array of strings): Names for input tensors (default: `["input"]`)
131141
- **`output_names`** (array of strings): Names for output tensors (default: auto-generated)

tools/model_converter/config.json

Lines changed: 498 additions & 16 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)