SFI-Visual-Intelligence / AI-exhibition

Code and documentation for the AI exhibition at the Science Center of Northern Norway
MIT License
3 stars 1 forks source link

GUI in one window #5

Closed bricaud closed 8 months ago

bricaud commented 2 years ago

We got some feedback to make each demo in a single window. It would reduce the risk to hack the demo when some windows are closed while other open.

One solution may be to use https://pyscript.net/ in order to make all the demos run in the browser.

Another popular solution in ML now is Gradio but I can't figure out if it can work with video streaming. It seems not (not yet).

salomaestro commented 2 years ago

Per pyscript, as it stands there does not seem to be backend support for pygame in a browser using pyscript, which affect one of the demos (pyodide support for pygame). As per the demos only requiring a video or camera feed, I do think this would be possible to implement quite easily.

As per gradio I do not see anyone having any experience using it in conjunction with pygame. Per the demos using the cameras, I also haven't seen any documentation with using a live video feed or backend support for taking images.

I do think using pyscript could work very well for the demos not requiring pygame, although that of course does not fulfill the requirements for all the demos. I wonder if there is a possibility to use some html rendering inside pyqt5 as also pygame perhaps has limited support for pyqt5

salomaestro commented 2 years ago

Additionally: Rendering python in a browser is not recommended and especially with pygame, I found something suggesting compiling to javascript, then rendering although compiling machine learning code to javascript might be a too large digression.

pmp-p commented 2 years ago

Rendering python in a browser is not recommended and especially with pygame

That is certainly not true when using sane resolutions for 2D canvas. Pygame can run well in browser, it can also run as a script engine. For 3D in browser it is preferable to use Panda3D or Harfang3D.

The only limitation to pyscript is that the engine (pyodide) used by default is not linked to SDL2 or WebGL2 for size reason. But i don't see why you could not use a custom pyodide or cpython (3.11+) build with it or just ask for it https://github.com/pyodide/pyodide/issues/289#issuecomment-1279942065.