From 587a02b30a4c8e22700539007dee661d2a8073aa Mon Sep 17 00:00:00 2001 From: ZhangGe6 Date: Fri, 22 Apr 2022 22:26:21 +0800 Subject: [PATCH] flask version works! --- static/index.js | 5 ++--- static/view.js | 12 ++++++++++-- templates/index.html | 1 - 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/static/index.js b/static/index.js index 77a9206..97c37c5 100644 --- a/static/index.js +++ b/static/index.js @@ -284,7 +284,7 @@ host.BrowserHost = class { } require(id) { - const url = this._url(id + '.js'); + const url = this._url('../static/' + id + '.js'); this.window.__modules__ = this.window.__modules__ || {}; // console.log(this.window.__modules__) // console.log(url) // file:///C:/Users/ZhangGe/Desktop/netron/source/./onnx.js @@ -298,8 +298,7 @@ host.BrowserHost = class { const script = document.createElement('script'); script.setAttribute('id', id); script.setAttribute('type', 'text/javascript'); - // script.setAttribute('src', url); - script.setAttribute('src', "{{url_for('static', filename='onnx.js')}}"); + script.setAttribute('src', url); script.onload = (e) => { if (this.window.module && this.window.module.exports) { const exports = this.window.module.exports; diff --git a/static/view.js b/static/view.js index e143c06..105add2 100644 --- a/static/view.js +++ b/static/view.js @@ -13,6 +13,9 @@ var python = python || require('./python'); var sidebar = sidebar || require('./view-sidebar'); var grapher = grapher || require('./view-grapher'); +// var onnx = onnx || require('./onnx'); + + view.View = class { constructor(host, id) { @@ -419,8 +422,8 @@ view.View = class { } open(context) { - // console.log("view open()"); - // console.log(context); + console.log("view open()"); + console.log(context); this._host.event('Model', 'Open', 'Size', context.stream ? context.stream.length : 0); this._sidebar.close(); return this._timeout(2).then(() => { @@ -1862,15 +1865,20 @@ view.ModelFactoryService = class { } _openContext(context) { + console.log(context) const modules = this._filter(context).filter((module) => module && module.length > 0); // console.log(modules) // ['./onnx', './tensorrt', './rknn', './om'] const errors = []; let success = false; + + // TODO: to simplify the logic here since this tool is used for only onnx const nextModule = () => { if (modules.length > 0) { const id = modules.shift(); + // console.log(id) return this._host.require(id).then((module) => { + console.log(module) const updateErrorContext = (error, context) => { const content = " in '" + context.identifier + "'."; if (error && typeof error.message === 'string' && !error.message.endsWith(content) && (error.context === undefined || error.context === true)) { diff --git a/templates/index.html b/templates/index.html index 0ca9bb5..6e8cbff 100644 --- a/templates/index.html +++ b/templates/index.html @@ -28,7 +28,6 @@ -