Просмотр исходного кода

TensorFlow Lite .tfl detection

Lutz Roeder 6 лет назад
Родитель
Сommit
82cb0d9a95
5 измененных файлов с 15 добавлено и 8 удалено
  1. 8 0
      electron-builder.yml
  2. 1 1
      src/app.js
  3. 1 1
      src/index.html
  4. 4 5
      src/tflite.js
  5. 1 1
      src/view.js

+ 8 - 0
electron-builder.yml

@@ -10,6 +10,10 @@ fileAssociations:
     ext: onnx
   - name: "TensorFlow Lite Model"
     ext: tflite
+  - name: "TensorFlow Lite Model"
+    ext: lite
+  - name: "TensorFlow Lite Model"
+    ext: tfl
   - name: "Keras Model"
     ext: h5
   - name: "Keras Model"
@@ -62,6 +66,10 @@ fileAssociations:
     ext: pth
   - name: "PyTorch Model"
     ext: pt
+  - name: "TorchScript Model"
+    ext: pth
+  - name: "TorchScript Model"
+    ext: pt
   - name: "Torch Model"
     ext: t7
 publish:

+ 1 - 1
src/app.js

@@ -125,7 +125,7 @@ class Application {
                     'model', 'dnn', 'cmf',
                     'mar', 'params',
                     'meta',
-                    'tflite', 'lite', 'bin',
+                    'tflite', 'lite', 'tfl', 'bin',
                     'pt', 'pth', 't7',
                     'pkl', 'joblib',
                     'pbtxt', 'prototxt',

+ 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, .bin, .keras, .h5, .hdf5, .json, .model, .mar, .params, .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, .hdf5, .json, .model, .mar, .params, .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>

+ 4 - 5
src/tflite.js

@@ -13,10 +13,10 @@ tflite.ModelFactory = class {
         if (extension == 'tflite' || extension == 'lite') {
             return true;
         }
-        if (extension == 'bin') {
+        if (extension == 'tfl' || extension == 'bin') {
             var buffer = context.buffer;
-            var torch = [ 0x54, 0x46, 0x4c, 0x33 ];
-            if (buffer && buffer.length > 8 && torch.every((v, i) => v == buffer[i + 4])) {
+            var signature = [ 0x54, 0x46, 0x4c, 0x33 ]; // TFL3
+            if (buffer && buffer.length > 8 && signature.every((x, i) => x == buffer[i + 4])) {
                 return true;
             }
         }
@@ -64,8 +64,7 @@ tflite.Model = class {
     constructor(metadata, model) {
         this._graphs = [];
         this._format = 'TensorFlow Lite v' + model.version().toString();
-        var description = model.description();
-        this._description = (description && description.length > 0) ? description : null;
+        this._description = model.description() || '';
         var operatorCodeList = [];
         var builtinOperatorMap = {};
         for (var key of Object.keys(tflite.schema.BuiltinOperator)) {

+ 1 - 1
src/view.js

@@ -1113,7 +1113,7 @@ view.ModelFactoryService = class {
         this.register('./pytorch', [ '.pt', '.pth', '.pkl', '.h5', '.t7', '.model', '.dms', '.pth.tar', '.ckpt' ]);
         this.register('./torch', [ '.t7' ]);
         this.register('./torchscript', [ '.pt', '.pth' ]);
-        this.register('./tflite', [ '.tflite', '.lite', '.bin' ]);
+        this.register('./tflite', [ '.tflite', '.lite', '.tfl', '.bin' ]);
         this.register('./tf', [ '.pb', '.meta', '.pbtxt', '.prototxt', '.json' ]);
         this.register('./sklearn', [ '.pkl', '.joblib' ]);
         this.register('./cntk', [ '.model', '.cntk', '.cmf', '.dnn' ]);