فهرست منبع

Update ncnn.js

Lutz Roeder 4 سال پیش
والد
کامیت
4a32f0fc0d
1فایلهای تغییر یافته به همراه14 افزوده شده و 9 حذف شده
  1. 14 9
      source/ncnn.js

+ 14 - 9
source/ncnn.js

@@ -22,17 +22,22 @@ ncnn.ModelFactory = class {
             }
         }
         if (identifier.endsWith('.param') || identifier.endsWith('.cfg.ncnn')) {
-            const reader = text.Reader.open(context.stream, 2048);
-            const signature = reader.read();
-            if (signature !== undefined) {
-                if (signature.trim() === '7767517') {
-                    return 'ncnn.model';
-                }
-                const header = signature.trim().split(' ');
-                if (header.length === 2 && header.every((value) => value >>> 0 === parseFloat(value))) {
-                    return 'ncnn.model';
+            try {
+                const reader = text.Reader.open(context.stream, 2048);
+                const signature = reader.read();
+                if (signature !== undefined) {
+                    if (signature.trim() === '7767517') {
+                        return 'ncnn.model';
+                    }
+                    const header = signature.trim().split(' ');
+                    if (header.length === 2 && header.every((value) => value >>> 0 === parseFloat(value))) {
+                        return 'ncnn.model';
+                    }
                 }
             }
+            catch (err) {
+                // continue regardless of error
+            }
         }
         if (identifier.endsWith('.bin') || identifier.endsWith('.weights.ncnn')) {
             if (identifier == 'snapshot_blob.bin' || identifier === 'v8_context_snapshot.bin') {