nuxt-module-essentia 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -0
- package/dist/module.d.ts +5 -0
- package/dist/module.js +31 -0
- package/dist/runtime/composables/useAudioAnalizer.d.ts +44 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/utils/config.d.ts +1 -0
- package/package.json +70 -0
- package/src/runtime/composables/useAudioAnalizer.ts +379 -0
- package/src/runtime/essentia-wasm.web.js +40 -0
- package/src/runtime/essentia.js-core.js +1 -0
- package/src/runtime/index.ts +1 -0
- package/src/runtime/models/LICENSE +1367 -0
- package/src/runtime/models/danceability-msd-musicnn-1/tfjs/group1-shard1of1.bin +0 -0
- package/src/runtime/models/danceability-msd-musicnn-1/tfjs/model.json +1 -0
- package/src/runtime/models/emomusic-msd-musicnn-1/tfjs/group1-shard1of1.bin +0 -0
- package/src/runtime/models/emomusic-msd-musicnn-1/tfjs/model.json +1 -0
- package/src/runtime/models/mood_aggressive-msd-musicnn-1/tfjs/group1-shard1of1.bin +0 -0
- package/src/runtime/models/mood_aggressive-msd-musicnn-1/tfjs/model.json +1 -0
- package/src/runtime/models/mood_happy-msd-musicnn-1/tfjs/group1-shard1of1.bin +0 -0
- package/src/runtime/models/mood_happy-msd-musicnn-1/tfjs/model.json +1 -0
- package/src/runtime/models/mood_relaxed-msd-musicnn-1/tfjs/group1-shard1of1.bin +0 -0
- package/src/runtime/models/mood_relaxed-msd-musicnn-1/tfjs/model.json +1 -0
- package/src/runtime/models/mood_sad-msd-musicnn-1/tfjs/group1-shard1of1.bin +0 -0
- package/src/runtime/models/mood_sad-msd-musicnn-1/tfjs/model.json +1 -0
- package/src/runtime/models/msd-musicnn-1/group1-shard1of1.bin +0 -0
- package/src/runtime/models/msd-musicnn-1/model.json +1 -0
- package/src/runtime/utils/config.ts +14 -0
- package/src/runtime/workers/featureExtraction.js +89 -0
- package/src/runtime/workers/inference.js +135 -0
- package/src/runtime/workers/lib/essentia-wasm.module.js +33 -0
- package/src/runtime/workers/lib/essentia.js-model.umd.js +641 -0
- package/src/runtime/workers/lib/tf-backend-wasm-3.5.0.js +5115 -0
- package/src/runtime/workers/lib/tf.min.3.5.0.js +18 -0
- package/src/runtime/workers/tfjs-backend-wasm-simd.wasm +0 -0
- package/src/runtime/workers/tfjs-backend-wasm-threaded-simd.wasm +0 -0
- package/src/runtime/workers/tfjs-backend-wasm.wasm +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"format": "graph-model", "generatedBy": "2.4.1", "convertedBy": "TensorFlow.js Converter v3.18.0", "signature": {"outputs": {"model/Softmax": {"name": "model/Softmax"}}}, "modelTopology": {"node": [{"name": "model/Placeholder", "op": "Placeholder", "attr": {"dtype": {"type": "DT_FLOAT"}, "shape": {"shape": {"dim": [{"size": "-1"}, {"size": "200"}]}}}}, {"name": "dense/kernel", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "200"}, {"size": "100"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "dense_1/bias", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "2"}]}}}}}, {"name": "dense/bias", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "100"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "dense_1/kernel", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "100"}, {"size": "2"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "model/dense/Relu", "op": "_FusedMatMul", "input": ["model/Placeholder", "dense/kernel", "dense/bias"], "device": "/device:CPU:0", "attr": {"num_args": {"i": "1"}, "transpose_a": {"b": false}, "T": {"type": "DT_FLOAT"}, "transpose_b": {"b": false}, "epsilon": {"f": 0.0}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}}}, {"name": "model/dense_1/BiasAdd", "op": "_FusedMatMul", "input": ["model/dense/Relu", "dense_1/kernel", "dense_1/bias"], "device": "/device:CPU:0", "attr": {"epsilon": {"f": 0.0}, "transpose_a": {"b": false}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}, "num_args": {"i": "1"}, "T": {"type": "DT_FLOAT"}, "transpose_b": {"b": false}}}, {"name": "model/Softmax", "op": "Softmax", "input": ["model/dense_1/BiasAdd"], "attr": {"T": {"type": "DT_FLOAT"}}}], "library": {}, "versions": {}}, "weightsManifest": [{"paths": ["group1-shard1of1.bin"], "weights": [{"name": "dense/kernel", "shape": [200, 100], "dtype": "float32"}, {"name": "dense_1/bias", "shape": [2], "dtype": "float32"}, {"name": "dense/bias", "shape": [100], "dtype": "float32"}, {"name": "dense_1/kernel", "shape": [100, 2], "dtype": "float32"}]}]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"format": "graph-model", "generatedBy": "2.4.1", "convertedBy": "TensorFlow.js Converter v3.18.0", "signature": {"outputs": {"dense_out": {"name": "dense_out"}}}, "modelTopology": {"node": [{"name": "onnx_tf_prefix_flatten_in/strided_slice/stack", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "1"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "onnx_tf_prefix_flatten_in/strided_slice/stack_1", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "1"}]}}}}}, {"name": "onnx_tf_prefix_flatten_in/strided_slice/stack_2", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "1"}]}}}}}, {"name": "onnx_tf_prefix_flatten_in/Reshape/shape/1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "onnx_tf_prefix_batch_normalization/mul", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "200"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "onnx_tf_prefix_batch_normalization/sub", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}, {"size": "200"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "dense_out/kernel_tf_0_cb059fca", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "200"}, {"size": "2"}]}}}}}, {"name": "dense_out/bias_tf_0_36efc7f2", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "2"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "flatten_in_input", "op": "Placeholder", "attr": {"dtype": {"type": "DT_FLOAT"}, "shape": {"shape": {"dim": [{"size": "-1"}, {"size": "1"}, {"size": "200"}]}}}}, {"name": "onnx_tf_prefix_flatten_in/Shape", "op": "Shape", "input": ["flatten_in_input"], "attr": {"out_type": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "onnx_tf_prefix_flatten_in/strided_slice", "op": "StridedSlice", "input": ["onnx_tf_prefix_flatten_in/Shape", "onnx_tf_prefix_flatten_in/strided_slice/stack", "onnx_tf_prefix_flatten_in/strided_slice/stack_1", "onnx_tf_prefix_flatten_in/strided_slice/stack_2"], "attr": {"ellipsis_mask": {"i": "0"}, "new_axis_mask": {"i": "0"}, "shrink_axis_mask": {"i": "1"}, "T": {"type": "DT_INT32"}, "begin_mask": {"i": "0"}, "Index": {"type": "DT_INT32"}, "end_mask": {"i": "0"}}}, {"name": "onnx_tf_prefix_flatten_in/Reshape/shape", "op": "Pack", "input": ["onnx_tf_prefix_flatten_in/strided_slice", "onnx_tf_prefix_flatten_in/Reshape/shape/1"], "attr": {"N": {"i": "2"}, "axis": {"i": "0"}, "T": {"type": "DT_INT32"}}}, {"name": "onnx_tf_prefix_flatten_in/Reshape", "op": "Reshape", "input": ["flatten_in_input", "onnx_tf_prefix_flatten_in/Reshape/shape"], "attr": {"Tshape": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "onnx_tf_prefix_batch_normalization/mul_1", "op": "Mul", "input": ["onnx_tf_prefix_flatten_in/Reshape", "onnx_tf_prefix_batch_normalization/mul"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "onnx_tf_prefix_batch_normalization/add_1", "op": "AddV2", "input": ["onnx_tf_prefix_batch_normalization/mul_1", "onnx_tf_prefix_batch_normalization/sub"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "onnx_tf_prefix_dense_out", "op": "MatMul", "input": ["onnx_tf_prefix_batch_normalization/add_1", "dense_out/kernel_tf_0_cb059fca"], "device": "/device:CPU:0", "attr": {"T": {"type": "DT_FLOAT"}, "transpose_b": {"b": false}, "transpose_a": {"b": false}}}, {"name": "dense_out", "op": "Add", "input": ["onnx_tf_prefix_dense_out", "dense_out/bias_tf_0_36efc7f2"], "attr": {"T": {"type": "DT_FLOAT"}}}], "library": {}, "versions": {"producer": 134}}, "weightsManifest": [{"paths": ["group1-shard1of1.bin"], "weights": [{"name": "onnx_tf_prefix_flatten_in/strided_slice/stack", "shape": [1], "dtype": "int32"}, {"name": "onnx_tf_prefix_flatten_in/strided_slice/stack_1", "shape": [1], "dtype": "int32"}, {"name": "onnx_tf_prefix_flatten_in/strided_slice/stack_2", "shape": [1], "dtype": "int32"}, {"name": "onnx_tf_prefix_flatten_in/Reshape/shape/1", "shape": [], "dtype": "int32"}, {"name": "onnx_tf_prefix_batch_normalization/mul", "shape": [1, 200], "dtype": "float32"}, {"name": "onnx_tf_prefix_batch_normalization/sub", "shape": [1, 200], "dtype": "float32"}, {"name": "dense_out/kernel_tf_0_cb059fca", "shape": [200, 2], "dtype": "float32"}, {"name": "dense_out/bias_tf_0_36efc7f2", "shape": [2], "dtype": "float32"}]}]}
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"format": "graph-model", "generatedBy": "2.4.1", "convertedBy": "TensorFlow.js Converter v3.18.0", "signature": {"outputs": {"model/Softmax": {"name": "model/Softmax"}}}, "modelTopology": {"node": [{"name": "model/Placeholder", "op": "Placeholder", "attr": {"dtype": {"type": "DT_FLOAT"}, "shape": {"shape": {"dim": [{"size": "-1"}, {"size": "200"}]}}}}, {"name": "dense/kernel", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "200"}, {"size": "100"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "dense_1/bias", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "2"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "dense/bias", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "100"}]}}}}}, {"name": "dense_1/kernel", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "100"}, {"size": "2"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "model/dense/Relu", "op": "_FusedMatMul", "input": ["model/Placeholder", "dense/kernel", "dense/bias"], "device": "/device:CPU:0", "attr": {"transpose_b": {"b": false}, "transpose_a": {"b": false}, "num_args": {"i": "1"}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}, "T": {"type": "DT_FLOAT"}, "epsilon": {"f": 0.0}}}, {"name": "model/dense_1/BiasAdd", "op": "_FusedMatMul", "input": ["model/dense/Relu", "dense_1/kernel", "dense_1/bias"], "device": "/device:CPU:0", "attr": {"epsilon": {"f": 0.0}, "num_args": {"i": "1"}, "T": {"type": "DT_FLOAT"}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}, "transpose_a": {"b": false}, "transpose_b": {"b": false}}}, {"name": "model/Softmax", "op": "Softmax", "input": ["model/dense_1/BiasAdd"], "attr": {"T": {"type": "DT_FLOAT"}}}], "library": {}, "versions": {}}, "weightsManifest": [{"paths": ["group1-shard1of1.bin"], "weights": [{"name": "dense/kernel", "shape": [200, 100], "dtype": "float32"}, {"name": "dense_1/bias", "shape": [2], "dtype": "float32"}, {"name": "dense/bias", "shape": [100], "dtype": "float32"}, {"name": "dense_1/kernel", "shape": [100, 2], "dtype": "float32"}]}]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"format": "graph-model", "generatedBy": "2.4.1", "convertedBy": "TensorFlow.js Converter v3.18.0", "signature": {"outputs": {"model/Softmax": {"name": "model/Softmax"}}}, "modelTopology": {"node": [{"name": "model/Placeholder", "op": "Placeholder", "attr": {"dtype": {"type": "DT_FLOAT"}, "shape": {"shape": {"dim": [{"size": "-1"}, {"size": "200"}]}}}}, {"name": "dense/kernel", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "200"}, {"size": "100"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "dense_1/bias", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "2"}]}}}}}, {"name": "dense/bias", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "100"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "dense_1/kernel", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "100"}, {"size": "2"}]}}}}}, {"name": "model/dense/Relu", "op": "_FusedMatMul", "input": ["model/Placeholder", "dense/kernel", "dense/bias"], "device": "/device:CPU:0", "attr": {"num_args": {"i": "1"}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}, "transpose_a": {"b": false}, "T": {"type": "DT_FLOAT"}, "epsilon": {"f": 0.0}, "transpose_b": {"b": false}}}, {"name": "model/dense_1/BiasAdd", "op": "_FusedMatMul", "input": ["model/dense/Relu", "dense_1/kernel", "dense_1/bias"], "device": "/device:CPU:0", "attr": {"fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}, "T": {"type": "DT_FLOAT"}, "transpose_a": {"b": false}, "transpose_b": {"b": false}, "epsilon": {"f": 0.0}, "num_args": {"i": "1"}}}, {"name": "model/Softmax", "op": "Softmax", "input": ["model/dense_1/BiasAdd"], "attr": {"T": {"type": "DT_FLOAT"}}}], "library": {}, "versions": {}}, "weightsManifest": [{"paths": ["group1-shard1of1.bin"], "weights": [{"name": "dense/kernel", "shape": [200, 100], "dtype": "float32"}, {"name": "dense_1/bias", "shape": [2], "dtype": "float32"}, {"name": "dense/bias", "shape": [100], "dtype": "float32"}, {"name": "dense_1/kernel", "shape": [100, 2], "dtype": "float32"}]}]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"format": "graph-model", "generatedBy": "2.4.1", "convertedBy": "TensorFlow.js Converter v3.18.0", "signature": {"outputs": {"model/Softmax": {"name": "model/Softmax"}}}, "modelTopology": {"node": [{"name": "model/Placeholder", "op": "Placeholder", "attr": {"dtype": {"type": "DT_FLOAT"}, "shape": {"shape": {"dim": [{"size": "-1"}, {"size": "200"}]}}}}, {"name": "dense/kernel", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "200"}, {"size": "100"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "dense_1/bias", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "2"}]}}}}}, {"name": "dense/bias", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "100"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "dense_1/kernel", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "100"}, {"size": "2"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "model/dense/Relu", "op": "_FusedMatMul", "input": ["model/Placeholder", "dense/kernel", "dense/bias"], "device": "/device:CPU:0", "attr": {"transpose_a": {"b": false}, "epsilon": {"f": 0.0}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}, "transpose_b": {"b": false}, "num_args": {"i": "1"}, "T": {"type": "DT_FLOAT"}}}, {"name": "model/dense_1/BiasAdd", "op": "_FusedMatMul", "input": ["model/dense/Relu", "dense_1/kernel", "dense_1/bias"], "device": "/device:CPU:0", "attr": {"T": {"type": "DT_FLOAT"}, "transpose_a": {"b": false}, "transpose_b": {"b": false}, "epsilon": {"f": 0.0}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}, "num_args": {"i": "1"}}}, {"name": "model/Softmax", "op": "Softmax", "input": ["model/dense_1/BiasAdd"], "attr": {"T": {"type": "DT_FLOAT"}}}], "library": {}, "versions": {}}, "weightsManifest": [{"paths": ["group1-shard1of1.bin"], "weights": [{"name": "dense/kernel", "shape": [200, 100], "dtype": "float32"}, {"name": "dense_1/bias", "shape": [2], "dtype": "float32"}, {"name": "dense/bias", "shape": [100], "dtype": "float32"}, {"name": "dense_1/kernel", "shape": [100, 2], "dtype": "float32"}]}]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"format": "graph-model", "generatedBy": "2.4.1", "convertedBy": "TensorFlow.js Converter v3.18.0", "signature": {"outputs": {"model/Softmax": {"name": "model/Softmax"}}}, "modelTopology": {"node": [{"name": "model/Placeholder", "op": "Placeholder", "attr": {"dtype": {"type": "DT_FLOAT"}, "shape": {"shape": {"dim": [{"size": "-1"}, {"size": "200"}]}}}}, {"name": "dense/kernel", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "200"}, {"size": "100"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "dense_1/bias", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "2"}]}}}}}, {"name": "dense/bias", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "100"}]}}}}}, {"name": "dense_1/kernel", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "100"}, {"size": "2"}]}}}}}, {"name": "model/dense/Relu", "op": "_FusedMatMul", "input": ["model/Placeholder", "dense/kernel", "dense/bias"], "device": "/device:CPU:0", "attr": {"T": {"type": "DT_FLOAT"}, "epsilon": {"f": 0.0}, "num_args": {"i": "1"}, "transpose_b": {"b": false}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}, "transpose_a": {"b": false}}}, {"name": "model/dense_1/BiasAdd", "op": "_FusedMatMul", "input": ["model/dense/Relu", "dense_1/kernel", "dense_1/bias"], "device": "/device:CPU:0", "attr": {"T": {"type": "DT_FLOAT"}, "num_args": {"i": "1"}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}, "epsilon": {"f": 0.0}, "transpose_a": {"b": false}, "transpose_b": {"b": false}}}, {"name": "model/Softmax", "op": "Softmax", "input": ["model/dense_1/BiasAdd"], "attr": {"T": {"type": "DT_FLOAT"}}}], "library": {}, "versions": {}}, "weightsManifest": [{"paths": ["group1-shard1of1.bin"], "weights": [{"name": "dense/kernel", "shape": [200, 100], "dtype": "float32"}, {"name": "dense_1/bias", "shape": [2], "dtype": "float32"}, {"name": "dense/bias", "shape": [100], "dtype": "float32"}, {"name": "dense_1/kernel", "shape": [100, 2], "dtype": "float32"}]}]}
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"format": "graph-model", "generatedBy": "2.1.0", "convertedBy": "TensorFlow.js Converter v1.7.2", "userDefinedMetadata": {"signature": {"outputs": {"model/Sigmoid": {"name": "model/Sigmoid"}}}}, "modelTopology": {"node": [{"name": "model/Placeholder_1", "op": "Placeholder", "attr": {"dtype": {"type": "DT_BOOL"}, "shape": {"shape": {"unknownRank": true}}}}, {"name": "model/batch_normalization_10/batchnorm/mul", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "200"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_9/batchnorm/mul", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1506"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "model/Max/reduction_indices", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "conv2d/kernel", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "7"}, {"size": "38"}, {"size": "1"}, {"size": "204"}]}}}}}, {"name": "conv2d/bias", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "204"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "conv2d_1/kernel", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "7"}, {"size": "67"}, {"size": "1"}, {"size": "204"}]}}}}}, {"name": "conv2d_1/bias", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "204"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "conv2d_2/kernel", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "128"}, {"size": "1"}, {"size": "1"}, {"size": "51"}]}}}}}, {"name": "conv2d_2/bias", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "51"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "conv2d_3/kernel", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "64"}, {"size": "1"}, {"size": "1"}, {"size": "51"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "conv2d_3/bias", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "51"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "model/Placeholder", "op": "Placeholder", "attr": {"shape": {"shape": {"dim": [{"size": "-1"}, {"size": "187"}, {"size": "96"}]}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "conv2d_4/kernel", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "32"}, {"size": "1"}, {"size": "1"}, {"size": "51"}]}}}}}, {"name": "conv2d_4/bias", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "51"}]}}}}}, {"name": "model/ExpandDims/dim", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "model/batch_normalization_4/FusedBatchNorm/Scaled", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "51"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_4/FusedBatchNorm/Offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "51"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "conv2d_5/kernel", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "7"}, {"size": "561"}, {"size": "1"}, {"size": "64"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "conv2d_5/bias", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "64"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "conv2d_6/kernel", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "7"}, {"size": "64"}, {"size": "1"}, {"size": "64"}]}}}}}, {"name": "conv2d_6/bias", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "64"}]}}}}}, {"name": "model/Pad_3/paddings", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}, {"size": "2"}]}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "model/batch_normalization_3/FusedBatchNorm/Scaled", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "51"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "conv2d_7/kernel", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "7"}, {"size": "64"}, {"size": "1"}, {"size": "64"}]}}}}}, {"name": "conv2d_7/bias", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "64"}]}}}}}, {"name": "model/transpose_2/perm", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "4"}]}}}}}, {"name": "model/concat/axis", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}}}, {"name": "model/batch_normalization_3/FusedBatchNorm/Offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "51"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization/FusedBatchNorm/Scaled", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "model/flatten/strided_slice/stack", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "1"}]}}}}}, {"name": "model/moments/mean/reduction_indices", "op": "Const", "attr": {"dtype": {"type": "DT_INT32"}, "value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {"dim": [{"size": "1"}]}}}}}, {"name": "model/flatten/Reshape/shape/1", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_INT32", "tensorShape": {}}}, "dtype": {"type": "DT_INT32"}}}, {"name": "model/batch_normalization_9/batchnorm/sub", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1506"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "dense/kernel", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1506"}, {"size": "200"}]}}}}}, {"name": "dense/bias", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "200"}]}}}}}, {"name": "model/batch_normalization_10/batchnorm/sub", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "200"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "dense_1/kernel", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "200"}, {"size": "50"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization/FusedBatchNorm/Offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "1"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "dense_1/bias", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "50"}]}}}}}, {"name": "model/batch_normalization_8/FusedBatchNorm/Scaled", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "64"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_8/FusedBatchNorm/Offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "64"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_7/FusedBatchNorm/Scaled", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "64"}]}}}}}, {"name": "model/batch_normalization_7/FusedBatchNorm/Offset", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "64"}]}}}}}, {"name": "model/batch_normalization_6/FusedBatchNorm/Scaled", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "64"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_6/FusedBatchNorm/Offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "64"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_2/FusedBatchNorm/Scaled", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "204"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_2/FusedBatchNorm/Offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "204"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_1/FusedBatchNorm/Scaled", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "204"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_1/FusedBatchNorm/Offset", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "204"}]}}}}}, {"name": "model/batch_normalization_5/FusedBatchNorm/Scaled", "op": "Const", "attr": {"dtype": {"type": "DT_FLOAT"}, "value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "51"}]}}}}}, {"name": "model/batch_normalization_5/FusedBatchNorm/Offset", "op": "Const", "attr": {"value": {"tensor": {"dtype": "DT_FLOAT", "tensorShape": {"dim": [{"size": "51"}]}}}, "dtype": {"type": "DT_FLOAT"}}}, {"name": "model/ExpandDims", "op": "ExpandDims", "input": ["model/Placeholder", "model/ExpandDims/dim"], "attr": {"T": {"type": "DT_FLOAT"}, "Tdim": {"type": "DT_INT32"}}}, {"name": "model/batch_normalization/FusedBatchNorm/Mul", "op": "Mul", "input": ["model/ExpandDims", "model/batch_normalization/FusedBatchNorm/Scaled"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization/FusedBatchNorm", "op": "Add", "input": ["model/batch_normalization/FusedBatchNorm/Mul", "model/batch_normalization/FusedBatchNorm/Offset"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/conv2d_2/Relu", "op": "_FusedConv2D", "input": ["model/batch_normalization/FusedBatchNorm", "conv2d_2/kernel", "conv2d_2/bias"], "device": "/device:CPU:0", "attr": {"epsilon": {"f": 0.0}, "padding": {"s": "U0FNRQ=="}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}}}, {"name": "model/conv2d_3/Relu", "op": "_FusedConv2D", "input": ["model/batch_normalization/FusedBatchNorm", "conv2d_3/kernel", "conv2d_3/bias"], "device": "/device:CPU:0", "attr": {"T": {"type": "DT_FLOAT"}, "padding": {"s": "U0FNRQ=="}, "explicit_paddings": {"list": {}}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}, "num_args": {"i": "1"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "use_cudnn_on_gpu": {"b": true}, "data_format": {"s": "TkhXQw=="}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "epsilon": {"f": 0.0}}}, {"name": "model/conv2d_4/Relu", "op": "_FusedConv2D", "input": ["model/batch_normalization/FusedBatchNorm", "conv2d_4/kernel", "conv2d_4/bias"], "device": "/device:CPU:0", "attr": {"epsilon": {"f": 0.0}, "use_cudnn_on_gpu": {"b": true}, "data_format": {"s": "TkhXQw=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "T": {"type": "DT_FLOAT"}, "explicit_paddings": {"list": {}}, "num_args": {"i": "1"}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "padding": {"s": "U0FNRQ=="}}}, {"name": "model/Pad", "op": "Pad", "input": ["model/batch_normalization/FusedBatchNorm", "model/Pad_3/paddings"], "attr": {"Tpaddings": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_3/FusedBatchNorm/Mul", "op": "Mul", "input": ["model/batch_normalization_3/FusedBatchNorm/Scaled", "model/conv2d_2/Relu"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_4/FusedBatchNorm/Mul", "op": "Mul", "input": ["model/batch_normalization_4/FusedBatchNorm/Scaled", "model/conv2d_3/Relu"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_5/FusedBatchNorm/Mul", "op": "Mul", "input": ["model/batch_normalization_5/FusedBatchNorm/Scaled", "model/conv2d_4/Relu"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/conv2d/Relu", "op": "_FusedConv2D", "input": ["model/Pad", "conv2d/kernel", "conv2d/bias"], "device": "/device:CPU:0", "attr": {"T": {"type": "DT_FLOAT"}, "num_args": {"i": "1"}, "padding": {"s": "VkFMSUQ="}, "data_format": {"s": "TkhXQw=="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}, "use_cudnn_on_gpu": {"b": true}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "epsilon": {"f": 0.0}, "explicit_paddings": {"list": {}}}}, {"name": "model/conv2d_1/Relu", "op": "_FusedConv2D", "input": ["model/Pad", "conv2d_1/kernel", "conv2d_1/bias"], "device": "/device:CPU:0", "attr": {"dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "explicit_paddings": {"list": {}}, "padding": {"s": "VkFMSUQ="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "use_cudnn_on_gpu": {"b": true}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}}}, {"name": "model/batch_normalization_3/FusedBatchNorm", "op": "Add", "input": ["model/batch_normalization_3/FusedBatchNorm/Mul", "model/batch_normalization_3/FusedBatchNorm/Offset"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_4/FusedBatchNorm", "op": "Add", "input": ["model/batch_normalization_4/FusedBatchNorm/Mul", "model/batch_normalization_4/FusedBatchNorm/Offset"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_5/FusedBatchNorm", "op": "Add", "input": ["model/batch_normalization_5/FusedBatchNorm/Mul", "model/batch_normalization_5/FusedBatchNorm/Offset"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_1/FusedBatchNorm/Mul", "op": "Mul", "input": ["model/batch_normalization_1/FusedBatchNorm/Scaled", "model/conv2d/Relu"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_2/FusedBatchNorm/Mul", "op": "Mul", "input": ["model/batch_normalization_2/FusedBatchNorm/Scaled", "model/conv2d_1/Relu"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/max_pooling2d_2/MaxPool", "op": "MaxPool", "input": ["model/batch_normalization_3/FusedBatchNorm"], "attr": {"ksize": {"list": {"i": ["1", "1", "96", "1"]}}, "strides": {"list": {"i": ["1", "1", "96", "1"]}}, "data_format": {"s": "TkhXQw=="}, "T": {"type": "DT_FLOAT"}, "padding": {"s": "VkFMSUQ="}}}, {"name": "model/max_pooling2d_3/MaxPool", "op": "MaxPool", "input": ["model/batch_normalization_4/FusedBatchNorm"], "attr": {"data_format": {"s": "TkhXQw=="}, "padding": {"s": "VkFMSUQ="}, "T": {"type": "DT_FLOAT"}, "strides": {"list": {"i": ["1", "1", "96", "1"]}}, "ksize": {"list": {"i": ["1", "1", "96", "1"]}}}}, {"name": "model/max_pooling2d_4/MaxPool", "op": "MaxPool", "input": ["model/batch_normalization_5/FusedBatchNorm"], "attr": {"data_format": {"s": "TkhXQw=="}, "padding": {"s": "VkFMSUQ="}, "strides": {"list": {"i": ["1", "1", "96", "1"]}}, "ksize": {"list": {"i": ["1", "1", "96", "1"]}}, "T": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_1/FusedBatchNorm", "op": "Add", "input": ["model/batch_normalization_1/FusedBatchNorm/Mul", "model/batch_normalization_1/FusedBatchNorm/Offset"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_2/FusedBatchNorm", "op": "Add", "input": ["model/batch_normalization_2/FusedBatchNorm/Mul", "model/batch_normalization_2/FusedBatchNorm/Offset"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/Squeeze_2", "op": "Squeeze", "input": ["model/max_pooling2d_2/MaxPool"], "attr": {"T": {"type": "DT_FLOAT"}, "squeeze_dims": {"list": {"i": ["2"]}}}}, {"name": "model/Squeeze_3", "op": "Squeeze", "input": ["model/max_pooling2d_3/MaxPool"], "attr": {"T": {"type": "DT_FLOAT"}, "squeeze_dims": {"list": {"i": ["2"]}}}}, {"name": "model/Squeeze_4", "op": "Squeeze", "input": ["model/max_pooling2d_4/MaxPool"], "attr": {"squeeze_dims": {"list": {"i": ["2"]}}, "T": {"type": "DT_FLOAT"}}}, {"name": "model/max_pooling2d/MaxPool", "op": "MaxPool", "input": ["model/batch_normalization_1/FusedBatchNorm"], "attr": {"T": {"type": "DT_FLOAT"}, "ksize": {"list": {"i": ["1", "1", "59", "1"]}}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "59", "1"]}}, "padding": {"s": "VkFMSUQ="}}}, {"name": "model/max_pooling2d_1/MaxPool", "op": "MaxPool", "input": ["model/batch_normalization_2/FusedBatchNorm"], "attr": {"ksize": {"list": {"i": ["1", "1", "30", "1"]}}, "padding": {"s": "VkFMSUQ="}, "strides": {"list": {"i": ["1", "1", "30", "1"]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}}}, {"name": "model/Squeeze", "op": "Squeeze", "input": ["model/max_pooling2d/MaxPool"], "attr": {"squeeze_dims": {"list": {"i": ["2"]}}, "T": {"type": "DT_FLOAT"}}}, {"name": "model/Squeeze_1", "op": "Squeeze", "input": ["model/max_pooling2d_1/MaxPool"], "attr": {"T": {"type": "DT_FLOAT"}, "squeeze_dims": {"list": {"i": ["2"]}}}}, {"name": "model/concat", "op": "ConcatV2", "input": ["model/Squeeze", "model/Squeeze_1", "model/Squeeze_2", "model/Squeeze_3", "model/Squeeze_4", "model/concat/axis"], "attr": {"N": {"i": "5"}, "Tidx": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "model/ExpandDims_1", "op": "ExpandDims", "input": ["model/concat", "model/ExpandDims/dim"], "attr": {"Tdim": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "model/Pad_1", "op": "Pad", "input": ["model/ExpandDims_1", "model/Pad_3/paddings"], "attr": {"T": {"type": "DT_FLOAT"}, "Tpaddings": {"type": "DT_INT32"}}}, {"name": "model/conv2d_5/Relu", "op": "_FusedConv2D", "input": ["model/Pad_1", "conv2d_5/kernel", "conv2d_5/bias"], "device": "/device:CPU:0", "attr": {"T": {"type": "DT_FLOAT"}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "data_format": {"s": "TkhXQw=="}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "padding": {"s": "VkFMSUQ="}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}, "explicit_paddings": {"list": {}}, "use_cudnn_on_gpu": {"b": true}}}, {"name": "model/batch_normalization_6/FusedBatchNorm/Mul", "op": "Mul", "input": ["model/batch_normalization_6/FusedBatchNorm/Scaled", "model/conv2d_5/Relu"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_6/FusedBatchNorm", "op": "Add", "input": ["model/batch_normalization_6/FusedBatchNorm/Mul", "model/batch_normalization_6/FusedBatchNorm/Offset"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/transpose", "op": "Transpose", "input": ["model/batch_normalization_6/FusedBatchNorm", "model/transpose_2/perm"], "attr": {"Tperm": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "model/Pad_2", "op": "Pad", "input": ["model/transpose", "model/Pad_3/paddings"], "attr": {"Tpaddings": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "model/conv2d_6/Relu", "op": "_FusedConv2D", "input": ["model/Pad_2", "conv2d_6/kernel", "conv2d_6/bias"], "device": "/device:CPU:0", "attr": {"epsilon": {"f": 0.0}, "num_args": {"i": "1"}, "T": {"type": "DT_FLOAT"}, "use_cudnn_on_gpu": {"b": true}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "padding": {"s": "VkFMSUQ="}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}}}, {"name": "model/batch_normalization_7/FusedBatchNorm/Mul", "op": "Mul", "input": ["model/batch_normalization_7/FusedBatchNorm/Scaled", "model/conv2d_6/Relu"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_7/FusedBatchNorm", "op": "Add", "input": ["model/batch_normalization_7/FusedBatchNorm/Mul", "model/batch_normalization_7/FusedBatchNorm/Offset"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/transpose_1", "op": "Transpose", "input": ["model/batch_normalization_7/FusedBatchNorm", "model/transpose_2/perm"], "attr": {"Tperm": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "model/Add", "op": "Add", "input": ["model/transpose", "model/transpose_1"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/Pad_3", "op": "Pad", "input": ["model/Add", "model/Pad_3/paddings"], "attr": {"T": {"type": "DT_FLOAT"}, "Tpaddings": {"type": "DT_INT32"}}}, {"name": "model/conv2d_7/Relu", "op": "_FusedConv2D", "input": ["model/Pad_3", "conv2d_7/kernel", "conv2d_7/bias"], "device": "/device:CPU:0", "attr": {"fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}, "T": {"type": "DT_FLOAT"}, "data_format": {"s": "TkhXQw=="}, "explicit_paddings": {"list": {}}, "dilations": {"list": {"i": ["1", "1", "1", "1"]}}, "use_cudnn_on_gpu": {"b": true}, "epsilon": {"f": 0.0}, "strides": {"list": {"i": ["1", "1", "1", "1"]}}, "num_args": {"i": "1"}, "padding": {"s": "VkFMSUQ="}}}, {"name": "model/batch_normalization_8/FusedBatchNorm/Mul", "op": "Mul", "input": ["model/batch_normalization_8/FusedBatchNorm/Scaled", "model/conv2d_7/Relu"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_8/FusedBatchNorm", "op": "Add", "input": ["model/batch_normalization_8/FusedBatchNorm/Mul", "model/batch_normalization_8/FusedBatchNorm/Offset"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/transpose_2", "op": "Transpose", "input": ["model/batch_normalization_8/FusedBatchNorm", "model/transpose_2/perm"], "attr": {"T": {"type": "DT_FLOAT"}, "Tperm": {"type": "DT_INT32"}}}, {"name": "model/Add_1", "op": "Add", "input": ["model/Add", "model/transpose_2"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/concat_1", "op": "ConcatV2", "input": ["model/ExpandDims_1", "model/transpose", "model/Add", "model/Add_1", "model/concat/axis"], "attr": {"T": {"type": "DT_FLOAT"}, "Tidx": {"type": "DT_INT32"}, "N": {"i": "4"}}}, {"name": "model/Max", "op": "Max", "input": ["model/concat_1", "model/Max/reduction_indices"], "attr": {"keep_dims": {"b": false}, "Tidx": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "model/moments/mean", "op": "Mean", "input": ["model/concat_1", "model/moments/mean/reduction_indices"], "attr": {"keep_dims": {"b": true}, "Tidx": {"type": "DT_INT32"}, "T": {"type": "DT_FLOAT"}}}, {"name": "model/moments/Squeeze", "op": "Squeeze", "input": ["model/moments/mean"], "attr": {"squeeze_dims": {"list": {"i": ["1"]}}, "T": {"type": "DT_FLOAT"}}}, {"name": "model/concat_2", "op": "ConcatV2", "input": ["model/Max", "model/moments/Squeeze", "model/concat/axis"], "attr": {"T": {"type": "DT_FLOAT"}, "N": {"i": "2"}, "Tidx": {"type": "DT_INT32"}}}, {"name": "model/flatten/Shape", "op": "Shape", "input": ["model/concat_2"], "attr": {"T": {"type": "DT_FLOAT"}, "out_type": {"type": "DT_INT32"}}}, {"name": "model/flatten/strided_slice", "op": "StridedSlice", "input": ["model/flatten/Shape", "model/flatten/strided_slice/stack", "model/moments/mean/reduction_indices", "model/moments/mean/reduction_indices"], "attr": {"begin_mask": {"i": "0"}, "ellipsis_mask": {"i": "0"}, "new_axis_mask": {"i": "0"}, "end_mask": {"i": "0"}, "shrink_axis_mask": {"i": "1"}, "T": {"type": "DT_INT32"}, "Index": {"type": "DT_INT32"}}}, {"name": "model/flatten/Reshape/shape", "op": "Pack", "input": ["model/flatten/strided_slice", "model/flatten/Reshape/shape/1"], "attr": {"axis": {"i": "0"}, "T": {"type": "DT_INT32"}, "N": {"i": "2"}}}, {"name": "model/flatten/Reshape", "op": "Reshape", "input": ["model/concat_2", "model/flatten/Reshape/shape"], "attr": {"T": {"type": "DT_FLOAT"}, "Tshape": {"type": "DT_INT32"}}}, {"name": "model/batch_normalization_9/batchnorm/mul_1", "op": "Mul", "input": ["model/batch_normalization_9/batchnorm/mul", "model/flatten/Reshape"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_9/batchnorm/add_1", "op": "Add", "input": ["model/batch_normalization_9/batchnorm/mul_1", "model/batch_normalization_9/batchnorm/sub"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/dense/Relu", "op": "_FusedMatMul", "input": ["model/batch_normalization_9/batchnorm/add_1", "dense/kernel", "dense/bias"], "device": "/device:CPU:0", "attr": {"num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "T": {"type": "DT_FLOAT"}, "transpose_b": {"b": false}, "transpose_a": {"b": false}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA==", "UmVsdQ=="]}}}}, {"name": "model/batch_normalization_10/batchnorm/mul_1", "op": "Mul", "input": ["model/batch_normalization_10/batchnorm/mul", "model/dense/Relu"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/batch_normalization_10/batchnorm/add_1", "op": "Add", "input": ["model/batch_normalization_10/batchnorm/mul_1", "model/batch_normalization_10/batchnorm/sub"], "attr": {"T": {"type": "DT_FLOAT"}}}, {"name": "model/dense_1/BiasAdd", "op": "_FusedMatMul", "input": ["model/batch_normalization_10/batchnorm/add_1", "dense_1/kernel", "dense_1/bias"], "device": "/device:CPU:0", "attr": {"T": {"type": "DT_FLOAT"}, "transpose_b": {"b": false}, "num_args": {"i": "1"}, "epsilon": {"f": 0.0}, "transpose_a": {"b": false}, "fused_ops": {"list": {"s": ["Qmlhc0FkZA=="]}}}}, {"name": "model/Sigmoid", "op": "Sigmoid", "input": ["model/dense_1/BiasAdd"], "attr": {"T": {"type": "DT_FLOAT"}}}], "versions": {}}, "weightsManifest": [{"paths": ["group1-shard1of1.bin"], "weights": [{"name": "model/batch_normalization_10/batchnorm/mul", "shape": [200], "dtype": "float32"}, {"name": "model/batch_normalization_9/batchnorm/mul", "shape": [1506], "dtype": "float32"}, {"name": "model/Max/reduction_indices", "shape": [], "dtype": "int32"}, {"name": "conv2d/kernel", "shape": [7, 38, 1, 204], "dtype": "float32"}, {"name": "conv2d/bias", "shape": [204], "dtype": "float32"}, {"name": "conv2d_1/kernel", "shape": [7, 67, 1, 204], "dtype": "float32"}, {"name": "conv2d_1/bias", "shape": [204], "dtype": "float32"}, {"name": "conv2d_2/kernel", "shape": [128, 1, 1, 51], "dtype": "float32"}, {"name": "conv2d_2/bias", "shape": [51], "dtype": "float32"}, {"name": "conv2d_3/kernel", "shape": [64, 1, 1, 51], "dtype": "float32"}, {"name": "conv2d_3/bias", "shape": [51], "dtype": "float32"}, {"name": "conv2d_4/kernel", "shape": [32, 1, 1, 51], "dtype": "float32"}, {"name": "conv2d_4/bias", "shape": [51], "dtype": "float32"}, {"name": "model/ExpandDims/dim", "shape": [], "dtype": "int32"}, {"name": "model/batch_normalization_4/FusedBatchNorm/Scaled", "shape": [51], "dtype": "float32"}, {"name": "model/batch_normalization_4/FusedBatchNorm/Offset", "shape": [51], "dtype": "float32"}, {"name": "conv2d_5/kernel", "shape": [7, 561, 1, 64], "dtype": "float32"}, {"name": "conv2d_5/bias", "shape": [64], "dtype": "float32"}, {"name": "conv2d_6/kernel", "shape": [7, 64, 1, 64], "dtype": "float32"}, {"name": "conv2d_6/bias", "shape": [64], "dtype": "float32"}, {"name": "model/Pad_3/paddings", "shape": [4, 2], "dtype": "int32"}, {"name": "model/batch_normalization_3/FusedBatchNorm/Scaled", "shape": [51], "dtype": "float32"}, {"name": "conv2d_7/kernel", "shape": [7, 64, 1, 64], "dtype": "float32"}, {"name": "conv2d_7/bias", "shape": [64], "dtype": "float32"}, {"name": "model/transpose_2/perm", "shape": [4], "dtype": "int32"}, {"name": "model/concat/axis", "shape": [], "dtype": "int32"}, {"name": "model/batch_normalization_3/FusedBatchNorm/Offset", "shape": [51], "dtype": "float32"}, {"name": "model/batch_normalization/FusedBatchNorm/Scaled", "shape": [1], "dtype": "float32"}, {"name": "model/flatten/strided_slice/stack", "shape": [1], "dtype": "int32"}, {"name": "model/moments/mean/reduction_indices", "shape": [1], "dtype": "int32"}, {"name": "model/flatten/Reshape/shape/1", "shape": [], "dtype": "int32"}, {"name": "model/batch_normalization_9/batchnorm/sub", "shape": [1506], "dtype": "float32"}, {"name": "dense/kernel", "shape": [1506, 200], "dtype": "float32"}, {"name": "dense/bias", "shape": [200], "dtype": "float32"}, {"name": "model/batch_normalization_10/batchnorm/sub", "shape": [200], "dtype": "float32"}, {"name": "dense_1/kernel", "shape": [200, 50], "dtype": "float32"}, {"name": "model/batch_normalization/FusedBatchNorm/Offset", "shape": [1], "dtype": "float32"}, {"name": "dense_1/bias", "shape": [50], "dtype": "float32"}, {"name": "model/batch_normalization_8/FusedBatchNorm/Scaled", "shape": [64], "dtype": "float32"}, {"name": "model/batch_normalization_8/FusedBatchNorm/Offset", "shape": [64], "dtype": "float32"}, {"name": "model/batch_normalization_7/FusedBatchNorm/Scaled", "shape": [64], "dtype": "float32"}, {"name": "model/batch_normalization_7/FusedBatchNorm/Offset", "shape": [64], "dtype": "float32"}, {"name": "model/batch_normalization_6/FusedBatchNorm/Scaled", "shape": [64], "dtype": "float32"}, {"name": "model/batch_normalization_6/FusedBatchNorm/Offset", "shape": [64], "dtype": "float32"}, {"name": "model/batch_normalization_2/FusedBatchNorm/Scaled", "shape": [204], "dtype": "float32"}, {"name": "model/batch_normalization_2/FusedBatchNorm/Offset", "shape": [204], "dtype": "float32"}, {"name": "model/batch_normalization_1/FusedBatchNorm/Scaled", "shape": [204], "dtype": "float32"}, {"name": "model/batch_normalization_1/FusedBatchNorm/Offset", "shape": [204], "dtype": "float32"}, {"name": "model/batch_normalization_5/FusedBatchNorm/Scaled", "shape": [51], "dtype": "float32"}, {"name": "model/batch_normalization_5/FusedBatchNorm/Offset", "shape": [51], "dtype": "float32"}]}]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
let cachedConfig: { publicAssetsPath: string } | null = null;
|
|
2
|
+
|
|
3
|
+
export async function getEssentiaConfig() {
|
|
4
|
+
if (cachedConfig) return cachedConfig;
|
|
5
|
+
|
|
6
|
+
if (import.meta.client) {
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
const { essentiaConfig } = await import("#build/essentia-config.mjs");
|
|
9
|
+
cachedConfig = essentiaConfig;
|
|
10
|
+
return essentiaConfig;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return { publicAssetsPath: "/essentia/" };
|
|
14
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
importScripts("./lib/tf.min.3.5.0.js");
|
|
2
|
+
importScripts("./lib/essentia.js-model.umd.js");
|
|
3
|
+
importScripts("./lib/essentia-wasm.module.js");
|
|
4
|
+
// using importScripts since it works on both Chrome and Firefox
|
|
5
|
+
// using modified version of ES6 essentia WASM, so that it can be loaded with importScripts
|
|
6
|
+
const EssentiaWASM = Module;
|
|
7
|
+
const extractor = new EssentiaModel.EssentiaTFInputExtractor(EssentiaWASM, "musicnn", false);
|
|
8
|
+
|
|
9
|
+
let modelStart = 0;
|
|
10
|
+
|
|
11
|
+
let model;
|
|
12
|
+
let modelURL = "/models/msd-musicnn-1/model.json";
|
|
13
|
+
let modelLoaded = false;
|
|
14
|
+
let modelReady = false;
|
|
15
|
+
|
|
16
|
+
function initModel() {
|
|
17
|
+
model = new EssentiaModel.TensorflowMusiCNN(tf, modelURL);
|
|
18
|
+
|
|
19
|
+
loadModel().then((isLoaded) => {
|
|
20
|
+
if (isLoaded) {
|
|
21
|
+
modelLoaded = true;
|
|
22
|
+
// perform dry run to warm them up
|
|
23
|
+
warmUp();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function loadModel() {
|
|
29
|
+
await model.initialize();
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getZeroMatrix(x, y) {
|
|
34
|
+
let matrix = new Array(x);
|
|
35
|
+
for (let f = 0; f < x; f++) {
|
|
36
|
+
matrix[f] = new Array(y).fill(0);
|
|
37
|
+
}
|
|
38
|
+
return matrix;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function warmUp() {
|
|
42
|
+
const fakeFeatures = {
|
|
43
|
+
melSpectrum: getZeroMatrix(187, 96),
|
|
44
|
+
frameSize: 187,
|
|
45
|
+
melBandsSize: 96,
|
|
46
|
+
patchSize: 187,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const fakeStart = Date.now();
|
|
50
|
+
|
|
51
|
+
model.predict(fakeFeatures, false, true).then(() => {
|
|
52
|
+
modelReady = true;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function initTensorflowWASM() {
|
|
57
|
+
if (tf.getBackend() != "wasm") {
|
|
58
|
+
importScripts("./lib/tf-backend-wasm-3.5.0.js");
|
|
59
|
+
// importScripts('https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm/dist/tf-backend-wasm.js');
|
|
60
|
+
tf.setBackend("wasm");
|
|
61
|
+
tf.ready()
|
|
62
|
+
.then(() => {
|
|
63
|
+
initModel();
|
|
64
|
+
})
|
|
65
|
+
.catch(() => {
|
|
66
|
+
return false;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function computeEmbeddings(audioData) {
|
|
72
|
+
const features = extractor.computeFrameWise(audioData, 256);
|
|
73
|
+
modelStart = Date.now();
|
|
74
|
+
return model.predict(features, true, true);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
onmessage = function listenToMainThread(msg) {
|
|
78
|
+
if (msg.data.init) {
|
|
79
|
+
initTensorflowWASM();
|
|
80
|
+
}
|
|
81
|
+
if (msg.data.audio) {
|
|
82
|
+
const audio = new Float32Array(msg.data.audio);
|
|
83
|
+
computeEmbeddings(audio).then((embeddings) => {
|
|
84
|
+
postMessage({
|
|
85
|
+
embeddings: embeddings,
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
importScripts("./lib/tf.min.3.5.0.js");
|
|
2
|
+
|
|
3
|
+
let classifiers = {
|
|
4
|
+
mood_happy: {
|
|
5
|
+
isLoaded: false,
|
|
6
|
+
tagOrder: [true, false],
|
|
7
|
+
model: null,
|
|
8
|
+
},
|
|
9
|
+
mood_sad: {
|
|
10
|
+
isLoaded: false,
|
|
11
|
+
tagOrder: [false, true],
|
|
12
|
+
model: null,
|
|
13
|
+
},
|
|
14
|
+
mood_relaxed: {
|
|
15
|
+
isLoaded: false,
|
|
16
|
+
tagOrder: [false, true],
|
|
17
|
+
model: null,
|
|
18
|
+
},
|
|
19
|
+
mood_aggressive: {
|
|
20
|
+
isLoaded: false,
|
|
21
|
+
tagOrder: [true, false],
|
|
22
|
+
model: null,
|
|
23
|
+
},
|
|
24
|
+
danceability: {
|
|
25
|
+
isLoaded: false,
|
|
26
|
+
tagOrder: [true, false],
|
|
27
|
+
model: null,
|
|
28
|
+
},
|
|
29
|
+
emomusic: {
|
|
30
|
+
isLoaded: false,
|
|
31
|
+
tagOrder: ["valence", "arousal"],
|
|
32
|
+
model: null,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
async function initModel(name) {
|
|
37
|
+
classifiers[name].model = await tf.loadGraphModel(getModelURL(name));
|
|
38
|
+
classifiers[name].isLoaded = true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function getModelURL(modelName) {
|
|
42
|
+
return `../models/${modelName}-msd-musicnn-1/tfjs/model.json`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function arrayToTensorAsBatches(embeddingsArray, patchSize) {
|
|
46
|
+
let inputTensor = tf.tensor2d(embeddingsArray, [embeddingsArray.length, patchSize]);
|
|
47
|
+
return inputTensor;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function initTensorflowWASM() {
|
|
51
|
+
let defaultBackend;
|
|
52
|
+
tf.ready().then(() => {
|
|
53
|
+
defaultBackend = tf.getBackend();
|
|
54
|
+
for (let n of Object.keys(classifiers)) {
|
|
55
|
+
initModel(n);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
if (defaultBackend != "wasm") {
|
|
60
|
+
return;
|
|
61
|
+
importScripts("./lib/tf-backend-wasm-3.5.0.js");
|
|
62
|
+
// importScripts('https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm/dist/tf-backend-wasm.js');
|
|
63
|
+
tf.setBackend("wasm");
|
|
64
|
+
tf.ready()
|
|
65
|
+
.then(() => {
|
|
66
|
+
initModel();
|
|
67
|
+
})
|
|
68
|
+
.catch(() => {
|
|
69
|
+
return false;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function twoValuesAverage(arrayOfArrays) {
|
|
75
|
+
const length = arrayOfArrays.length;
|
|
76
|
+
if (length === 0) return [0, 0];
|
|
77
|
+
|
|
78
|
+
const [firstValuesSum, secondValuesSum] = arrayOfArrays.reduce(
|
|
79
|
+
([firstAcc, secondAcc], [firstVal, secondVal]) => [firstAcc + firstVal, secondAcc + secondVal],
|
|
80
|
+
[0, 0]
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
return [firstValuesSum / length, secondValuesSum / length];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function outputPredictions(p) {
|
|
87
|
+
postMessage({
|
|
88
|
+
predictions: p,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function modelsPredict(embeddings) {
|
|
93
|
+
const inferenceStart = Date.now();
|
|
94
|
+
let inputTensor = arrayToTensorAsBatches(embeddings, 200);
|
|
95
|
+
const emomusicInputTensor = tf.tensor3d(
|
|
96
|
+
embeddings.map((e) => [e]),
|
|
97
|
+
[embeddings.length, 1, 200]
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
let predictions = {};
|
|
101
|
+
|
|
102
|
+
for (let name of Object.keys(classifiers)) {
|
|
103
|
+
if (classifiers[name].isLoaded) {
|
|
104
|
+
let output;
|
|
105
|
+
if (name == "emomusic") {
|
|
106
|
+
output = classifiers[name].model.execute(emomusicInputTensor);
|
|
107
|
+
} else {
|
|
108
|
+
output = classifiers[name].model.execute(inputTensor);
|
|
109
|
+
}
|
|
110
|
+
let outputArray = output.arraySync();
|
|
111
|
+
|
|
112
|
+
const summarizedPredictions = twoValuesAverage(outputArray);
|
|
113
|
+
// format predictions, grab only positive one
|
|
114
|
+
if (name == "emomusic") {
|
|
115
|
+
predictions[name] = {
|
|
116
|
+
[classifiers[name]["tagOrder"][0]]: summarizedPredictions[0],
|
|
117
|
+
[classifiers[name]["tagOrder"][1]]: summarizedPredictions[1],
|
|
118
|
+
};
|
|
119
|
+
} else {
|
|
120
|
+
const result = summarizedPredictions.filter((_, i) => classifiers[name].tagOrder[i])[0];
|
|
121
|
+
predictions[name] = result;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
outputPredictions(predictions);
|
|
126
|
+
inputTensor.dispose();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
initTensorflowWASM();
|
|
130
|
+
|
|
131
|
+
onmessage = function listenToMainThread(msg) {
|
|
132
|
+
if (msg.data.embeddings) {
|
|
133
|
+
modelsPredict(msg.data.embeddings);
|
|
134
|
+
}
|
|
135
|
+
};
|