MCPcopy Index your code
hub / github.com/tensorflow/tfjs / loadJSONModel

Method loadJSONModel

tfjs-node/src/io/file_system.ts:166–182  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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,

Callers 1

loadMethod · 0.95

Calls 2

loadWeightsMethod · 0.95
doesNotExistHandlerFunction · 0.85

Tested by

no test coverage detected