6 ms·
Brain.js: GPU Accelerated Neural Networks in JavaScript
- neodypsis 4y agoThere's also TensorFlow.js: https://www.tensorflow.org/js https://www.tensorflow.org/js
- ch_sm 4y agoalso ONNX.js, which is great for interop: https://github.com/microsoft/onnxjs https://github.com/microsoft/onnxjs
- pluc 4y agohttps://dannjs.org/ https://dannjs.org/
- neodypsis 4y agoDoes it support GPU?
- ge96 4y agoI used their facial landmark model, took some messing around (import/dep issues) but worked in my react project. My use case was just automatic picture taking when a face was detected in a video stream.
- jppope 4y agobrain.js is significantly simpler to deploy basic projects than TensorFlow.js
- yeldarb 4y agoFor object detection, we made a way to do it from scratch in a couple of hours (for free if your project is open source[1]): https://docs.roboflow.com/inference/web-browser https://docs.roboflow.com/inference/web-browser [1] https://blog.roboflow.com/computer-vision-datasets-and-apis/ https://blog.roboflow.com/computer-vision-datasets-and-apis/
- neodypsis 4y agoI was checking it out, but it seems limited in terms of the type of models you can implement. You don't have CNNs for example.
- Aspos 4y agoCNNs are possible, but require some hacky code. Tensorflow.js is far better in this regard.
- darepublic 4y agoThe mobile site needs some work. Why is the hero present on every page, not just the lander? On mobile firefox the flex box in the hero is not wrapping like it should. In terms of marketing and communication, you need to specify up front what lib is being used for the gpu accelerated parts. Can I do everything with this as I could with, say, pytorch, except in js?
- m00dy 4y agoNo, you can’t
- fbanon654 4y agonot yet (and not with this framework) but soon with pytorch itself https://dev-discuss.pytorch.org/t/proposal-torch-js-a-javascript-frontend-for-pytorch/650 https://dev-discuss.pytorch.org/t/proposal-torch-js-a-javasc...
- pixelbyindex 4y ago> It’s pretty much a certainty that a web standard for eager-mode machine learning will spring up when WebGPU comes online I can agree on this point. The fusion of the browser and the GPU will likely open up some new pathways to ML concepts that were previously impeded. At the same time, is there a possibility that websites begin implementing heavy GPU operations at scale, in the same way that SPA webapps are heavy on memory today?
- cubano 4y agoSo being semi-retired (unable to find work due to 10yr+ past background issues) and living in Vegas, I've really given serious thought to building some sort of NN to help with gambling in general and specifically the picking of horses (or perhaps even baseball outcomes). I can't help but think that buried in all the race data their are correlations that are impossible to figure with standard statistical methods but can be sussed out using NNs. Of course I am vaguely aware that many people are already using NNs to predict race outcomes, but I am purposely trying to keep that info at arms length as I don't really want to be negatively influenced existing attitudes. However, if someone does happen to know of a good NN/horseracing blog that has a positive outlook and is making money, I would be interested in such a site. Anyway, this type of easy-to-use NN could be exactly what I'm looking for with getting started on this project, and once again, I would be interested in hearing about the pros and cons of using such a lightweight easy-to-use NN for my explorations.
- mhh__ 4y agoThose standard statical methods probably don't have the gift of thousands of parameters.
- carnitine 4y agoWell no, but what’s your point?
- mhh__ 4y agoIt's a pretty strange comparison if you think about it computationally. I'm very much on the deep learning train but comparisons with traditional statistics are rather somewhat tortured.
- ShamelessC 4y agoI’m still learning about a lot of this stuff so apologies if this is wrong. Isn’t part of the motivation for using deep learning that it can actually generalize over that many parameters? My understanding is that classical statistical models are prone to overfitting on data as you add more parameters to the model. Deep learning tries to learn the underlying distribution of data, enabling predictions not found in the dataset that still match the underlying positional statistics of the dataset. In that context I’d say the comparison is apt. It’s not just throwing more compute at the problem - it’s doing so in a way that actually achieves scalable accuracy gains. With pre training and self-supervised learning, you can (feasibly) train such a model without even needing to understand statistics.
- m00dy 4y agoI think a js framework doesn’t make sense because all people I know dealing with dnns using python as base language. I’m also working on something very similar and I think my stack is a lot better because I used pyodide + webassembly + webgpu . So far, I managed to implement a very small grad based dnn framework with couple of ops. (like matmul, etc.) One of the limitations is that webassembly vm has 4gb address space. This could be a problem during loading/unloading from/to gpu.
- misterdata 4y agoSee also https://github.com/webonnx/wonnx https://github.com/webonnx/wonnx, which runs ONNX models through WebGPU. It is written in Rust and can be used natively on Windows, macOS and Linux (through wgpu which uses either DX12, Vulkan or Metal) or on the web (it has a JS API that uses WASM under the hood, which calls into the browser’s WebGPU API). There is a Python module as well.
- davidatbu 4y agoI've ran across this before, but haven't figured out if a GPU is required to use it. That would be a deal-breaker for any consumer facing web app right?
- misterdata 4y agoIt will work with software implementations (e.g. llvmpipe/lavapipe is used in CI). That will be slower though. However you’d be surprised at how many devices have a usable GPU. Not all have NVIDIA RTX’es of course, but a simple iGPU will do. I tested it on a fairly low specced Dell office PC with an Intel Iris iGPU and that works just fine. Also most mobile devices will have a GPU these days.
- davidatbu 4y agoThanks! it looks like the wonnx CLI itself falls back to tract to do inference on CPU if a GPU is not available[0], and it also sounds like setting up llvmpipe/lavapipe on WASM is much harder (if not impossible?) than just shipping tract, so the approach I'll take is probably a wonnx+tract approach. [0] https://github.com/webonnx/wonnx/issues/116#issuecomment-1140308255 https://github.com/webonnx/wonnx/issues/116#issuecomment-114...
- nightski 4y agoI'm curious if there are many scenarios where a CPU fallback, especially javascript based, would have acceptable performance when a GPU is not present. Is that even really a solution?
- jppope 4y agoI ABSOLUTELY loved this project and used it for all of my "quick and dirty" ML stuff where I was fooling around... the only problem, which I don't think has been fixed is that it still requires *Python 2.7*. End of life for Python 2.7 was 2020!
- Aspos 4y agoWhat do you mean? Brain.js is JavaScript ML engine.
- synchronizing 4y agoCheck out the README: https://github.com/BrainJS/brain.js https://github.com/BrainJS/brain.js
- Aspos 4y agoOh, you don't need to use python if you don't want to. Brain.js happily runs in a broswer.
- YetAnotherNick 4y agoIt's just a requirement. Python 2 is available on all the systems I know. What difficulty are you facing in installing it?
- kllrnohj 4y ago> Python 2 is unsupported by the Python Foundation since 2020-01-01 and is being removed as of Debian 11 (Bullseye) https://wiki.debian.org/Python https://wiki.debian.org/Python
- YetAnotherNick 4y agoIt's not being removed. It won't be default, but installing python2 is possible(https://packages.debian.org/stable/python/python2 https://packages.debian.org/stable/python/python2)
- davidatbu 4y agoThere's also tract, from Sonos[0]. 100% Rust[1]. I'm currently using it to do speech recognition with a variant of the Conformer architecture (exported to ONNX). The final goal is to do it in WASM client-side. [0] https://github.com/sonos/tract https://github.com/sonos/tract [1] To be clear, I'm not saying that writing in Rust is some inherent advantage for an NN inference engine. But I personally gravitate to using libraries written in languages I know/want to learn, and Rust might be that for some people.
- brrrrrm 4y agoFor inference, models should be compiled down directly to WASM or WebGPU or whatever, right? The driving language really shouldn't matter at the end of the day. Unless you've got massive compute bound transformers or old-school full convolutions, if you're interpreting a list of operations you're going to lose perf.
- davidatbu 4y ago> For inference, models should be compiled down directly to WASM or WebGPU I mean, yes? Whether for inference or for training, ML operators are usually implemented in compiled low level languages. That implementation might also take advantage of GPUs. > ... if you're going interpreting a list of operations ... I'm not sure what "interpreting a list of operators" means here. To clarify why I mentioned the implementation language, I recently had to modify the source code of Tract to get my model running (I will push that change upstream at some point). I would not have (been able to do that), had tract been written in C++, for example.
- leeoniya 4y agoalso https://github.com/photopea/UNN.js https://github.com/photopea/UNN.js
- danielEM 4y agoLong time ago wanted to so something good and took a part in W3C webmachinelearning standardization group. Inspired by simplicity of brain.js wanted browser API to offer something similar to it - simple and easy to learn and easy to understand, also wanted a training API to be available. It is possible to keep simplicity of brain.js and flexibility of any other op set. And my oh my - did hit the wall HARD! Paid seats in W3C rules. They do what they want there. Your voice there matters only if it aligns well with their voice. Browsers API is now their own domain and whenever there is a conflict of interest their choice is obvious.
- dennisy 4y agoThat group has been around for so long, seems mostly Intel folks. I just don’t get why the progress is so slow! I was trying to follow along, and joined calls, but the group moves like a glacier.
- melony 4y agoIf you don't get buy-in from the actual browser vendors, they can just ignore your W3C standards. Buy a couple drinks for the Chrome engineering and product managers and your problem will be solved.
- de6u99er 4y agoWebmachinelearning sounds like a problem nobody has. Why would I want a standardized browser API for doing stuff that I can obviously already do without such an API?
- b_mc2 4y agoSee also: https://ml5js.org/ https://ml5js.org/ "The library provides access to machine learning algorithms and models in the browser, building on top of TensorFlow.js with no other external dependencies."