MCPcopy Index your code
hub / github.com/tensorflow/tfjs-examples / getImage

Function getImage

webcam-transfer-learning/index.js:159–165  ·  view source on GitHub ↗

* Captures a frame from the webcam and normalizes it between -1 and 1. * Returns a batched image (1-element batch) of shape [1, w, h, c].

()

Source from the content-addressed store, hash-verified

157 * Returns a batched image (1-element batch) of shape [1, w, h, c].
158 */
159async function getImage() {
160 const img = await webcam.capture();
161 const processedImg =
162 tf.tidy(() => img.expandDims(0).toFloat().div(127).sub(1));
163 img.dispose();
164 return processedImg;
165}
166
167document.getElementById('train').addEventListener('click', async () => {
168 ui.trainStatus('Training...');

Callers 2

index.jsFile · 0.85
predictFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected