You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The models are loaded from the file system using a custom sync loader (code below)
We are using the pure-JS (browser) version of tfjs in a nodeJS server (we cannot use the nodeJS version due to incompatibilities with our linux distro)
The two models have many overlapping input names
Describe the expected behavior
Running predictions should work for multiple models loaded from files.
Standalone code to reproduce the issue
export class TFDFFileSystemLoadHandlerSync {
static loadModel(path: string): tf.io.ModelArtifacts {
const modelPath = join(path, 'model.json');
try {
const info = statSync(modelPath);
// `path` can be either a directory or a file. If it is a file, assume
// it is model.json file.
if (info.isFile()) {
const modelJSON = JSON.parse(readFileSync(modelPath, 'utf8'));
const [weightsManifest, weightData] = this.loadWeights(modelJSON.weightsManifest, modelPath);
return tf.io.getModelArtifactsForJSONSync(modelJSON, weightsManifest, weightData);
} else {
throw new Error('The path to load from must be a file. Loading from a directory ' + 'is not supported.');
}
} catch (e) {
doesNotExistHandler('Path')(e as NodeJS.ErrnoException);
// This line is never reached. It is added to pacify the TypeScript compiler.
return {} as tf.io.ModelArtifacts;
}
}
static loadAssets(path: string): Blob {
const assetsPath = join(path, 'assets.zip');
const buffer = readFileSync(assetsPath);
return toArrayBuffer(buffer) as unknown as Blob;
}
static loadWeights(
weightsManifest: tf.io.WeightsManifestConfig,
path: string
): [tf.io.WeightsManifestEntry[], ArrayBuffer] {
const dirName = dirname(path);
const buffers: Buffer[] = [];
const weightSpecs: tf.io.WeightsManifestEntry[] = [];
for (const group of weightsManifest) {
for (const path of group.paths) {
const weightFilePath = join(dirName, path);
try {
const buffer = readFileSync(weightFilePath);
buffers.push(buffer);
} catch (e) {
doesNotExistHandler('Weight file')(e as NodeJS.ErrnoException);
}
}
weightSpecs.push(...group.weights);
}
return [weightSpecs, toArrayBuffer(buffers)];
}
}
I apologize for the delayed response and thank you for bringing this issue to our attention, if possible could you please help us with your Github repo along with converted TensorFlow.js models and complete steps to replicate the same behavior from our end to investigate this issue further from our end ?
System information
Describe the current behavior
Loading two decision forest models (trained in Python and converted) yields the following error when calling
model.executeAsync
:Describe the expected behavior
Running predictions should work for multiple models loaded from files.
Standalone code to reproduce the issue
Loading model:
The text was updated successfully, but these errors were encountered: