cazala / synaptic

architecture-free neural network library for node.js and the browser
http://caza.la/synaptic
Other
6.92k stars 666 forks source link

Image as an input #343

Open ZauChoco opened 5 years ago

ZauChoco commented 5 years ago

Hello,

How to send an image as an input to make a prediciton ?

For example: If I want to make a neural network to know if an image is red, how to send the image ? In this case, it would be a buffer.

Thank you

ghost commented 5 years ago

Read the RGB value of each pixel and feed each pixel as your input. Doing this with Javascript is very slow, so you should learn Tensorflow/Keras in combination with a top Nvidia card which has Tensorcores.

ZauChoco commented 5 years ago

I tried, but each images don't have the same number of pixels, because of compression. I could send everything in one input? Prgb+P²rgb+P³rgb.......

For instant, I try with Javascript, but I will certainly change with another language.

ghost commented 5 years ago

You can create Javascript code with Javascript to adopt your inputs to different pixel size, but that's more of a hack. You need to optimize and tune your neural network, for that you need static input size. Maybe define 3 models, small pix, medium and large pix and optimize each network. But that still will be slow in Javascript. Using Tensorflow you can be 100-1000x faster, limit ist just your hardware budget.

I recommend to read study this blog daily: https://machinelearningmastery.com/blog/