Ml5-library: Import / export model retrained using featureExtractor

Created on 4 Jul 2018  路  18Comments  路  Source: ml5js/ml5-library

Nice project!
I was wondering, is it possible to export a MobileNet model which has been retrained with the featureExtractor class?
It would be great to be able to import a retrained MobileNet classifier as JSON for example!

Do you have plans to support other models next to MobileNet? I'm experimenting with object detection / semantic segmentation using tensorflow.js. Are there guidelines or documentation on how to port other models to work with ml5js? I'm aware that the project is still in development, i'd love to contribute!

enhancement

Most helpful comment

Will be implemented soon!

All 18 comments

Yes, we want to support export/import of custom models. This is something that hopefully will get implemented in the short term. We will probably need to wrap tf.model.save (https://js.tensorflow.org/api/0.11.7/#tf.Model.save)

And we also want to support more models! There are no current guides on how to port new models to ml5 but it is something we can work together in a PR if you would like to contribute.

Thanks for your reply, import/export and custom model support would be useful!馃
I'm trying to port a Quick Draw-like RNN to tensorflow.js, the plan is to make it work with ml5 (looking at https://github.com/ml5js/ml5-library/blob/master/src/YOLO/index.js).
If i can get it to work i'll do a write-up of the necessary steps.

You should check this thread: https://github.com/ml5js/ml5-library/issues/11

+1 for the requested save/load feature.
I need this for a project I'm working on:)

I've written down my steps of retraining a MobileNet model for the web. It's based on the TensorFlow for Poets guide, and describes how to use a retrained model in the browser with TensorFlow.js.

https://gist.github.com/woudsma/d01eeda8998c9ab972d05ec9e9843886

No time yet to look on how to easily use such a model with ml5js unfortunately. Any thoughts?
And is it even possible to retrain a (quantized) retrained model using featureExtractor?

I am looking for the import-export model feature aswell

Will be implemented soon!

I too am looking forward to seeing this feature added!

I'd like to update my example (transfer learning w/ data augmentation) once the feature is added. :wink:

https://codepen.io/kotobuki/pen/ZMKEWo

I created examples to illustrate ways of saving/loading custom models for a workshop and worked as expected. Thank you very much! :blush:

@kotobuki
classifier.load(evt.target.files, () => {
console.log("hello");
status.html("Loaded");
});
This is not working in codepen in google chrome and so i am not being able to load the saved model files. The status never shows "Loaded". Am i doing something wrong? Please help. Wonderful job by the way!

@davenep
I was about to file an issue regarding this problem. For me, the status never shows "Loaded," but the model seems to be loaded. FYR, I uploaded saved model files at https://www.dropbox.com/s/5t586w83ni05ddt/saved_model.zip?dl=0

@kotobuki
Also I get error "classifier.save is not a function" and "classifier.load in not a function" when i run the file in my local server..however classifier.save seems to be working in codepen and i am able to save the files..am i missing something? any way to make this work in my local server?

@davenep
Are you using v0.1.1? For the examples on CodePen, I refer to the latest version (i.e. f471eec18b7b64347b355ced8bc40604827924b3 ) via jsDelivr as follows:

https://cdn.jsdelivr.net/gh/ml5js/ml5-library@f471eec18b7b64347b355ced8bc40604827924b3/dist/ml5.min.js

@kotobuki My bad! Thank you so much. It works perfectly. Any way to automatically load the model files from local drive when the browser loads without having to choose via a button? Thank you again :)

@kotobuki hi. i was trying your codepen examples and i am a bit puzzled by what to expect. i tried with two classes (5 images for each) and it worked fine. but saved and then loaded model outputs only 0 or 1 as class - is that how it should be?
then i tried anew with 3 classes, again 5 pics for each, but when testing (without save&loading of model) i never got the class from images uploaded as last ones, even when i tested on image it was trained on. is this example/model able to handle more than two classes?

update: digging further, i found this and the solution here too https://github.com/ml5js/ml5-library/issues/164

I am not able to use the classifier.save(); capability, it is throwing errors stating that it is not a defined function. In addition, I am unable to classify three different objects.
image

Hi All! This is now resolved in the latest version of ml5. Closing this now. Thanks!

Was this page helpful?
0 / 5 - 0 ratings