flask version works!

1123
ZhangGe6 4 years ago
parent 09f23c7152
commit 587a02b30a

@ -284,7 +284,7 @@ host.BrowserHost = class {
} }
require(id) { require(id) {
const url = this._url(id + '.js'); const url = this._url('../static/' + id + '.js');
this.window.__modules__ = this.window.__modules__ || {}; this.window.__modules__ = this.window.__modules__ || {};
// console.log(this.window.__modules__) // console.log(this.window.__modules__)
// console.log(url) // file:///C:/Users/ZhangGe/Desktop/netron/source/./onnx.js // console.log(url) // file:///C:/Users/ZhangGe/Desktop/netron/source/./onnx.js
@ -298,8 +298,7 @@ host.BrowserHost = class {
const script = document.createElement('script'); const script = document.createElement('script');
script.setAttribute('id', id); script.setAttribute('id', id);
script.setAttribute('type', 'text/javascript'); script.setAttribute('type', 'text/javascript');
// script.setAttribute('src', url); script.setAttribute('src', url);
script.setAttribute('src', "{{url_for('static', filename='onnx.js')}}");
script.onload = (e) => { script.onload = (e) => {
if (this.window.module && this.window.module.exports) { if (this.window.module && this.window.module.exports) {
const exports = this.window.module.exports; const exports = this.window.module.exports;

@ -13,6 +13,9 @@ var python = python || require('./python');
var sidebar = sidebar || require('./view-sidebar'); var sidebar = sidebar || require('./view-sidebar');
var grapher = grapher || require('./view-grapher'); var grapher = grapher || require('./view-grapher');
// var onnx = onnx || require('./onnx');
view.View = class { view.View = class {
constructor(host, id) { constructor(host, id) {
@ -419,8 +422,8 @@ view.View = class {
} }
open(context) { open(context) {
// console.log("view open()"); console.log("view open()");
// console.log(context); console.log(context);
this._host.event('Model', 'Open', 'Size', context.stream ? context.stream.length : 0); this._host.event('Model', 'Open', 'Size', context.stream ? context.stream.length : 0);
this._sidebar.close(); this._sidebar.close();
return this._timeout(2).then(() => { return this._timeout(2).then(() => {
@ -1862,15 +1865,20 @@ view.ModelFactoryService = class {
} }
_openContext(context) { _openContext(context) {
console.log(context)
const modules = this._filter(context).filter((module) => module && module.length > 0); const modules = this._filter(context).filter((module) => module && module.length > 0);
// console.log(modules) // ['./onnx', './tensorrt', './rknn', './om'] // console.log(modules) // ['./onnx', './tensorrt', './rknn', './om']
const errors = []; const errors = [];
let success = false; let success = false;
// TODO: to simplify the logic here since this tool is used for only onnx
const nextModule = () => { const nextModule = () => {
if (modules.length > 0) { if (modules.length > 0) {
const id = modules.shift(); const id = modules.shift();
// console.log(id)
return this._host.require(id).then((module) => { return this._host.require(id).then((module) => {
console.log(module)
const updateErrorContext = (error, context) => { const updateErrorContext = (error, context) => {
const content = " in '" + context.identifier + "'."; const content = " in '" + context.identifier + "'.";
if (error && typeof error.message === 'string' && !error.message.endsWith(content) && (error.context === undefined || error.context === true)) { if (error && typeof error.message === 'string' && !error.message.endsWith(content) && (error.context === undefined || error.context === true)) {

@ -28,7 +28,6 @@
<script src="{{url_for('static', filename='view-sidebar.js')}}"></script> <script src="{{url_for('static', filename='view-sidebar.js')}}"></script>
<script src="{{url_for('static', filename='view.js')}}"></script> <script src="{{url_for('static', filename='view.js')}}"></script>
<script src="{{url_for('static', filename='index.js')}}"></script> <script src="{{url_for('static', filename='index.js')}}"></script>
<script src="{{url_for('static', filename='onnx.js')}}"></script>
<style> <style>
html { touch-action: none; overflow: hidden; width: 100%; height: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; text-rendering: optimizeLegibility; -webkit-text-rendering: optimizeLegibility; -moz-text-rendering: optimizeLegibility; -ms-text-rendering: optimizeLegibility; -o-text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; -moz-font-smoothing: antialiased; -ms-font-smoothing: antialiased; -o-font-smoothing: antialiased; } html { touch-action: none; overflow: hidden; width: 100%; height: 100%; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; text-rendering: optimizeLegibility; -webkit-text-rendering: optimizeLegibility; -moz-text-rendering: optimizeLegibility; -ms-text-rendering: optimizeLegibility; -o-text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; -moz-font-smoothing: antialiased; -ms-font-smoothing: antialiased; -o-font-smoothing: antialiased; }
body { touch-action: none; overflow: hidden; width: 100%; height: 100%; margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI", "Ubuntu", "Droid Sans", sans-serif, "PingFang SC"; font-size: 12px; text-rendering: geometricPrecision; } body { touch-action: none; overflow: hidden; width: 100%; height: 100%; margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI", "Ubuntu", "Droid Sans", sans-serif, "PingFang SC"; font-size: 12px; text-rendering: geometricPrecision; }

Loading…
Cancel
Save