ソースを参照

Update mlnet-metadata.json

Lutz Roeder 5 年 前
コミット
8d9f95f145
2 ファイル変更119 行追加82 行削除
  1. 116 72
      source/mlnet-metadata.json
  2. 3 10
      source/mlnet.js

+ 116 - 72
source/mlnet-metadata.json

@@ -1,92 +1,136 @@
 [
   {
-    "name": "ImageLoaderTransform",
-    "schema": {
-      "description": "Load images from files.",
-      "attributes": [
-        { "name": "ImageFolder", "type": "string", "description": "Folder where to search for images" }
-      ]
-    }
+    "name": "CharToken",
+    "description": "Character-oriented tokenizer where text is considered a sequence of characters.",
+    "attributes": [
+      {
+        "name": "UseMarkerChars",
+        "type": "boolean"
+      },
+      {
+        "name": "IsSeparatorStartEnd",
+        "type": "boolean"
+      }
+    ]
   },
   {
-    "name": "ImageScalerTransform",
-    "schema": {
-      "description": "Scales an image to specified dimensions using one of the three scale types: isotropic with padding, isotropic with cropping or anisotropic. In case of isotropic padding, transparent color is used to pad resulting image.",
-      "attributes": [
-        { "name": "Width" },
-        { "name": "Height" },
-        { "name": "Resizing", "type": "ImageResizingTransformer.ResizingKind" },
-        { "name": "Anchor", "type": "ImageResizingTransformer.Anchor" }
-      ]
-    }
+    "name": "ConcatTransform",
+    "category": "Tensor",
+    "description": "Concatenates one or more columns of the same item type."
   },
   {
-    "name": "ImagePixelExtractor",
-    "schema": {
-      "description": "Scales an image to specified dimensions using one of the three scale types: isotropic with padding, isotropic with cropping or anisotropic. In case of isotropic padding, transparent color is used to pad resulting image.",
-      "attributes": [
-        { "name": "ColorsToExtract", "type": "ImagePixelExtractingTransformer.ColorBits" },
-        { "name": "OrderOfExtraction", "type": "ImagePixelExtractingTransformer.ColorsOrder" },
-        { "name": "Planes", "type": "uint8" },
-        { "name": "OutputAsFloatArray", "type": "boolean" },
-        { "name": "OffsetImage", "type": "float32" },
-        { "name": "ScaleImage", "type": "float32" },
-        { "name": "InterleavePixelColors", "type": "boolean" }
-      ]
-    }
+    "name": "CopyTransform",
+    "category": "Tensor",
+    "description": "Duplicates columns from the dataset."
   },
   {
-    "name": "TensorFlowTransform",
-    "schema": {
-      "description": "Transforms the data using the TensorFlow model.",
-      "attributes": [
-        { "name": "IsFrozen", "type": "boolean" },
-        { "name": "AddBatchDimensionInput", "type": "boolean" }
-      ]
-    }
+    "name": "ImageLoaderTransform",
+    "description": "Load images from files.",
+    "attributes": [
+      {
+        "name": "ImageFolder",
+        "type": "string",
+        "description": "Folder where to search for images"
+      }
+    ]
   },
   {
-    "name": "TextNormalizerTransform",
-    "schema": {
-      "description": "A text normalization transform that allows normalizing text case, removing diacritical marks, punctuation marks and/or numbers. The transform operates on text input as well as vector of tokens/text (vector of ReadOnlyMemory).",
-      "attributes": [
-        { "name": "CaseMode", "type": "TextNormalizingTransformer.CaseMode" },
-        { "name": "KeepDiacritics", "type": "boolean" },
-        { "name": "KeepPunctuations", "type": "boolean" },
-        { "name": "KeepNumbers", "type": "boolean" }
-      ]
-    }
+    "name": "ImagePixelExtractor",
+    "description": "Scales an image to specified dimensions using one of the three scale types: isotropic with padding, isotropic with cropping or anisotropic. In case of isotropic padding, transparent color is used to pad resulting image.",
+    "attributes": [
+      {
+        "name": "ColorsToExtract",
+        "type": "ImagePixelExtractingTransformer.ColorBits"
+      },
+      {
+        "name": "OrderOfExtraction",
+        "type": "ImagePixelExtractingTransformer.ColorsOrder"
+      },
+      {
+        "name": "Planes",
+        "type": "uint8"
+      },
+      {
+        "name": "OutputAsFloatArray",
+        "type": "boolean"
+      },
+      {
+        "name": "OffsetImage",
+        "type": "float32"
+      },
+      {
+        "name": "ScaleImage",
+        "type": "float32"
+      },
+      {
+        "name": "InterleavePixelColors",
+        "type": "boolean"
+      }
+    ]
   },
   {
-    "name": "CharToken",
-    "schema": {
-      "description": "Character-oriented tokenizer where text is considered a sequence of characters.",
-      "attributes": [
-        { "name": "UseMarkerChars", "type": "boolean" },
-        { "name": "IsSeparatorStartEnd", "type": "boolean" }
-      ]
-    }
+    "name": "ImageScalerTransform",
+    "description": "Scales an image to specified dimensions using one of the three scale types: isotropic with padding, isotropic with cropping or anisotropic. In case of isotropic padding, transparent color is used to pad resulting image.",
+    "attributes": [
+      {
+        "name": "Width"
+      },
+      {
+        "name": "Height"
+      },
+      {
+        "name": "Resizing",
+        "type": "ImageResizingTransformer.ResizingKind"
+      },
+      {
+        "name": "Anchor",
+        "type": "ImageResizingTransformer.Anchor"
+      }
+    ]
   },
   {
-    "name": "ConcatTransform",
-    "schema": {
-      "category": "Tensor",
-      "description": "Concatenates one or more columns of the same item type."
-    }
+    "name": "SSAModel",
+    "attributes": [
+      {
+        "name": "UseMarkerChars",
+        "type": "boolean"
+      }
+    ]
   },
   {
-    "name": "CopyTransform",
-    "schema": {
-      "category": "Tensor",
-      "description": "Duplicates columns from the dataset."
-    }
+    "name": "TensorFlowTransform",
+    "description": "Transforms the data using the TensorFlow model.",
+    "attributes": [
+      {
+        "name": "IsFrozen",
+        "type": "boolean"
+      },
+      {
+        "name": "AddBatchDimensionInput",
+        "type": "boolean"
+      }
+    ]
   },
   {
-    "name": "SSAModel",
-    "schema": {
-      "attributes": [
-        { "name": "UseMarkerChars", "type": "boolean" }
-      ]
-    }
+    "name": "TextNormalizerTransform",
+    "description": "A text normalization transform that allows normalizing text case, removing diacritical marks, punctuation marks and/or numbers. The transform operates on text input as well as vector of tokens/text (vector of ReadOnlyMemory).",
+    "attributes": [
+      {
+        "name": "CaseMode",
+        "type": "TextNormalizingTransformer.CaseMode"
+      },
+      {
+        "name": "KeepDiacritics",
+        "type": "boolean"
+      },
+      {
+        "name": "KeepPunctuations",
+        "type": "boolean"
+      },
+      {
+        "name": "KeepNumbers",
+        "type": "boolean"
+      }
+    ]
   }
 ]

+ 3 - 10
source/mlnet.js

@@ -378,20 +378,13 @@ mlnet.Metadata = class {
         this._map = {};
         this._attributeCache = {};
         if (data) {
-            const items = JSON.parse(data);
-            if (items) {
-                for (const item of items) {
-                    if (item.name && item.schema) {
-                        item.schema.name = item.name;
-                        this._map[item.name] = item.schema;
-                    }
-                }
-            }
+            const metadata = JSON.parse(data);
+            this._map = new Map(metadata.map((item) => [ item.name, item ]));
         }
     }
 
     type(name) {
-        return this._map[name] || null;
+        return this._map.get(name);
     }
 
     attribute(type, name) {