1

I am new to both tensorflow and chrome extensions and haven't been able to find information on combining the two. I would like to build a graph (train a model) inside of tensorflow and then execute it inside a chrome extension. I see that there is a c++ api in tensorflow, and it appears that chrome extensions can use c++ as a language. However, the tensorflow documentation seems to indicate that there is a runtime which is necessary to use the C++ graph execution api. Is this the case? If it is, how can I import the runtime into a chrome extension so that I can execute my model inside the extension? Is this possible?

Thanks in advance, Brad

Brad
  • 11
  • 3
  • Impossible is nothing. One path forward would be to compile TensorFlow through NaCL/pNaCL since that can run in Chrome. But that may take some work. – Yaroslav Bulatov Apr 20 '16 at 17:20
  • Thank you for the reply. Do you think this could be done? I'm just now digging into the PNaCl/NaCl SDK. I do know that tensorflow is hugely complex. I wonder if I could extract/compile part of it, the part I need to execute the model... Then I don't have to worry about the Python API and the training subsystem. I have no idea how long that might take. There is a runtime for Android, so maybe the code is extracted to a sufficient degree since it has already been ported. Maybe I could just treat it like another porting effort. – Brad Apr 21 '16 at 13:42
  • On TensorFlow side, it was ported to Android and iOS (mostly) and Raspberry Pi. On NaCL side, someone ported Python/SciPy to run inside Chrome (https://codereview.chromium.org/165473002). So I bet it's possible. But unless you are a hacker genius, it may take a >1 month of work....maybe start a discussion on github to drum up some community support? – Yaroslav Bulatov Apr 21 '16 at 17:41
  • About IPython/SciPy in Chrome there's this presentation: http://conference.scipy.org/scipy2014/schedule/presentation/1720/ – Yaroslav Bulatov Apr 21 '16 at 17:44
  • Wow, this is wonderful stuff. Thank you! Yeah, I saw the port of the runtime to Android and thought there was one for IOS, but didn't know about the Raspberry Pi port. So the runtime must be sufficiently extracted that it SHOULD be able to be ported. Python in Chrome is very interesting. I bet that took a lot of work. Good idea about github. I'm not the best code hacker, so I'll definitely need help. :) – Brad Apr 22 '16 at 13:48

1 Answers1

-1

Updated

You could take a look at Native Client, it allows you to run compiled C++ code in the browser. And NaCL can be called in an extension, see Adding NaCl in an Chrome Extension and Nacl Modules for more details.

Previous

Chrome extension can only use web technologies such as HTML, JavaScript, and CSS.

If tensorflow only has C++ support, you could take a look at Native Messaing, it allows extensions exchange messages with native applications.

Community
  • 1
  • 1
Haibara Ai
  • 10,703
  • 2
  • 31
  • 47