mirror of
https://github.com/hexahigh/games.git
synced 2025-12-11 20:15:38 +01:00
Compare commits
2 Commits
d7f95cdcea
...
f9460828bb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9460828bb | ||
|
|
7783cb4e31 |
15
other/tensor/test1/index.html
Normal file
15
other/tensor/test1/index.html
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Audio Classification</title>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@2.8.4/dist/tf.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/speech-commands@0.4.0/dist/speech-commands.min.js"></script>
|
||||
<script src="script.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<div>Audio Model</div>
|
||||
<button type="button" onclick="init()">Start</button>
|
||||
<div id="label-container"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
BIN
other/tensor/test1/model/group1-shard1of6.bin
Normal file
BIN
other/tensor/test1/model/group1-shard1of6.bin
Normal file
Binary file not shown.
BIN
other/tensor/test1/model/group1-shard2of6.bin
Normal file
BIN
other/tensor/test1/model/group1-shard2of6.bin
Normal file
Binary file not shown.
BIN
other/tensor/test1/model/group1-shard3of6.bin
Normal file
BIN
other/tensor/test1/model/group1-shard3of6.bin
Normal file
Binary file not shown.
BIN
other/tensor/test1/model/group1-shard4of6.bin
Normal file
BIN
other/tensor/test1/model/group1-shard4of6.bin
Normal file
Binary file not shown.
BIN
other/tensor/test1/model/group1-shard5of6.bin
Normal file
BIN
other/tensor/test1/model/group1-shard5of6.bin
Normal file
Binary file not shown.
BIN
other/tensor/test1/model/group1-shard6of6.bin
Normal file
BIN
other/tensor/test1/model/group1-shard6of6.bin
Normal file
Binary file not shown.
1
other/tensor/test1/model/model.json
Normal file
1
other/tensor/test1/model/model.json
Normal file
@ -0,0 +1 @@
|
||||
{"format": "layers-model", "generatedBy": "keras v2.13.1", "convertedBy": "TensorFlow.js Converter v4.10.0", "modelTopology": {"keras_version": "2.13.1", "backend": "tensorflow", "model_config": {"class_name": "Sequential", "config": {"name": "sequential", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": [null, 128, 87, 1], "dtype": "float32", "sparse": false, "ragged": false, "name": "conv2d_input"}}, {"class_name": "Conv2D", "config": {"name": "conv2d", "trainable": true, "dtype": "float32", "batch_input_shape": [null, 128, 87, 1], "filters": 32, "kernel_size": [3, 3], "strides": [1, 1], "padding": "valid", "data_format": "channels_last", "dilation_rate": [1, 1], "groups": 1, "activation": "relu", "use_bias": true, "kernel_initializer": {"module": "keras.initializers", "class_name": "GlorotUniform", "config": {"seed": null}, "registered_name": null}, "bias_initializer": {"module": "keras.initializers", "class_name": "Zeros", "config": {}, "registered_name": null}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "MaxPooling2D", "config": {"name": "max_pooling2d", "trainable": true, "dtype": "float32", "pool_size": [2, 2], "padding": "valid", "strides": [2, 2], "data_format": "channels_last"}}, {"class_name": "Dropout", "config": {"name": "dropout", "trainable": true, "dtype": "float32", "rate": 0.25, "noise_shape": null, "seed": null}}, {"class_name": "Flatten", "config": {"name": "flatten", "trainable": true, "dtype": "float32", "data_format": "channels_last"}}, {"class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 64, "activation": "relu", "use_bias": true, "kernel_initializer": {"module": "keras.initializers", "class_name": "GlorotUniform", "config": {"seed": null}, "registered_name": null}, "bias_initializer": {"module": "keras.initializers", "class_name": "Zeros", "config": {}, "registered_name": null}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Dense", "config": {"name": "dense_1", "trainable": true, "dtype": "float32", "units": 2, "activation": "softmax", "use_bias": true, "kernel_initializer": {"module": "keras.initializers", "class_name": "GlorotUniform", "config": {"seed": null}, "registered_name": null}, "bias_initializer": {"module": "keras.initializers", "class_name": "Zeros", "config": {}, "registered_name": null}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}]}}, "training_config": {"loss": "sparse_categorical_crossentropy", "metrics": [[{"class_name": "MeanMetricWrapper", "config": {"name": "accuracy", "dtype": "float32", "fn": "sparse_categorical_accuracy"}}]], "weighted_metrics": null, "loss_weights": null, "optimizer_config": {"class_name": "Custom>Adam", "config": {"name": "Adam", "weight_decay": null, "clipnorm": null, "global_clipnorm": null, "clipvalue": null, "use_ema": false, "ema_momentum": 0.99, "ema_overwrite_frequency": null, "jit_compile": false, "is_legacy_optimizer": false, "learning_rate": 0.0010000000474974513, "beta_1": 0.9, "beta_2": 0.999, "epsilon": 1e-07, "amsgrad": false}}}}, "weightsManifest": [{"paths": ["group1-shard1of6.bin", "group1-shard2of6.bin", "group1-shard3of6.bin", "group1-shard4of6.bin", "group1-shard5of6.bin", "group1-shard6of6.bin"], "weights": [{"name": "conv2d/kernel", "shape": [3, 3, 1, 32], "dtype": "float32"}, {"name": "conv2d/bias", "shape": [32], "dtype": "float32"}, {"name": "dense/kernel", "shape": [84672, 64], "dtype": "float32"}, {"name": "dense/bias", "shape": [64], "dtype": "float32"}, {"name": "dense_1/kernel", "shape": [64, 2], "dtype": "float32"}, {"name": "dense_1/bias", "shape": [2], "dtype": "float32"}]}]}
|
||||
50
other/tensor/test1/script.js
Normal file
50
other/tensor/test1/script.js
Normal file
@ -0,0 +1,50 @@
|
||||
// more documentation available at
|
||||
// https://github.com/tensorflow/tfjs-models/tree/master/speech-commands
|
||||
|
||||
// the link to your model provided by Teachable Machine export panel
|
||||
const URL = "./model/";
|
||||
|
||||
async function createModel() {
|
||||
const checkpointURL = URL + "model.json"; // model topology
|
||||
const metadataURL = URL + "metadata.json"; // model metadata
|
||||
|
||||
const recognizer = speechCommands.create(
|
||||
"BROWSER_FFT", // fourier transform type, not useful to change
|
||||
undefined, // speech commands vocabulary feature, not useful for your models
|
||||
checkpointURL,
|
||||
metadataURL);
|
||||
|
||||
// check that model and metadata are loaded via HTTPS requests.
|
||||
await recognizer.ensureModelLoaded();
|
||||
|
||||
return recognizer;
|
||||
}
|
||||
|
||||
async function init() {
|
||||
const recognizer = await createModel();
|
||||
const classLabels = recognizer.wordLabels(); // get class labels
|
||||
const labelContainer = document.getElementById("label-container");
|
||||
for (let i = 0; i < classLabels.length; i++) {
|
||||
labelContainer.appendChild(document.createElement("div"));
|
||||
}
|
||||
|
||||
// listen() takes two arguments:
|
||||
// 1. A callback function that is invoked anytime a word is recognized.
|
||||
// 2. A configuration object with adjustable fields
|
||||
recognizer.listen(result => {
|
||||
const scores = result.scores; // probability of prediction for each class
|
||||
// render the probability scores per class
|
||||
for (let i = 0; i < classLabels.length; i++) {
|
||||
const classPrediction = classLabels[i] + ": " + result.scores[i].toFixed(2);
|
||||
labelContainer.childNodes[i].innerHTML = classPrediction;
|
||||
}
|
||||
}, {
|
||||
includeSpectrogram: true, // in case listen should return result.spectrogram
|
||||
probabilityThreshold: 0.75,
|
||||
invokeCallbackOnNoiseAndUnknown: true,
|
||||
overlapFactor: 0.50 // probably want between 0.5 and 0.75. More info in README
|
||||
});
|
||||
|
||||
// Stop the recognition in 5 seconds.
|
||||
// setTimeout(() => recognizer.stopListening(), 5000);
|
||||
}
|
||||
10
site.torrent
10
site.torrent
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user