ZhangGe6 4 years ago
parent 787453dba3
commit 131362ce61

@ -3,7 +3,7 @@ ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get clean && apt-get update -y && apt-get upgrade -y && pip install --upgrade pip
RUN pip3 install -U onnx flask onnxruntime
RUN pip3 install -U onnx flask
COPY ./static /static
COPY ./templates /templates

@ -1,6 +1,5 @@
#!/usr/bin/env python3.8
from flask import Flask, render_template, request
from onnx_modifier import onnxModifier
app = Flask(__name__)

@ -1,13 +1,12 @@
# TODO
- support desktop application.
- support more flexible downloading schema
- As this [request](https://github.com/ZhangGe6/onnx-modifier/pull/5) notes, the current downloading schema prevents `onnx-modifier ` from being deployed remotely as a service.
- support adding more complicated nodes (which has some simple parameters).
- support combine models.
- support user-defined input/output number when the type of node's input/output is list.
- slim the codes.
- because some `.js` files (like electron.js and even python.js) in the `static` folder and `electron.html` in `templates` folder are legacy of Netron and can be further slimmed.

@ -7,7 +7,6 @@ import os
import copy
import numpy as np
import onnx
import onnxruntime as rt
from utils import make_new_node, make_attr_changed_node
class onnxModifier:
@ -159,7 +158,8 @@ class onnxModifier:
# onnx.checker.check_model(self.model_proto)
onnx.save(self.model_proto, save_path)
def inference(self, x=None, output_names=None):
def inference(self, x=None, output_names=None):
import onnxruntime as rt
if not x:
input_shape = [1, 3, 224, 224]
x = np.random.randn(*input_shape).astype(np.float32)

@ -28,7 +28,7 @@ Hope it helps!
# Getting started
We have two methods to launch `onnx-modifier` now.
We have three methods to launch `onnx-modifier` now.
## launch from command line
Clone the repo and install the required Python packages by
@ -37,7 +37,7 @@ Clone the repo and install the required Python packages by
git clone git@github.com:ZhangGe6/onnx-modifier.git
cd onnx-modifier
pip install onnx onnxruntime flask
pip install onnx flask
```
Then run
@ -49,15 +49,20 @@ python app.py
Click the url in the output info generated by flask (`http://127.0.0.1:5000/` for example), then `onnx-modifier` will be launched in the web browser.
## launch from executable file
<details>
<summary>Click to expand</summary>
- Windows: Download [onnx-modifier.exe (27.6MB)](https://drive.google.com/file/d/1y7mYlvF0G5iiNDgOFh1ESXlTs8I2ipVQ/view?usp=sharing), double-click it and enjoy.
- Edge browser is used for runtime environment by default.
> I recorded how I made the the executable file in `app_desktop.py`. The executable file for other platforms are left for future work.
</details>
Click `Open Model...` to upload the ONNX model to edit. The model will be parsed and shown on the page.
## launch from a docker container
<details>
<summary>Click to expand</summary>
We create a docker container like this:
@ -80,9 +85,14 @@ docker run -d -t \
```
Then we have access to onnx-modifer from URL <http://127.0.0.1:5000>. The modified ONNX models are expected to be found inside the local folder `modified_onnx`.
</details>
Click `Open Model...` to upload the ONNX model to edit. The model will be parsed and shown on the page.
# Usage
Graph-level-operation elements are placed on the left-top of the page. Currently, there are four buttons: `Refresh`, `Reset`, `Download` and `Add node`. They can do:
- `Refresh`: Refresh the model graph to preview editing effects.

Loading…
Cancel
Save