MCPcopy
hub / github.com/tensorflow/tfjs / start

Function start

tfjs-tflite/demo/src/script.ts:30–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28 'https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-tflite@0.0.1-alpha.8/dist/');
29
30async function start() {
31 // Load model runner with the cartoonizer tflite model.
32 const start = Date.now();
33 const tfliteModel = await tflite.loadTFLiteModel(
34 'https://tfhub.dev/sayakpaul/lite-model/cartoongan/fp16/1',
35 );
36 ele('.loading-msg').innerHTML = `Loaded WASM module and <a href='${
37 CARTOONIZER_LINK}' target='blank'>TFLite model</a> in ${
38 Date.now() - start}ms`;
39 eles('.trigger').forEach(ele => {
40 ele.classList.add('show');
41 });
42 removeClass('.imgs-container', 'hide');
43
44 // Setup cam.
45 setupCam();
46
47 // Setup the magic wand buttons. Click it will cartoonize the
48 // corresponding picture.
49 eles('.trigger').forEach(ele => {
50 ele.addEventListener('click', (event) => {
51 const trigger = event.target! as HTMLElement;
52 trigger.classList.add('processing');
53 trigger.innerHTML = 'Processing...';
54
55 setTimeout(() => {
56 handleClickTrigger(trigger, tfliteModel);
57 trigger.classList.add('hide');
58 });
59 });
60 });
61
62 // Click cam's result picture to take another picture.
63 ele('#cam-canvas').addEventListener('click', (event) => {
64 handleClickTrigger(event.target as HTMLElement, tfliteModel);
65 });
66}
67
68async function setupCam() {
69 const constraints = {

Callers 2

script.tsFile · 0.85
scopedRunMethod · 0.85

Calls 7

eleFunction · 0.85
elesFunction · 0.85
removeClassFunction · 0.85
setupCamFunction · 0.85
handleClickTriggerFunction · 0.85
nowMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…