Adding custom properties to model.json upon save?
See original GitHub issueHello! I’m writing on behalf of the ml5 project. In a meeting today with @cvalenzuela and other contributors we discussed some questions around the saving and loading features for ml5. This is discussed in more detail at https://github.com/ml5js/ml5-library/issues/174.
We are wrapping the tf.js save()
method in our ImageClassifier class for use with the FeatureExtractor example. model.json
and model.weights.bin
work “out of the box” with ml5, however our examples include additional functionality. For example, we allow the end user to specify a string label for a class rather than a numeric index. To be able to retain this information when saving, we would like to be able to customize model.json
with ml5 specific properties.
What do you think about adding an optional argument to save()
that allows for customization, e.g.
const ml5prop = {
labels: ['cat', 'dog']
};
model.save(destination, ml5prop);
This could be good for other use cases where tf.js users have other meta-data they would like to include.
Let us know your thoughts. We are happy to work on a pull request for this. Or perhaps you have a better idea for how we should be handling saving/loading on our end?
@cvalenzuela let me know if I missed anything or am not describing this properly!
Issue Analytics
- State:
- Created 5 years ago
- Comments:17 (4 by maintainers)
Top GitHub Comments
I think this is a reasonable feature request.
weightSpecs are a subset of weightsManifest that don’t contain the paths. weightsSpecs are of type
WeightsManifestEntry
, here is the corresponding entry in the weights manifest: https://github.com/tensorflow/tfjs-core/blob/master/src/io/types.ts#L59You can just kick off a download using a Blob, createObjectURL and forcing a link (google how to trigger file download from JS).