How to run a pytorch model on the browser?
Asked Answered
M

3

6

I would like to know what are the options I have to run an object detection model in the browser, until now I have found the next options:

  1. Streamlit: is very simple but requires the server resources to run, including its own camera. Besides, I believe is not possible to be implemented as a website.
  2. Brython: is a JS substitute? I couldnt find the way how to load pytorch or libraries.
  3. Onnx: Seems to be a very good option, however I dont quite understand how to run the model in JS, since I have been using python and pytorch only, What is the learning roadmap? What is the relation with Webassembly?
  4. NCNN: This is the method I know the least, It seems to be able to work on basically any device, Webassembly, windows, android..., but again, I cant understand how to use my python-pytorch model to this framework since I dont know the roadmap.

Are there other options?

Motion answered 20/8, 2021 at 6:32 Comment(0)
P
1

There's TensorFlow.js.

You still need to convert your model with something like ONNX, though.

Pallor answered 20/8, 2021 at 7:21 Comment(0)
T
0

Just to update you. Tensorflow.js is suitable for the TensorFlow model while onnx runtime web is a good option for others. Things to do are;

  • Convert your model to onnx(see PyTorch export onnx)
  • Use onnxruntime web to use generated onnx with javascript(detailed at onnxruntime.ai)

If anyone knows more options, kindly add.

Timber answered 6/10, 2022 at 7:38 Comment(0)
N
0

Another alternative is JS-PyTorch.

You can train and run models directly on the web (with GPU support).

Nutritious answered 1/8, 2024 at 0:2 Comment(1)
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From ReviewOlatha

© 2022 - 2025 — McMap. All rights reserved.