From ca125bec0c3a926181d1b9e703318931ec7eee6b Mon Sep 17 00:00:00 2001 From: Laurent Fainsin Date: Tue, 30 Aug 2022 13:23:17 +0200 Subject: [PATCH] feat: POC onnxruntime with mask R-CNN Former-commit-id: e10c3a9f332145797979ce1ef556909a8f76c2f3 [formerly 625ae128a1fe6dbc0eec8da170fd0b5390128fe2] Former-commit-id: 5dd429a665b96f5a833ca7734815d771600241b3 --- src/notebooks/convert.ipynb | 112 --------------------- src/notebooks/convert.ipynb.REMOVED.git-id | 1 + src/notebooks/predict.ipynb.REMOVED.git-id | 2 +- 3 files changed, 2 insertions(+), 113 deletions(-) delete mode 100644 src/notebooks/convert.ipynb create mode 100644 src/notebooks/convert.ipynb.REMOVED.git-id diff --git a/src/notebooks/convert.ipynb b/src/notebooks/convert.ipynb deleted file mode 100644 index d12409b..0000000 --- a/src/notebooks/convert.ipynb +++ /dev/null @@ -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": [ - "" - ] - }, - "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 -} diff --git a/src/notebooks/convert.ipynb.REMOVED.git-id b/src/notebooks/convert.ipynb.REMOVED.git-id new file mode 100644 index 0000000..fa5f3c7 --- /dev/null +++ b/src/notebooks/convert.ipynb.REMOVED.git-id @@ -0,0 +1 @@ +dbe91cbc0788d93595dac272825aa57412f04d70 \ No newline at end of file diff --git a/src/notebooks/predict.ipynb.REMOVED.git-id b/src/notebooks/predict.ipynb.REMOVED.git-id index 9012cc5..e2538a4 100644 --- a/src/notebooks/predict.ipynb.REMOVED.git-id +++ b/src/notebooks/predict.ipynb.REMOVED.git-id @@ -1 +1 @@ -3abcdffb1cbc384de89a39b26f5f57b7472df478 \ No newline at end of file +df787682f8ee4387834b713d1d48437b94d45f61 \ No newline at end of file