Kaynağa Gözat

Add scikit-learn test file

Lutz Roeder 5 yıl önce
ebeveyn
işleme
21263aa948
5 değiştirilmiş dosya ile 29 ekleme ve 45 silme
  1. 2 10
      source/gzip.js
  2. 2 1
      source/sklearn.js
  3. 1 1
      source/view.js
  4. 0 10
      source/zip.js
  5. 24 23
      test/models.json

+ 2 - 10
source/gzip.js

@@ -1,7 +1,7 @@
 /* jshint esversion: 6 */
-/* global pako */
 
 var gzip = gzip || {};
+var zip = zip || require('./zip');
 
 gzip.Archive = class {
 
@@ -147,15 +147,7 @@ gzip.InflaterStream = class {
     _inflate() {
         if (this._buffer === undefined) {
             const compressed = this._stream.peek();
-            if (typeof process === 'object' && typeof process.versions == 'object' && typeof process.versions.node !== 'undefined') {
-                this._buffer = require('zlib').inflateRawSync(compressed);
-            }
-            else if (typeof pako !== 'undefined') {
-                this._buffer = pako.inflateRaw(compressed);
-            }
-            else {
-                this._buffer = new require('./zip').Inflater().inflateRaw(compressed);
-            }
+            this._buffer = new zip.Inflater().inflateRaw(compressed);
             if (this._buffer.length !== this._length) {
                 throw new gzip.Error('Invalid size.');
             }

+ 2 - 1
source/sklearn.js

@@ -667,7 +667,8 @@ sklearn.Container = class {
 
     constructor(buffer, pickle, exception) {
         if (buffer.length > 0 && buffer[0] == 0x78) {
-            buffer = new zip.Inflater().inflate(buffer);
+            buffer = buffer.subarray(2, buffer.length - 2);
+            buffer = new zip.Inflater().inflateRaw(buffer);
         }
 
         const unpickler = new pickle.Unpickler(buffer);

+ 1 - 1
source/view.js

@@ -1193,7 +1193,7 @@ view.ModelFactoryService = class {
         this.register('./tf', [ '.pb', '.meta', '.pbtxt', '.prototxt', '.pt', '.json', '.index', '.ckpt', '.graphdef', /.data-[0-9][0-9][0-9][0-9][0-9]-of-[0-9][0-9][0-9][0-9][0-9]$/, /^events.out.tfevents./ ]);
         this.register('./mediapipe', [ '.pbtxt' ]);
         this.register('./uff', [ '.uff', '.pb', '.pbtxt', '.uff.txt', '.trt', '.engine' ]);
-        this.register('./sklearn', [ '.pkl', '.pickle', '.joblib', '.model', '.meta', '.pb', '.pt', '.h5' ]);
+        this.register('./sklearn', [ '.pkl', '.pickle', '.joblib', '.model', '.meta', '.pb', '.pt', '.h5', '.pkl.z', '.joblib.z' ]);
         this.register('./cntk', [ '.model', '.cntk', '.cmf', '.dnn' ]);
         this.register('./paddle', [ '.paddle', '.pdmodel', '__model__', '.pbtxt', '.txt', '.tar', '.tar.gz' ]);
         this.register('./bigdl', [ '.model', '.bigdl' ]);

+ 0 - 10
source/zip.js

@@ -225,16 +225,6 @@ zip.HuffmanTree = class {
 
 zip.Inflater = class {
 
-    inflate(data) {
-        if (typeof process === 'object' && typeof process.versions == 'object' && typeof process.versions.node !== 'undefined') {
-            return require('zlib').inflateSync(data);
-        }
-        if (typeof pako !== 'undefined') {
-            return pako.inflate(data);
-        }
-        throw new zip.Error("zlib inflate not supported.");
-    }
-
     inflateRaw(data) {
 
         if (typeof process === 'object' && typeof process.versions == 'object' && typeof process.versions.node !== 'undefined') {

+ 24 - 23
test/models.json

@@ -1,89 +1,96 @@
 [
   {
-    "type":   "any",
+    "type":   "_",
     "target": "config.json",
     "source": "https://github.com/lutzroeder/netron/files/5398758/config.json.zip[config.json]",
     "error":  "Invalid file content. File contains keras-yolo2 configuation.",
     "link":   "https://github.com/lutzroeder/netron/issues/458"
   },
   {
-    "type":   "any",
+    "type":   "_",
     "target": "config.pbtxt",
     "source": "https://github.com/lutzroeder/netron/files/5398767/config.pbtxt.zip[config.pbtxt]",
     "error":  "Invalid file content. File contains Triton Inference Server configuration.",
     "link":   "https://github.com/NVIDIA/triton-inference-server"
   },
   {
-    "type":   "any",
+    "type":   "_",
     "target": "empty.zip",
     "source": "https://github.com/lutzroeder/netron/files/5581087/empty.zip",
     "error":  "Invalid file content. File contains Zip archive in 'empty.zip'.",
     "link":   "https://github.com/lutzroeder/netron/issues/458"
   },
   {
-    "type":   "any",
+    "type":   "_",
     "target": "imagenet_2012_challenge_label_map_proto.pbtxt",
     "source": "https://raw.githubusercontent.com/dmlc/web-data/master/tensorflow/models/InceptionV1/imagenet_2012_challenge_label_map_proto.pbtxt",
     "error":  "Invalid file content. File contains ImageNet LabelMap data."
   },
   {
-    "type":   "any",
+    "type":   "_",
     "target": "labelmap.pbtxt",
     "source": "https://github.com/lutzroeder/netron/files/5398649/labelmap.zip[labelmap.pbtxt]",
     "error":  "Invalid file content. File contains StringIntLabelMapProto data.",
     "link":   "https://github.com/lutzroeder/netron/issues/458"
   },
   {
-    "type":   "any",
+    "type":   "_",
     "target": "gzip_invalid_archive.tar.gz",
     "source": "https://github.com/lutzroeder/netron/files/5468427/gzip_invalid_archive.tar.gz",
     "error":  "Invalid gzip archive in 'gzip_invalid_archive.tar.gz'.",
     "link":   "https://github.com/lutzroeder/netron/issues/249"
   },
   {
-    "type":   "any",
+    "type":   "_",
     "target": "gzip_invalid_compression.tar.gz",
     "source": "https://github.com/lutzroeder/netron/files/3027193/gzip_invalid_compression.tar.gz",
     "error":  "Invalid compression method '1' in 'gzip_invalid_compression.tar.gz'.",
     "link":   "https://github.com/lutzroeder/netron/issues/249"
   },
   {
-    "type":   "any",
+    "type":   "_",
     "target": "invalid_git_lfs.mlmodel",
     "source": "https://github.com/lutzroeder/netron/files/4432767/invalid_git_lfs.mlmodel.zip[invalid_git_lfs.mlmodel]",
     "error":  "Invalid file content. File contains Git LFS header.",
     "link":   "https://github.com/lutzroeder/netron/issues/458"
   },
   {
-    "type":   "any",
+    "type":   "_",
     "target": "invalid_html.mlmodel.zip",
     "source": "https://github.com/lutzroeder/netron/files/4432768/invalid_html.mlmodel.zip",
     "error":  "Invalid file content. File contains HTML markup.",
     "link":   "https://github.com/lutzroeder/netron/issues/458"
   },
   {
-    "type":   "any",
+    "type":   "_",
     "target": "invalid_html.tflite",
     "source": "https://github.com/lutzroeder/netron/files/4432789/invalid_html.tflite.zip[invalid_html.tflite]",
     "error":  "Invalid file content. File contains HTML markup.",
     "link":   "https://github.com/lutzroeder/netron/issues/458"
   },
   {
-    "type":   "any",
+    "type":   "_",
+    "target": "ops.pbtxt",
+    "source": "https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/core/ops/ops.pbtxt",
+    "error":  "Invalid file content. File contains TensorFlow OpList data.",
+    "link":   "https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/ops/ops.pbtxt"
+  },
+  {
+    "type":   "_",
     "target": "vk_swiftshader_icd.json",
     "source": "https://github.com/lutzroeder/netron/files/5398770/vk_swiftshader_icd.json.zip[vk_swiftshader_icd.json]",
     "error":  "Invalid file content. File contains Vulkan SwiftShader ICD manifest.",
     "link":   "https://github.com/lutzroeder/netron/issues/458"
   },
   {
-    "type":   "any",
+    "type":   "_",
     "target": "yolo-1c.meta",
     "source": "https://github.com/lutzroeder/netron/files/5398632/yolo-1c.meta.zip[yolo-1c.meta]",
     "error":  "Invalid file content. File contains Darkflow metadata.",
     "link":   "https://github.com/lutzroeder/netron/issues/458"
   },
   {
-    "type":   "any",
+    "type":   "_",
     "target": "zip_invalid_archive.zip",
     "source": "https://github.com/lutzroeder/netron/files/5468425/zip_invalid_archive.zip",
     "error":  "Invalid Zip archive in 'zip_invalid_archive.zip'.",
@@ -895,13 +902,6 @@
     "format": "Caffe2",
     "link":   "https://github.com/lutzroeder/netron/issues/168"
   },
-  {
-    "type":   "caffe2",
-    "target": "ops/ops.pbtxt",
-    "source": "https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/core/ops/ops.pbtxt",
-    "error":  "Invalid file content. File contains TensorFlow OpList data.",
-    "link":   "https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/ops/ops.pbtxt"
-  },
   {
     "type":   "caffe2",
     "target": "resnet50/predict_net.pb,resnet50/init_net.pb",
@@ -4735,9 +4735,10 @@
   },
   {
     "type":   "sklearn",
-    "target": "d2v.model",
-    "source": "https://raw.githubusercontent.com/aseth99/doc2vec/master/d2v.model",
-    "format": "gensim"
+    "target": "iris_svc.joblib.z",
+    "source": "https://github.com/lutzroeder/netron/files/5728549/iris_svc.joblib.z.zip[iris_svc.joblib.z]",
+    "format": "scikit-learn v0.24.0rc1",
+    "link":   "https://github.com/lutzroeder/netron/issues/182"
   },
   {
     "type":   "sklearn",