Browse Source

Add DLC test file (#640)

Lutz Roeder 5 years ago
parent
commit
f02d88c6f1
3 changed files with 40 additions and 0 deletions
  1. 32 0
      source/dlc.js
  2. 1 0
      source/view.js
  3. 7 0
      test/models.json

+ 32 - 0
source/dlc.js

@@ -0,0 +1,32 @@
+/* jshint esversion: 6 */
+
+var dlc = dlc || {};
+
+dlc.ModelFactory = class {
+
+    match(context) {
+        const entries = context.entries('zip');
+        if (entries.find((entry) => entry.name === 'model')) {
+            return true;
+        }
+        return false;
+    }
+
+    open(context, host) {
+        return Promise.resolve().then(() => {
+            throw new dlc.Error("File contains undocumented DLC data.");
+        });
+    }
+};
+
+dlc.Error = class extends Error {
+
+    constructor(message) {
+        super(message);
+        this.name = 'Error loading DLC model.';
+    }
+};
+
+if (typeof module !== 'undefined' && typeof module.exports === 'object') {
+    module.exports.ModelFactory = dlc.ModelFactory;
+}

+ 1 - 0
source/view.js

@@ -1199,6 +1199,7 @@ view.ModelFactoryService = class {
         this.register('./darknet', [ '.cfg', '.model', '.txt' ]);
         this.register('./weka', [ '.model' ]);
         this.register('./rknn', [ '.rknn' ]);
+        this.register('./dlc', [ '.dlc' ]);
         this.register('./keras', [ '.h5', '.hd5', '.hdf5', '.keras', '.json', '.cfg', '.model', '.pb', '.pth' ]);
         this.register('./armnn', [ '.armnn', '.json' ]);
         this.register('./mnn', ['.mnn']);

+ 7 - 0
test/models.json

@@ -1995,6 +1995,13 @@
     "format": "Deeplearning4j",
     "link":   "https://github.com/eclipse/deeplearning4j"
   },
+  {
+    "type":   "dlc",
+    "target": "inception_v3_quantized.dlc",
+    "source": "https://github.com/lutzroeder/netron/files/5615377/inception_v3_quantized.dlc.zip[inception_v3_quantized.dlc]",
+    "error":  "File contains undocumented DLC data in 'inception_v3_quantized.dlc'.",
+    "link":   "https://github.com/lutzroeder/netron/issues/640"
+  },
   {
     "type":   "dnn",
     "target": "brows_model.dnn",