Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: tensorflow.js support #2233

Open
beriberikix opened this issue Jul 6, 2019 · 13 comments
Open

Feature Request: tensorflow.js support #2233

beriberikix opened this issue Jul 6, 2019 · 13 comments

Comments

@beriberikix
Copy link

@beriberikix beriberikix commented Jul 6, 2019

Has the team looked into supporting Tensorflow.js? There is a tool and documentation to convert existing models to be compatible with the format needed by tfjs. I have use case that would benefit from running wav transcription example in the browser.

Note: I filed a similar feature request on tfjs project.

@lissyx

This comment has been minimized.

Copy link
Collaborator

@lissyx lissyx commented Jul 6, 2019

Nothing stops you from experimenting. But we have not had time to try that.

@lissyx

This comment has been minimized.

Copy link
Collaborator

@lissyx lissyx commented Jul 6, 2019

To be honest I fear we won't get any decent perfs with that, given the experiments without vectorization we could perform.

@beriberikix

This comment has been minimized.

Copy link
Author

@beriberikix beriberikix commented Jul 6, 2019

Understood, I hope to experiment and report back!

I watched a recent talk by two leads and I'm optimistic, at least of the future perf. Today they're using WebGL to get better speed than vanilla JS and in the future they'll be looking into WebAssembly with Threads and SIMD.

@lissyx

This comment has been minimized.

Copy link
Collaborator

@lissyx lissyx commented Jul 6, 2019

Yeah, threads and SIMD that's still a long way, according to a colleague working on that and wasm. Still curious about what you can get.

@lissyx

This comment has been minimized.

Copy link
Collaborator

@lissyx lissyx commented Jul 8, 2019

FTR @beriberikix I don't know if the TF.js converter has the same constraints as the one for leveraging EdgeTPU, but we cannot (yet) convert our model for running on EdgeTPU. It's not impossible they may share constraints.

@sdll sdll mentioned this issue Jul 15, 2019
2 of 20 tasks complete
@beriberikix

This comment has been minimized.

Copy link
Author

@beriberikix beriberikix commented Jul 18, 2019

I'm trying to convert deepspeech-0.5.1-models.tar.gz using tensorflow/tfjs-converter but I'm running into an issue (probably because I've never used the tool before!)

SavedModel file does not exist at: 
./deepspeech-0.5.1-models/output_graph.pb/{saved_model.pbtxt|saved_model.pb}

Do you know which, if any, signatures and/or tags were used in generating the SavedModel? Per the help output:

--signature_name SIGNATURE_NAME
                        Signature of the SavedModel Graph or TF-Hub module to
                        load. Applicable only if input format is "tf_hub" or
                        "tf_saved_model".
  --saved_model_tags SAVED_MODEL_TAGS
                        Tags of the MetaGraphDef to load, in comma separated
                        string format. Defaults to "serve". Applicable only if
                        input format is "tf_saved_model".
@lissyx

This comment has been minimized.

Copy link
Collaborator

@lissyx lissyx commented Jul 18, 2019

You should have a look at the export function, maybe some parameters needs to be adjusted?

@sdll

This comment has been minimized.

Copy link

@sdll sdll commented Jul 18, 2019

@beriberikix, seems like the converter looks for saved_model.pb, but the graph is saved in output_graph.pb instead, so you might need to just rename this file. Other than that, here is a working example of how to convert SavedModel. The options

  --signature_name=serving_default \
  --saved_model_tags=serve

are merely default settings, so you might skip setting them if the model was saved without altering them.

@beriberikix

This comment has been minimized.

Copy link
Author

@beriberikix beriberikix commented Jul 18, 2019

Ah, I tried something else. Looking at the export function I noticed it was saved as a frozen model, which the latest converter no longer supports:

Note: Session bundle and Frozen model formats have been deprecated in TensorFlow.js 1.0. Please use the TensorFlow.js 0.15.x backend to convert these formats, available in tfjs-converter 0.8.6.

I downgraded to 0.8.6 and got further before another error:

tensorflow.python.framework.errors_impl.InvalidArgumentError: NodeDef mentions attr 'feature_win_len' not in Op<name=NoOp; signature= -> >; NodeDef: {{node model_metadata}}. (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).

Which appears to be related to the version of tf used to originally generate the model. I'll try reverting back to latest and renaming the file before trying to investigate the tf version path.

@lissyx

This comment has been minimized.

Copy link
Collaborator

@lissyx lissyx commented Jul 18, 2019

tensorflow.python.framework.errors_impl.InvalidArgumentError: NodeDef mentions attr 'feature_win_len' not in Op<name=NoOp; signature= -> >; NodeDef: {{node model_metadata}}. (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).

That's just from some metadata that we add to the exported model. Try to disable that and re-export ?

@lissyx

This comment has been minimized.

Copy link
Collaborator

@lissyx lissyx commented Aug 29, 2019

@beriberikix Have you been able to make any progress ?

@beriberikix

This comment has been minimized.

Copy link
Author

@beriberikix beriberikix commented Sep 16, 2019

Unfortunately not. I ran into a few issues and work got very busy lately. Hope to come back to but not in the near-term.

@lissyx

This comment has been minimized.

Copy link
Collaborator

@lissyx lissyx commented Sep 16, 2019

Are those issues workable items we could help about?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.