Lutz Roeder 8 лет назад
Родитель
Сommit
e1573deeb0
2 измененных файлов с 26 добавлено и 6 удалено
  1. 3 3
      DEVELOPMENT.md
  2. 23 3
      src/tf-model.js

+ 3 - 3
DEVELOPMENT.md

@@ -4,16 +4,16 @@ Netron can run as both an [Electron](https://electronjs.org) app or a Python web
 
 
 ## Develop the Electron app
 ## Develop the Electron app
 
 
-The start the Electron app, install [Node.js](https://nodejs.org) and run: 
+To start the Electron app, install [Node.js](https://nodejs.org) and run: 
 
 
 ```bash
 ```bash
 npm install
 npm install
 npx electron .
 npx electron .
 ```
 ```
 
 
-To debug the Electron app use [Visual Studio Code](https://code.visualstudio.com) and install the [Debugger for Chrome](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome) extension, open the `./Netron` root folder and press `F5`. To attach the debugger to a rendering window select the `Debug` tab and `Debug Renderer Process` before launching.
+To debug the Electron app use [Visual Studio Code](https://code.visualstudio.com) and install the [Debugger for Chrome](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome) extension. Open the `./Netron` root folder and press `F5`. To attach the debugger to a rendering window select the `Debug` tab and `Debug Renderer Process` before launching.
 
 
-To build full Electron app binaries to the `./build/electron` folder run:
+To build Electron release binaries to the `./build/electron` folder run:
 
 
 ```bash
 ```bash
 npx electron-builder --mac --linux --win
 npx electron-builder --mac --linux --win

+ 23 - 3
src/tf-model.js

@@ -123,6 +123,7 @@ class TensorFlowGraph {
 
 
     get groups() {
     get groups() {
         return false;
         return false;
+        // TODO return true;
     }
     }
 
 
     get inputs() {
     get inputs() {
@@ -158,12 +159,25 @@ class TensorFlowGraph {
         return this._metadata;
         return this._metadata;
     }
     }
 
 
+    get namespaces() {
+        return this._namespaces;
+    }
+
     update() {
     update() {
         if (!this._nodeMap) {
         if (!this._nodeMap) {
             this._nodeMap = {};
             this._nodeMap = {};
+            this._namespaces = {};
             var nodes = this._graph.graphDef.node;
             var nodes = this._graph.graphDef.node;
             nodes.forEach((node) => {
             nodes.forEach((node) => {
-                this._nodeMap[node.name] = node;   
+                var name = node.name;
+                this._nodeMap[name] = node;   
+                if (node.op != 'Const') {
+                    var lastIndex = name.lastIndexOf('/');
+                    if (lastIndex != -1) {
+                        var namespace = name.substring(0, lastIndex);
+                        this._namespaces[namespace] = true;
+                    }
+                }
                 node.output = [];         
                 node.output = [];         
             });
             });
             nodes.forEach((node) => {
             nodes.forEach((node) => {
@@ -312,11 +326,17 @@ class TensorFlowNode {
 
 
     get group() {
     get group() {
         var name = this._node.name;
         var name = this._node.name;
+        if (this._graph.namespaces[name]) {
+            return name;
+        }
         var lastIndex = name.lastIndexOf('/');
         var lastIndex = name.lastIndexOf('/');
         if (lastIndex != -1) {
         if (lastIndex != -1) {
-            return name.substring(0, lastIndex);
+            var namespace = name.substring(0, lastIndex);
+            if (this._graph.namespaces[namespace]) {
+                return namespace;
+            }
         }
         }
-        return null;
+        return '';
     }
     }
 
 
     get description() {
     get description() {