1

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!

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the resources! I for sure need the processing steps, but the run inference section I drew a complete blank. Your posts have definitely helped me!
0

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.

1 Comment

Oh yes I definitely need the same processing, I was just unsure about the translation of certain areas. I will make my question more clear for next time. I did not know that the default was RGB in JS, so thanks for that info!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.