Merge pull request #5 from fengwang/master

Docker container for feature request at issue #4
1123
Zhang Ge 4 years ago committed by GitHub
commit 787453dba3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,15 @@
FROM python:3.8
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
COPY ./static /static
COPY ./templates /templates
COPY ./utils /utils
COPY ./*.py /
RUN chmod +x /app.py
CMD ["/bin/bash", "-c", "/app.py"]

@ -1,3 +1,6 @@
#!/usr/bin/env python3.8
from flask import Flask, render_template, request from flask import Flask, render_template, request
from onnx_modifier import onnxModifier from onnx_modifier import onnxModifier
app = Flask(__name__) app = Flask(__name__)
@ -30,4 +33,5 @@ def modify_and_download_model():
return 'OK', 200 return 'OK', 200
if __name__ == '__main__': if __name__ == '__main__':
app.run() app.debug = True
app.run(host="0.0.0.0")

@ -37,8 +37,7 @@ Clone the repo and install the required Python packages by
git clone git@github.com:ZhangGe6/onnx-modifier.git git clone git@github.com:ZhangGe6/onnx-modifier.git
cd onnx-modifier cd onnx-modifier
pip install onnx pip install onnx onnxruntime flask
pip install flask
``` ```
Then run Then run
@ -58,6 +57,31 @@ Click the url in the output info generated by flask (`http://127.0.0.1:5000/` fo
Click `Open Model...` to upload the ONNX model to edit. The model will be parsed and shown on the page. 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
We create a docker container like this:
```bash
git clone git@github.com:ZhangGe6/onnx-modifier.git
cd onnx-modifier
docker build --file Dockerfile . -t onnx-modifier
```
After building the container, we run onnx-modifier by mapping docker port and a local folder `modified_onnx`
```bash
mkdir -p modified_onnx
docker run -d -t \
--name onnx-modifier \
-u $(id -u ${USER}):$(id -g ${USER}) \
-v $(pwd)/modified_onnx:/modified_onnx \
-p 5000:5000 \
onnx-modifier
```
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`.
# Usage # 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: 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. - `Refresh`: Refresh the model graph to preview editing effects.

Loading…
Cancel
Save