diff --git a/.gitignore b/.gitignore index 79a271c..168e62f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,16 @@ +# tmp files */__pycache__/ -gym/ -*ppt -*pptx +build/ +dist/ +*.spec + +# onnx files *.onnx /test_onnx/ -/modified_onnx/ \ No newline at end of file +/modified_onnx/ + +# self maintained files +gym/ +*ppt +*pptx diff --git a/__pycache__/onnx_modifier.cpython-38.pyc b/__pycache__/onnx_modifier.cpython-38.pyc index 04fc9e0..3e2d804 100644 Binary files a/__pycache__/onnx_modifier.cpython-38.pyc and b/__pycache__/onnx_modifier.cpython-38.pyc differ diff --git a/app_desktop.py b/app_desktop.py index 5298e2c..a24c6de 100644 --- a/app_desktop.py +++ b/app_desktop.py @@ -1,4 +1,33 @@ +import sys +sys.path.append("../../") + from flaskwebgui import FlaskUI from app import app -FlaskUI(app, width=1200, height=800).run() \ No newline at end of file +FlaskUI(app, maximized=True, idle_interval=1).run() + +''' +This script is used for generating excutable files. +The following are some notes about How I worked for it. + +1. How to make flaskwebgui work as expected: + a. install flaskwebgui: `pip install flaskwebgui` + - flaskwebgui github repo: https://github.com/ClimenteA/flaskwebgui + b. add some scripts to keep server running while gui is running + - see here: https://github.com/ClimenteA/flaskwebgui#install + - I added the code in the index.js + c. Then run: `python app_desktop.py`, the web browser will be automatically lauched for onnx-modifier + +2. How to generate excutable files: + a. For Windows: + - Run `pyinstaller -F -n onnx-modifier -i ./static/favicon.png --add-data "templates;templates" --add-data "static;static" app_desktop.py` + - see here: https://stackoverflow.com/a/48976223/10096987 + - Then we can find the our target `.exe` file in the ./dist folder. + - The icon will not show until we change it in another directory due to Windows Explorer caching. + - see here: https://stackoverflow.com/a/35783199/10096987 + + b. For Ubuntu (not done): + - Run `pyinstaller -F -n onnx-modifier -i ./static/favicon.png --add-data "templates:templates" --add-data "static:static" app_desktop.py` + - However, I get a file with size of 400+MB + +''' \ No newline at end of file diff --git a/readme.md b/readme.md index e5fa41e..2991db5 100644 --- a/readme.md +++ b/readme.md @@ -2,6 +2,8 @@ English | [简体中文](readme_zh-CN.md) +> In this branch + # Introduction To edit an ONNX model, One common way is to visualize the model graph, and edit it using ONNX Python API. This works fine. However, we have to code to edit, then visualize to check. The two processes may iterate for many times, which is time-consuming. 👋 @@ -27,6 +29,9 @@ Hope it helps! # Getting started +We have two methods to launch `onnx-modifier` now. + +## launch from command line Clone the repo and install the required Python packages by ```bash @@ -45,6 +50,13 @@ 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 +- Windows: Download [onnx-modifier.exe](https://drive.google.com/file/d/1y7mYlvF0G5iiNDgOFh1ESXlTs8I2ipVQ/view?usp=sharing), double-click it and enjoy. + - Egde browser is used for viewing 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. + + Click `Open Model...` to upload the ONNX model to edit. The model will be parsed and shown on the page. # Usage @@ -145,7 +157,7 @@ For quick testing, some typical sample models are provided as following. Most of - [ ] Create executable file for easier launching for the following platforms: - [ ] Linux - - [ ] Windows + - [x] Windows - [ ] Add `merge models` feature # Credits and referred materials @@ -157,3 +169,4 @@ For quick testing, some typical sample models are provided as following. Most of - ONNX IO Stream [Leimao's Blog](https://leimao.github.io/blog/ONNX-IO-Stream/) - [onnx-utils](https://github.com/saurabh-shandilya/onnx-utils) - [sweetalert](https://github.com/t4t5/sweetalert) +- [flaskwebgui](https://github.com/ClimenteA/flaskwebgui) \ No newline at end of file diff --git a/static/favicon.png b/static/favicon.png new file mode 100644 index 0000000..39ace44 Binary files /dev/null and b/static/favicon.png differ diff --git a/static/index.js b/static/index.js index 4d8a16d..29ed2e0 100644 --- a/static/index.js +++ b/static/index.js @@ -372,11 +372,13 @@ host.BrowserHost = class { let url = this.document.location let route = "/flaskwebgui-keep-server-alive" - let interval_request = 3 * 1000 //sec + // let interval_request = 3 * 1000 //sec + let interval_request = 0.5 * 1000 //sec function keep_alive_server(){ getRequest(url + route) - .then(data => console.log(data)) + .then(data => {}) + // .then(data => console.log(data)) } setInterval(keep_alive_server, interval_request)