| 28 | let tf; |
| 29 | |
| 30 | function parseArgs() { |
| 31 | const parser = new argparse.ArgumentParser({ |
| 32 | description: |
| 33 | 'TensorFlow.js Quantization Example: Evaluating an MNIST Model', |
| 34 | addHelp: true |
| 35 | }); |
| 36 | parser.addArgument('modelSavePath', { |
| 37 | type: 'string', |
| 38 | help: 'Path at which the model to be evaluated is saved.' |
| 39 | }); |
| 40 | parser.addArgument('imageDir', { |
| 41 | type: 'string', |
| 42 | help: 'Path at the directory under which the test images are stored.' |
| 43 | }); |
| 44 | parser.addArgument('--gpu', { |
| 45 | action: 'storeTrue', |
| 46 | help: 'Use tfjs-node-gpu for evaluation (requires CUDA-enabled ' + |
| 47 | 'GPU and supporting drivers and libraries.' |
| 48 | }); |
| 49 | return parser.parseArgs(); |
| 50 | } |
| 51 | |
| 52 | async function readImageTensorFromFile(filePath, height, width) { |
| 53 | return new Promise((resolve, reject) => { |