Skip to content

Instantly share code, notes, and snippets.

@Marina-Miranovich
Created November 14, 2018 21:06
Show Gist options
  • Save Marina-Miranovich/fd9e0cd349a37c56c8effa517adc4643 to your computer and use it in GitHub Desktop.
Save Marina-Miranovich/fd9e0cd349a37c56c8effa517adc4643 to your computer and use it in GitHub Desktop.
code_snippet_13 for "Playing Mortal Kombat with TensorFlow.js. Transfer learning and data augmentation" translation
const [punch, kick, nothing] = Array.from((model.predict(
mobilenet(tf.fromPixels(scaled))
) as tf.Tensor1D).dataSync() as Float32Array);
const detect = (window as any).Detect;
if (nothing >= 0.4) return;
if (kick > punch && kick >= 0.35) {
detect.onKick();
return;
}
if (punch > kick && punch >= 0.35) detect.onPunch();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment