Skip to content

Commit

Permalink
Merge pull request #2721 from entrylabs/develop
Browse files Browse the repository at this point in the history
Master
  • Loading branch information
leunge authored Apr 26, 2024
2 parents 0eabf0d + 9db80ef commit 9502aea
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 50 deletions.
26 changes: 1 addition & 25 deletions src/class/learning/ImageLearning.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,31 +141,7 @@ class ImageLearning {
}

async load(url) {
const model = await tf.loadLayersModel(url);
const modelData = new Promise((resolve) =>
model.save({
save: (data) => {
const layers = data?.modelTopology?.config?.layers;
if (Array.isArray(layers)) {
data.modelTopology.config.layers.forEach((layer) => {
if (layer?.config?.name) {
layer.config.name = `${layer.config.name}_ws`;
}
});
}
if (Array.isArray(data.weightSpecs)) {
data.weightSpecs.forEach((spec) => {
const splits = spec.name.split('/');
splits[0] = `${splits[0]}_ws`;
spec.name = splits.join('/');
});
}
resolve(data);
},
})
);
this.model = await tf.loadLayersModel({ load: () => modelData });
model.dispose();
this.model = await tf.loadLayersModel(url);
this.isLoaded = true;
}
}
Expand Down
26 changes: 1 addition & 25 deletions src/class/learning/SpeechClassification.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,31 +69,7 @@ class Classification {
}

async load(url) {
const model = await tf.loadLayersModel(url);
const modelData = new Promise((resolve) =>
model.save({
save: (data) => {
const layers = data?.modelTopology?.config?.layers;
if (Array.isArray(layers)) {
data.modelTopology.config.layers.forEach((layer) => {
if (layer?.config?.name) {
layer.config.name = `${layer.config.name}_ws`;
}
});
}
if (Array.isArray(data.weightSpecs)) {
data.weightSpecs.forEach((spec) => {
const splits = spec.name.split('/');
splits[0] = `${splits[0]}_ws`;
spec.name = splits.join('/');
});
}
resolve(data);
},
})
);
this.model = await tf.loadLayersModel({ load: () => modelData });
model.dispose();
this.model = await tf.loadLayersModel(url);
}
}

Expand Down

0 comments on commit 9502aea

Please sign in to comment.