tensorflow / tfjs

A WebGL accelerated JavaScript library for training and deploying ML models.
https://js.tensorflow.org
Apache License 2.0
18.49k stars 1.93k forks source link

Feature Request: More well trained model.json files on googleapis storage, organized somehow #706

Closed hpssjellis closed 6 years ago

hpssjellis commented 6 years ago

Presently googleapis https://storage.googleapis.com/tfjs-models/ has several frozen and regular models saved.

Is there a webpage somewhere that shows information about the models such as training accuracy, input and output shape etc?

I made a codepen that helps with some of that information here

I think lots of JavaScript programmers would benefit from more, highly accurate pre-trained regular (not frozen) models to have access to. I find my desktop computer is not powerful enough to train larger models, but if someone else could train them I could definitely work with them.

Just requesting the normal batch of models: mnist, cifar, vgg, mobilnet, squeezenet, etc, etc.

hpssjellis commented 6 years ago

So I answered the first part of my question:

Is there a webpage somewhere that shows information about the models such as training accuracy, input and output shape etc?

The place to look is: TensorflowHub

but as far as I can tell these models can only be converted to web friendly frozen format by the converter. As far as I know this format can't be edited, retrained or changed in any way.

Can someone ( perhaps @caisq or @nsthorat ) respond about if there is a reasonably easy way to convert these TensorflowHub models to "SavedModel" TFJS format?

nsthorat commented 6 years ago

Have you seen our models repo?

https://github.com/tensorflow/tfjs-models

These are where we'll store already converted models.

TensorFlow hub models can be converted with the converter, the instructions are in the readme of https://github.com/tensorflow/tfjs-converter

On Sat, Sep 22, 2018 at 8:56 PM Jeremy Ellis notifications@github.com wrote:

So I answered the first part of my question:

Is there a webpage somewhere that shows information about the models such as training accuracy, input and output shape etc?

The place to look is: TensorflowHub https://www.tensorflow.org/hub/

but as far as I can tell these models can only be converted to web friendly frozen format by the converter https://github.com/tensorflow/tfjs-converter. As far as I know this format can't be edited, retrained or changed in any way.

Can someone ( perhaps @caisq https://github.com/caisq or @nsthorat https://github.com/nsthorat ) respond about if there is a reasonably easy way to convert these TensorflowHub models to "SavedModel" TFJS format?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tensorflow/tfjs/issues/706#issuecomment-423783762, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDLzY_t2NrUvXVT-R1GA5rwGBQzBQeDks5udtxJgaJpZM4WusXX .

hpssjellis commented 6 years ago

Thanks for replying @nsthorat as far as I know the converter only makes frozen models with the .pb file extensions. I want savedModels with the .JSON extension so that I can work with them.

https://github.com/tensorflow/tfjs-models has no saved models for others to use, but it does have a few models referenced on googleapis

So I made a codepen to find out information about saved models on googleapis. I found about 6 models, but could not find much more information about them.

I guess what I could do is fork tfjs-models and save my own versions, but my computers are not powerful enough to make really good models. It would be really useful if I could use other peoples models.

nsthorat commented 6 years ago

The JSON files only come from Keras models. SavedModels become pb files (this is actually something I want to change, but we're not there yet). @pyu10055

The tfjs-models code are all hosted there, weights are all on GCP because we don't want to bloat the repository.

hpssjellis commented 6 years ago

@nsthorat am I correct that you can't retrain the pb files? I can't even run model.summary() with a pb file.

That is why I really like the savedModels because they give flexibility.

I also feel that a Tensorflow model could be converted into a SavedModel, since you have the shard files and weights manifest. You are just missing the model definition, which I assume the pb file has in some mixed text and binary format.

nsthorat commented 6 years ago

Correct, you cannot retrain frozen models (the ones converted from TensorFlow SavedModels and are shipped as pbs). For naming purposes, "SavedModels" are a TensorFlow python concept, there is no "Saved Model" in TensorFlow.js. If you define a model with the layers API, you will save it in the layers format (which is identical to the keras format).

I agree, the keras format is really nice because of the flexibility. It's a deep technical reason why we can't retrain the pb files, but we might try to work on that in the future.

You are right, the pb file contains the graph, which is analogous the keras / layers model.json file.

hpssjellis commented 6 years ago

Thanks for the clarification @nsthorat. I am now working with the tfjs-models on cloud9 and have most of them working.

These npm webpages have been very useful

https://www.npmjs.com/package/@tensorflow-models/posenet

https://www.npmjs.com/package/@tensorflow-models/mobilenet

https://www.npmjs.com/package/@tensorflow-models/knn-classifier

Not sure why I can't find npm sites for "coco-ssd" or "speech-commands" but will keep looking.

hpssjellis commented 6 years ago

I think I can close this issue, unless you want to keep it open. My problems with the saved files at https://storage.googleapis.com/tfjs-models/ were my own issues with pixel normalization. All is good now.

My demo works fine now.

A summary page for the above googleapis would still be nice but not fully needed.