feat: POC onnxruntime with mask R-CNN
Former-commit-id: e10c3a9f332145797979ce1ef556909a8f76c2f3 [formerly 625ae128a1fe6dbc0eec8da170fd0b5390128fe2] Former-commit-id: 5dd429a665b96f5a833ca7734815d771600241b3
This commit is contained in:
parent
562ef110af
commit
ca125bec0c
|
@ -1,112 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/home/laurent_fainsin/Documents/unet/.venv/lib/python3.8/site-packages/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
|
||||
" from .autonotebook import tqdm as notebook_tqdm\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import torch\n",
|
||||
"from unet.model import UNet\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"net = UNet(\n",
|
||||
" n_channels=3,\n",
|
||||
" n_classes=1,\n",
|
||||
" features=[8, 16, 32, 64],\n",
|
||||
")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"<All keys matched successfully>"
|
||||
]
|
||||
},
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"net.load_state_dict(\n",
|
||||
" torch.load(\"../../checkpoints/best.pth\", map_location=torch.device('cpu'))\n",
|
||||
")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"dummy_input = torch.randn(1, 3, 512, 512, requires_grad=True)\n",
|
||||
"torch.onnx.export(\n",
|
||||
" net,\n",
|
||||
" dummy_input,\n",
|
||||
" \"../../checkpoints/best-fixed.onnx\",\n",
|
||||
" opset_version=10,\n",
|
||||
" # input_names=[\"input\"],\n",
|
||||
" # output_names=[\"output\"],\n",
|
||||
" # dynamic_axes={\n",
|
||||
" # \"input\": {\n",
|
||||
" # 2: \"height\",\n",
|
||||
" # 3: \"width\",\n",
|
||||
" # },\n",
|
||||
" # \"output\": {\n",
|
||||
" # 2: \"height\",\n",
|
||||
" # 3: \"width\",\n",
|
||||
" # },\n",
|
||||
" # },\n",
|
||||
")\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3.8.0 ('.venv': poetry)",
|
||||
"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.8.0"
|
||||
},
|
||||
"orig_nbformat": 4,
|
||||
"vscode": {
|
||||
"interpreter": {
|
||||
"hash": "dc80d2c03865715c8671359a6bf138f6c8ae4e26ae025f2543e0980b8db0ed7e"
|
||||
}
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
1
src/notebooks/convert.ipynb.REMOVED.git-id
Normal file
1
src/notebooks/convert.ipynb.REMOVED.git-id
Normal file
|
@ -0,0 +1 @@
|
|||
dbe91cbc0788d93595dac272825aa57412f04d70
|
|
@ -1 +1 @@
|
|||
3abcdffb1cbc384de89a39b26f5f57b7472df478
|
||||
df787682f8ee4387834b713d1d48437b94d45f61
|
Loading…
Reference in a new issue