()
| 164 | } |
| 165 | |
| 166 | protected async loadJSONModel(): Promise<tf.io.ModelArtifacts> { |
| 167 | const path = this.path as string; |
| 168 | const info = await stat(path).catch(doesNotExistHandler('Path')); |
| 169 | |
| 170 | // `path` can be either a directory or a file. If it is a file, assume |
| 171 | // it is model.json file. |
| 172 | if (info.isFile()) { |
| 173 | const modelJSON = JSON.parse(await readFile(path, 'utf8')); |
| 174 | return tf.io.getModelArtifactsForJSON( |
| 175 | modelJSON, |
| 176 | (weightsManifest) => this.loadWeights(weightsManifest, path)); |
| 177 | } else { |
| 178 | throw new Error( |
| 179 | 'The path to load from must be a file. Loading from a directory ' + |
| 180 | 'is not supported.'); |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | private async loadWeights( |
| 185 | weightsManifest: tf.io.WeightsManifestConfig, |
no test coverage detected