acho
acho

Reputation: 66

Tensorflow Object Detection API model for use in TensorFlow.js

I am trying to use an object detection model, that was created using the TF Object Detection API, in TensorFlow.js.

I converted the model using:

tensorflowjs_converter --input_format=tf_saved_model inference_graph/saved_model inference_graph/web_model

It gets converted without any problems and loads in my javascript code. Now I am a bit unsure about what my next steps should be. I have to translate the Python into JavaScript, but certain areas I am unsure about.

With the object detection API in python, there are many steps; (1)preprocessing the image, such as convert to RGB, numpy array reshape, expand dimensions (I have an idea of how I would approach it) and (2) the run inference for single image function, I am not sure how I would go about it in tensorflow.js.

I tried to find some general information about deploying an object detection model in tensorflow.js, but I could not find much, except with pre-trained models.

Any information about this topic would be great! Thanks!

Upvotes: 1

Views: 995

Answers (2)

vabarbosa
vabarbosa

Reputation: 706

as mentioned by @edkeveked you will need to perform similar input processing and output processing in JavaScript as is being done in Python. i can't say exactly what you will need to do since i am not familiar with the model. however, you can find an example using a specific object detection model here:

https://github.com/vabarbosa/tfjs-model-playground/blob/master/object-detector/demo/object-detector.js

see also

https://medium.com/codait/bring-machine-learning-to-the-browser-with-tensorflow-js-part-iii-62d2b09b10a3

Upvotes: 1

edkeveked
edkeveked

Reputation: 18401

You would need to replicate the same process in javascript before giving it to the model. In js, the image use by default the RGB channel, so there is no need to make that conversion again.

Upvotes: 0

Related Questions