RubixML / ML

A high-level machine learning and deep learning library for the PHP language.
https://rubixml.com
MIT License
2.01k stars 181 forks source link

Adults image filtering #164

Open sgoranov opened 3 years ago

sgoranov commented 3 years ago

I'm trying to implement a simple adults image filter using RubixML. The only example I can find that deals with something similar is CIFAR-10 Image Recognizer. I was thinking about to define only two labels - "adult" and "not-adult" and basically follow the example. Do you think this strategy is appropriate?

andrewdalpino commented 3 years ago

Hello @sgoranov indeed the CIFAR-10 or the MNIST example projects are a good place to start for image recognition in Rubix ML. The adult/non adult labeling schema works great. I would also make sure that the labels are distributed in the training and testing sets in roughly the same proportions as a "real world" scenario. You can use the stratified methods on the Labeled dataset object to split your dataset into training and testing sets while maintaining this proportion. Also, for neural net training, the Tensor extension will speed up training by about an order of magnitude.

A couple things I'd add that may help you hone your expectations ... Fully connected feed-forward neural nets (Multilayer Perceptrons) are not the state-of-the-art in image recognition since the Convolutional neural network. The difference primarily being that convnets are able to use spatial information contained within the image and not just the pixel intensities. We hope to implement convnets among many other types of network architectures using a new project we are currently researching called Rubix DL.

sgoranov commented 3 years ago

Thank you @andrewdalpino! The Tensor extension is really great, I managed to compile and install it successfully and it looks like it's much more faster when using it. I wonder whether it's possible to get some more data but not just the label ? I mean that $predictions = $estimator->predict($dataset); returns the labels only but is there an option to get some percentage probably of how much this label corresponds to the image?

andrewdalpino commented 3 years ago

is there an option to get some percentage probably of how much this label corresponds to the image?

You may be talking about a probability? If so, yes you can return the class probabilities using the proba() method on a Probabilistic classifier.

See https://docs.rubixml.com/latest/inference.html#estimation-of-probabilities

sgoranov commented 3 years ago

Thank you @andrewdalpino! This is exactly what I was looking for!