MCPcopy
hub / github.com/tensorflow/tfjs-examples / showResults

Function showResults

mobilenet/index.js:134–163  ·  view source on GitHub ↗
(imgElement, classes)

Source from the content-addressed store, hash-verified

132//
133
134function showResults(imgElement, classes) {
135 const predictionContainer = document.createElement('div');
136 predictionContainer.className = 'pred-container';
137
138 const imgContainer = document.createElement('div');
139 imgContainer.appendChild(imgElement);
140 predictionContainer.appendChild(imgContainer);
141
142 const probsContainer = document.createElement('div');
143 for (let i = 0; i < classes.length; i++) {
144 const row = document.createElement('div');
145 row.className = 'row';
146
147 const classElement = document.createElement('div');
148 classElement.className = 'cell';
149 classElement.innerText = classes[i].className;
150 row.appendChild(classElement);
151
152 const probsElement = document.createElement('div');
153 probsElement.className = 'cell';
154 probsElement.innerText = classes[i].probability.toFixed(3);
155 row.appendChild(probsElement);
156
157 probsContainer.appendChild(row);
158 }
159 predictionContainer.appendChild(probsContainer);
160
161 predictionsElement.insertBefore(
162 predictionContainer, predictionsElement.firstChild);
163}
164
165const filesElement = document.getElementById('files');
166filesElement.addEventListener('change', evt => {

Callers 1

predictFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected