| 132 | // |
| 133 | |
| 134 | function 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 | |
| 165 | const filesElement = document.getElementById('files'); |
| 166 | filesElement.addEventListener('change', evt => { |