Browse Source

Add Keras .hd5 detection (#293)

Lutz Roeder 6 năm trước cách đây
mục cha
commit
667264717a
5 tập tin đã thay đổi với 9 bổ sung4 xóa
  1. 4 0
      electron-builder.yml
  2. 1 1
      src/app.js
  3. 1 1
      src/index.html
  4. 2 1
      src/keras.js
  5. 1 1
      src/view.js

+ 4 - 0
electron-builder.yml

@@ -16,6 +16,10 @@ fileAssociations:
     ext: tfl
   - name: "Keras Model"
     ext: h5
+  - name: "Keras Model"
+    ext: hd5
+  - name: "Keras Model"
+    ext: hdf5
   - name: "Keras Model"
     ext: keras
   - name: "Core ML Model"

+ 1 - 1
src/app.js

@@ -119,7 +119,7 @@ class Application {
             filters: [
                 { name: 'All Model Files',  extensions: [ 
                     'onnx', 'pb',
-                    'h5', 'hdf5', 'json', 'keras',
+                    'h5', 'hd5', 'hdf5', 'json', 'keras',
                     'mlmodel',
                     'caffemodel',
                     'model', 'dnn', 'cmf',

+ 1 - 1
src/index.html

@@ -68,7 +68,7 @@
         </svg>
     </a>
     <button id="open-file-button" class="center" style="top: 200px; width: 125px; opacity: 0;">Open Model...</button>
-    <input type="file" id="open-file-dialog" style="display:none" multiple="false" accept=".onnx, .pb, .meta, .tflite, .lite, .tfl, .bin, .keras, .h5, .hdf5, .json, .model, .mar, .params, .param, .ncnn, .dnn, .cmf, .mlmodel, .caffemodel, .pbtxt, .prototxt, .pkl, .pt, .pth, .t7, .joblib, .cfg, .xml">
+    <input type="file" id="open-file-dialog" style="display:none" multiple="false" accept=".onnx, .pb, .meta, .tflite, .lite, .tfl, .bin, .keras, .h5, .hd5, .hdf5, .json, .model, .mar, .params, .param, .ncnn, .dnn, .cmf, .mlmodel, .caffemodel, .pbtxt, .prototxt, .pkl, .pt, .pth, .t7, .joblib, .cfg, .xml">
     <!-- Preload fonts to workaround Chrome SVG layout issue -->
     <div style="font-weight: normal; color: rgba(0, 0, 0, 0.01); user-select: none;">.</div>
     <div style="font-weight: bold; color: rgba(0, 0, 0, 0.01); user-select: none;">.</div>

+ 2 - 1
src/keras.js

@@ -11,7 +11,7 @@ keras.ModelFactory = class {
         var identifier = context.identifier;
         var extension = identifier.split('.').pop().toLowerCase();
         var buffer = null;
-        if (extension == 'keras' || extension == 'h5' || extension == 'hdf5') {
+        if (extension == 'keras' || extension == 'h5' || extension == 'hd5' || extension == 'hdf5') {
             // Reject PyTorch models with .h5 file extension.
             buffer = context.buffer;
             var torch = [ 0x8a, 0x0a, 0x6c, 0xfc, 0x9c, 0x46, 0xf9, 0x20, 0x6a, 0xa8, 0x50, 0x19 ];
@@ -65,6 +65,7 @@ keras.ModelFactory = class {
                 switch (identifier.split('.').pop().toLowerCase()) {
                     case 'keras':
                     case 'h5':
+                    case 'hd5':
                     case 'hdf5':
                     case 'model':
                         var file = new hdf5.File(context.buffer);

+ 1 - 1
src/view.js

@@ -1106,7 +1106,7 @@ view.ModelFactoryService = class {
         this._extensions = [];
         this.register('./onnx', [ '.onnx', '.pb', '.pbtxt', '.prototxt' ]);
         this.register('./mxnet', [ '.mar', '.model', '.json', '.params' ]);
-        this.register('./keras', [ '.h5', '.keras', '.hdf5', '.json', '.model' ]);
+        this.register('./keras', [ '.h5', '.hd5', '.hdf5', '.keras', '.json', '.model' ]);
         this.register('./coreml', [ '.mlmodel' ]);
         this.register('./caffe', [ '.caffemodel', '.pbtxt', '.prototxt', '.pt' ]);
         this.register('./caffe2', [ '.pb', '.pbtxt', '.prototxt' ]);