-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Ultralytics YOLO models and TIMM models (#2)
* add yolo * add timm and ultralytics * add yolov11 * add yolov10 * update * move model list into its own module * update req to pass test * add limit to list models * streamline all transformers models * update * update
- Loading branch information
Showing
18 changed files
with
1,972 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
# pytorch related | ||
*.pt | ||
*.pth | ||
|
||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-style: italic\"> Available Models </span>\n", | ||
"┏━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓\n", | ||
"┃<span style=\"font-weight: bold\"> Backend </span>┃<span style=\"font-weight: bold\"> Model ID </span>┃<span style=\"font-weight: bold\"> Input --> Output </span>┃\n", | ||
"┡━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩\n", | ||
"│<span style=\"color: #008080; text-decoration-color: #008080\"> timm </span>│<span style=\"color: #800080; text-decoration-color: #800080\"> vit_huge_patch14_clip_336.laion2b_ft_in12k_in1k </span>│<span style=\"color: #008000; text-decoration-color: #008000\"> image --> class </span>│\n", | ||
"│<span style=\"color: #008080; text-decoration-color: #008080\"> timm </span>│<span style=\"color: #800080; text-decoration-color: #800080\"> maxvit_xlarge_tf_512.in21k_ft_in1k </span>│<span style=\"color: #008000; text-decoration-color: #008000\"> image --> class </span>│\n", | ||
"│<span style=\"color: #008080; text-decoration-color: #008080\"> timm </span>│<span style=\"color: #800080; text-decoration-color: #800080\"> maxvit_xlarge_tf_384.in21k_ft_in1k </span>│<span style=\"color: #008000; text-decoration-color: #008000\"> image --> class </span>│\n", | ||
"│<span style=\"color: #008080; text-decoration-color: #008080\"> ... </span>│<span style=\"color: #800080; text-decoration-color: #800080\"> ... </span>│<span style=\"color: #008000; text-decoration-color: #008000\"> ... </span>│\n", | ||
"│<span style=\"color: #008080; text-decoration-color: #008080\"> ... </span>│<span style=\"color: #800080; text-decoration-color: #800080\"> ... </span>│<span style=\"color: #008000; text-decoration-color: #008000\"> ... </span>│\n", | ||
"└─────────┴─────────────────────────────────────────────────┴──────────────────┘\n", | ||
"</pre>\n" | ||
], | ||
"text/plain": [ | ||
"\u001b[3m Available Models \u001b[0m\n", | ||
"┏━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓\n", | ||
"┃\u001b[1m \u001b[0m\u001b[1mBackend\u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mModel ID \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mInput --> Output\u001b[0m\u001b[1m \u001b[0m┃\n", | ||
"┡━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩\n", | ||
"│\u001b[36m \u001b[0m\u001b[36mtimm \u001b[0m\u001b[36m \u001b[0m│\u001b[35m \u001b[0m\u001b[35mvit_huge_patch14_clip_336.laion2b_ft_in12k_in1k\u001b[0m\u001b[35m \u001b[0m│\u001b[32m \u001b[0m\u001b[32mimage --> class \u001b[0m\u001b[32m \u001b[0m│\n", | ||
"│\u001b[36m \u001b[0m\u001b[36mtimm \u001b[0m\u001b[36m \u001b[0m│\u001b[35m \u001b[0m\u001b[35mmaxvit_xlarge_tf_512.in21k_ft_in1k \u001b[0m\u001b[35m \u001b[0m│\u001b[32m \u001b[0m\u001b[32mimage --> class \u001b[0m\u001b[32m \u001b[0m│\n", | ||
"│\u001b[36m \u001b[0m\u001b[36mtimm \u001b[0m\u001b[36m \u001b[0m│\u001b[35m \u001b[0m\u001b[35mmaxvit_xlarge_tf_384.in21k_ft_in1k \u001b[0m\u001b[35m \u001b[0m│\u001b[32m \u001b[0m\u001b[32mimage --> class \u001b[0m\u001b[32m \u001b[0m│\n", | ||
"│\u001b[36m \u001b[0m\u001b[36m... \u001b[0m\u001b[36m \u001b[0m│\u001b[35m \u001b[0m\u001b[35m... \u001b[0m\u001b[35m \u001b[0m│\u001b[32m \u001b[0m\u001b[32m... \u001b[0m\u001b[32m \u001b[0m│\n", | ||
"│\u001b[36m \u001b[0m\u001b[36m... \u001b[0m\u001b[36m \u001b[0m│\u001b[35m \u001b[0m\u001b[35m... \u001b[0m\u001b[35m \u001b[0m│\u001b[32m \u001b[0m\u001b[32m... \u001b[0m\u001b[32m \u001b[0m│\n", | ||
"└─────────┴─────────────────────────────────────────────────┴──────────────────┘\n" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"import xinfer\n", | ||
"\n", | ||
"xinfer.list_models(\"vit\", limit=3)\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"\u001b[32m2024-10-11 23:43:39.344\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36mxinfer.timm.timm_model\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m17\u001b[0m - \u001b[1mLoading model: mobilenetv2_050.lamb_in1k\u001b[0m\n", | ||
"\u001b[32m2024-10-11 23:43:39.345\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36mxinfer.timm.timm_model\u001b[0m:\u001b[36mload_model\u001b[0m:\u001b[36m21\u001b[0m - \u001b[1mLoading model: mobilenetv2_050.lamb_in1k\u001b[0m\n" | ||
] | ||
}, | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "128884c6909b4ebb9a4f3881fdaff671", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"model.safetensors: 0%| | 0.00/7.98M [00:00<?, ?B/s]" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"\u001b[32m2024-10-11 23:43:40.408\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36mxinfer.timm.timm_model\u001b[0m:\u001b[36minference\u001b[0m:\u001b[36m27\u001b[0m - \u001b[1mRunning inference on https://ultralytics.com/images/bus.jpg\u001b[0m\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"model = xinfer.create_model(\"mobilenetv2_050.lamb_in1k\", \"timm\")\n", | ||
"\n", | ||
"result = model.inference(\"https://ultralytics.com/images/bus.jpg\", top_k=10)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"[{'class': 'minibus', 'id': 654, 'confidence': 62.94279098510742},\n", | ||
" {'class': 'police van, police wagon, paddy wagon, patrol wagon, wagon, black Maria',\n", | ||
" 'id': 734,\n", | ||
" 'confidence': 8.970001220703125},\n", | ||
" {'class': 'trolleybus, trolley coach, trackless trolley',\n", | ||
" 'id': 874,\n", | ||
" 'confidence': 4.9347052574157715},\n", | ||
" {'class': 'ambulance', 'id': 407, 'confidence': 2.7388036251068115},\n", | ||
" {'class': 'streetcar, tram, tramcar, trolley, trolley car',\n", | ||
" 'id': 829,\n", | ||
" 'confidence': 1.687123417854309},\n", | ||
" {'class': 'jinrikisha, ricksha, rickshaw',\n", | ||
" 'id': 612,\n", | ||
" 'confidence': 1.6692038774490356},\n", | ||
" {'class': 'passenger car, coach, carriage',\n", | ||
" 'id': 705,\n", | ||
" 'confidence': 1.348435401916504},\n", | ||
" {'class': 'recreational vehicle, RV, R.V.',\n", | ||
" 'id': 757,\n", | ||
" 'confidence': 1.2413547039031982},\n", | ||
" {'class': 'minivan', 'id': 656, 'confidence': 0.5516668558120728},\n", | ||
" {'class': 'amphibian, amphibious vehicle',\n", | ||
" 'id': 408,\n", | ||
" 'confidence': 0.4996110796928406}]" | ||
] | ||
}, | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"result" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "xinfer", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.15" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.