| 277 | } |
| 278 | |
| 279 | private checkMapInputs( |
| 280 | inputTensorNames: string[], modelInputNames: string[]) { |
| 281 | const notInModel = |
| 282 | inputTensorNames.filter(name => !modelInputNames.includes(name)); |
| 283 | const notInInput = |
| 284 | modelInputNames.filter(name => !inputTensorNames.includes(name)); |
| 285 | if (notInModel.length === 0 && notInInput.length === 0) { |
| 286 | return; |
| 287 | } |
| 288 | |
| 289 | const msgParts = |
| 290 | ['The model input names don\'t match the model input names.']; |
| 291 | if (notInModel.length > 0) { |
| 292 | msgParts.push(`Names in input but missing in model: [${notInModel}].`); |
| 293 | } |
| 294 | if (notInInput.length > 0) { |
| 295 | msgParts.push(`Names in model but missing in inputs: [${notInInput}].`); |
| 296 | } |
| 297 | throw new Error(msgParts.join(' ')); |
| 298 | } |
| 299 | |
| 300 | private getShapeFromTFLiteTensorInfo(info: TFLiteWebModelRunnerTensorInfo) { |
| 301 | return info.shape.split(',').map(s => Number(s)); |