r/MachineLearning • u/deepPurpleHaze • Apr 23 '15
Android App: Nipple Detection using Convolutional Neural Network. Results. [NSFW] NSFW
http://imgur.com/a/6KUEu77
u/bakedpatata Apr 24 '15
You realize the next step is to reverse the algorithm to guess what peoples nipples look like.
42
u/deepPurpleHaze Apr 24 '15
ha thats silly. reminds me of this paper by Hinton. "To recognize shapes, first learn to generate images."
10
0
Apr 24 '15
[deleted]
7
u/deepPurpleHaze Apr 24 '15
This is a great idea. I'm definitely doing it! Let me know if you get any results.
1
u/holomanga Apr 26 '15
RemindMe! 1 month
2
u/ptntprty Jun 18 '15
Reminder to you and /u/amazingmuffin and /u/deeppurplehaze
Anything to report?
8
u/deepPurpleHaze Aug 13 '15
Anything
Using the google deepdream code i dropped in the nippler model. The results aren't that cool because of only 2 classes: nippple and non-nipple. Here's a picture of my cat deepdreamed with the Nippler model:
2
34
u/shaggorama Apr 23 '15
I bet constructing the training set was fun ;)
Since you've deployed this as an app, you should consider compressing/distilling your model with Hinton's dark knowledge technique (or whatever we're supposed to call it). It should give you roughly equivalent performance while occupying significantly less disk space and probably producing results faster as well.
18
u/deepPurpleHaze Apr 23 '15 edited Apr 23 '15
Sounds fun but honestly it was quite tedious. Thanks for that I really would like to speed up the prediction. My main work lately has been on window proposal strategies to reduce the number of predictions.
I tried simple color histograms with SVMs but the linear ones didn't work and the non-linear ones took too log. Didn't try HOGs but i think they're too expensive. Couldn't find a good implementation of Selective search without matlab (tried a simplified python one but it suggested more windows than my sliding search).
5
u/DrEdPrivateRubbers Apr 24 '15
Would it be easier, more accurate to create an algorithm to look for the proportional relationship of the chest landmarks and facial landmarks. Maybe it would be easier to find faces then look for the nipples attached to the subject? I'm totally out of my depth so just ignore me if I'm talking out my ass.
4
u/deepPurpleHaze Apr 24 '15
That's a good idea. I agree there's room for improvement using more domain knowledge but it was a proof of concept that it can do well without specific human tuned features.
I think more context would help meaning i crop larger windows around the nipple so it can see the difference between a belly button and a nipple for example. That would probably make it miss more nipples and certainly would require a larger training set though too.
4
u/ogrisel Apr 24 '15
If you think non-linear (RBF) SVM would work but is too slow to train you might want to try the
Nystroemmethod:from sklearn.preprocessing import StandardScaler from sklearn.linear_model import LogisticRegressionCV from sklearn.kernel_approximation import Nystroem from sklearn.pipelione import make_pipeline model = make_pipeline( StandardScaler(), Nystroem(n_components=300, gamma=1e-3), LogisticRegressionCV(), ).fit(X_train, y_train)
StandardScalermight not be required if your features are already homogeneous. Try to find the best value forgammaon a small subset of the data.2
u/deepPurpleHaze Apr 24 '15 edited Apr 24 '15
Thanks I'll try this. For now the skin filter is working well but that uses domain specific knowledge.
But the non-linear SVM showed a lot of promise getting about 80%
17
u/SarcasticMetaName Apr 23 '15
What library do you use to implement the CNN on the phone?
18
12
u/mkoxbg Apr 23 '15
can you make it so it identifies male vs female?
33
u/deepPurpleHaze Apr 23 '15 edited Apr 23 '15
the training set was all female nipples and it does fairly well on male nipples too. I'd say it would be very difficult.
Also belly buttons look a lot like nipples if you block everything else out it looks like it sticks out rather than in. its a strange optical illusion i never saw before.
50
u/thirdegree Apr 24 '15
the training set was all female nipples
Rofl op.
27
u/deepPurpleHaze Apr 24 '15
I included lots of races, ages, and styles. The focus wasn't as much for my personal preference as thats what people want to filter or tag. Not men's nipples. In trying to flag nudity those would be false positives strangely.
6
Apr 24 '15
Which is where the real challenge is going to be. A dude on the beach tossing a stick to his dog. Nipples are fine.
A chick's flapjacks flipping while getting drilled from behind. Totally NSFW.
5
u/deepPurpleHaze Apr 24 '15
well you could combine this with other image recognition techniques, like facial recognition to decide if it's a man or a woman (and eliminate false positives if its not a person at all).
4
Apr 24 '15
like facial recognition to decide if it's a man or a woman
I don't think we'll ever get that to work. I often can't tell IRL!
Detecting signs of breast like shape around the nipples would probably be beneficial though, and of course any genital detection would automatically rule an image nsfw. I would think genital detection would be much harder than nipples though... given the variety. Perhaps leg detection would be a lot easier coupled with the ability to detect that continuous skin exists between leg and torso.
2
u/deepPurpleHaze Apr 24 '15
Well if you have a large database of faces tied to identites (like Google or Facebook) you could just identify who it is first.
I think genital detection would be a lot harder and really gets into what is obscene because a lot of it depends on the larger context as you point out.
30
4
4
u/stilllton Apr 24 '15
Maybe you can make a rule that excludes that (belly button) area if two horizontal nipples are found above.
6
u/deepPurpleHaze Apr 24 '15
Yes i could. I'd love to find a way that doesn't include specific domain knowledge though. Maybe i can just add a bunch of belly buttons to the training set.
3
Apr 24 '15
What about inverted nipples? Many women have them... Have you accounted for those?
3
u/deepPurpleHaze Apr 24 '15
http://i.imgur.com/mzTv8Kl.jpg [NSFW] http://i.imgur.com/SfpojYi.jpg [NSFW]
seems to do fine
3
6
u/Farseli Apr 24 '15
Seems to work well on my wife. Hell, the more inverted one had a higher confidence level.
1
1
u/shaggorama Apr 24 '15
That makes sense. I'm...uh...testing your app, and it can't seem to find my nipples through my hairy chest.
1
u/deepPurpleHaze Apr 24 '15
There aren't any examples like that in the training set and so it won't do as well on men. That's by design since your nipples are really false positives in our society with respect to nudity detection.
3
u/ozyman Apr 24 '15
its a strange optical illusion i never saw before.
Sounds similar to the Hollow Face Illusion
2
u/zdk Apr 23 '15
I think the thing to do is just have a totally separate classifier for males vs females and concatenate the results.
1
u/mkoxbg Apr 23 '15
it seems to see the large boobs as a nipple, and then a nipple inside, so in this case it should pick female. or fat/muscle guy.
1
9
5
Apr 23 '15
what feature detection technique was used?
6
u/deepPurpleHaze Apr 23 '15
See my other comment about what i tried with SVMs and a python version of selective search (which i cant find the link to right now).
Ended up using a sliding overlapping window of a few scales, with a filter for HSV ranges that represent skin values and throwing out the window if it doesn't have enough skin. That can be turned off (the deep search) option in the settings of the app.
I'd love suggestions of course. Better windows would help a lot.
2
u/shaggorama Apr 24 '15
Instead of taking a simple color histogram, maybe take the DFT? I'm not convinced this is a good approach though, considering people's skin can take on lots of different colors, not just biologically but also subject to the lighting/processing of the image. Are you whitening the image before performing the search for candidate tiles (I imagine you're at least whitening it before feeding it to your CNN)? Might help.
2
u/deepPurpleHaze Apr 27 '15
The only pre-processing I do to test images is subtracting by the mean for each channel from the training set. That really helps a lot and is almost identical to the per pixel means.
I should try whitening. I'm testing a YCrCb model from the literature, but sadly it doesn't do noticeably better than the HSV one I'm currently using.
Testing the whole thing vs viola-jones with haar features currently.
4
u/andreasblixt Apr 24 '15
So does the app also upload detected nipples for "training purposes"?
12
u/deepPurpleHaze Apr 24 '15
The app doesn't have internet permissions and doesn't keep any data. That's by design.
The database is trained on my pc and not on the phone. I'd like to update the local database on the fly with new images but thats difficult. And unless the user tells the app if its right theres no ground truth to train on.
4
4
u/synaesthesisx Apr 24 '15
Would this work with pierced ones too?
9
u/deepPurpleHaze Apr 24 '15
http://i.imgur.com/qvRhlMO.jpg [NSFW]
yes some of the nipples in the training set are pierced and it could probably generalize that anyways.
2
u/IgorAce Apr 24 '15
This summer I will be getting into neural nets, any advice?
1
u/deepPurpleHaze Apr 24 '15
With respect to deep learning frameworks i've tried Caffe, Theano, and Torch. Caffe is the most plug and play and Theano has great tutorials and documentation. Torch was the most difficult for me and had the least documentation but Google uses it a lot and it seemed reasonably fast.
1
u/IgorAce Apr 24 '15
did u find any textbooks to be super helpful?
1
u/deepPurpleHaze Apr 24 '15
might wanna start here for reading http://deeplearning.net/reading-list/
2
u/f_ditty Apr 24 '15
How does this compare to Viola Jones?
1
u/deepPurpleHaze Apr 24 '15
That's a good idea to compare. I'm gonna try this against my python version...
3
u/f_ditty Apr 24 '15
Viola Jones used to be the best stuff (before Deep Learning). I implemented an extension to this for my Ph.D. work so I'm very curious to see how far the field has progressed empirically in important image recognition work like nipple detection.
1
u/deepPurpleHaze Aug 13 '15
Viola
I could never get the haar cascasdes to work well even as a pre-processing step. They either missed too many or generated more candidates than my sliding window. I tried 6 to 15 levels and applied random shifts and horizontal mirroring to the input data. Any suggestions?
2
u/forte4 Apr 24 '15
It flips the picture for android
1
u/deepPurpleHaze Apr 24 '15
What do u mean? If u found a bug please explain more so i can fix it. Thanks.
1
u/forte4 Apr 24 '15
The pictures I took come out sideways so the nippler are on my sternum and neck
1
u/deepPurpleHaze Apr 24 '15
interesting. what device and version are you using? also a screenshot would be amazing. Thanks :)
0
2
Apr 24 '15
at least you tried
2
u/deepPurpleHaze Apr 24 '15
yes belly buttons are a problem still for sure. Who knew they looked so much like nipples?
2
2
u/foxh8er Apr 25 '15
Apologies, but how are you feeding the image into the CNN? Do you have an application using Caffe hosted on a webservice?
1
u/deepPurpleHaze Apr 25 '15
No, the CNN has been implemented on the phone directly and it does all the processing locally. It doesn't send any information or have permission to access the internet at all.
182
3
Apr 23 '15
Does it work for buttholes too?
21
u/deepPurpleHaze Apr 24 '15
Wasn't trained on buttholes but you're welcome to try it and report back.
9
u/fourhoarsemen Apr 24 '15
I've always wanted to be a part of an academic research collaboration. Can I get the job of building up the training set?
3
17
37
u/ThatSomeGaming Apr 23 '15
Putin tho
44
11
10
u/BenjaminGeiger Apr 24 '15
I took a grad level ML course a few semesters ago. We had to do a project.
I wish I had thought of this. My partner and I did a subreddit recommendation engine (which never worked right).
And I got grouched at for referring to /r/EarthPorn. Apparently a group of 22-30 year olds can't handle hearing the word "porn".
19
u/TecherTurtle Apr 24 '15
About your last point: you'd think they'd be into that considering the sticks up their asses.
-22
Apr 24 '15
When I hear anyone use the word porn to describe anything not actually related to pornography I assume they're a stunted, video game playing manchild. And I'm usually right.
6
Apr 24 '15
[removed] — view removed comment
-3
Apr 24 '15
Pro tip: everyone is constantly making assumptions about other people based on your behavior.
It's called being human.
4
4
1
1
u/quirm Apr 24 '15
So I guess this is similar to this: http://danielnouri.org/notes/2014/12/17/using-convolutional-neural-nets-to-detect-facial-keypoints-tutorial/ ?
What did you use for ConvNet deployment on Android devices?
1
u/deepPurpleHaze Apr 24 '15
Yes great tutorial. Thanks for the link. I used sh1r0's implementation as a framework https://github.com/sh1r0/caffe-android-demo
1
u/jet_heller Apr 24 '15
OK. Now, is this fast enough to work on real time video streams? Like, can I use it to detect nip slips on live TV? Or on my phone's camera?
and then screen shot it.
1
u/deepPurpleHaze Apr 24 '15
No. Unfortunately its not. Without a gpu it takes way too long. With a gpu i'm not sure but i doubt it could do 60fps or even 30. It's possible maybe with some dedicated hardware but in the future i'm sure it will be trivial.
It could crawl websites for nip slips or something like that.
1
u/alexmlamb Apr 28 '15
How many instances did you train on? Do you have a good sense for how many data points are needed to get good results?
1
u/deepPurpleHaze Apr 29 '15
About 2000 nipples and about 20,000 non-nipples. I tried 1:1 and 1:2 positives to negatives but adding more negatives seemed to eliminate false alarms without reducing the hit rate so i just added all the ones I had.
Working on a bigger database now!
6
u/TotesMessenger Apr 24 '15 edited Apr 24 '15
This thread has been linked to from another place on reddit.
[/r/bestof] Redditor shares Android App to detect Nipples with results
[/r/siliconvalleyhbo] Holy shit you guys, NipAlert is happening.
If you follow any of the above links, respect the rules of reddit and don't vote. (Info / ^Contact)
3
3
3
u/chezty Apr 24 '15 edited Apr 24 '15
australia tried to do something similar but failed.
they wanted to force all isp's to run a nudity filter to stop all porn, but the software kept flagging pictures of prime minister tony abbott as an arsehole
3
2
2
2
2
1
1
1
u/timmaeus Apr 24 '15
Aaaaand a project on nipples is the top post of all time on /r/machinelearning.
1
1
1
1
1
u/smokeyj Apr 24 '15
And the state of penis recognition is.. well.. no one really wants to train that data..
3
1
u/EnIdiot Apr 24 '15
I think the next thing he should work on is advanced asshole detection. The entire U.S. Congressional body has pictures of themselves on-line. You could train with that and then move on to corporate and religious figures.
-54
0
0
160
u/deepPurpleHaze Apr 23 '15 edited Apr 24 '15
https://play.google.com/store/apps/details?id=com.boxcar2d.nippler
I created this app with a model I trained on a CNN with varying layers of pooling and convolution. The confidence can be adjusted. The colors represent the prediction confidence: 99% magenta, 95%red, 90% orange, 80% yellow, 70% blue, 60% gray, 50% cyan.
Gonna add some references:
Caffe
ImageNet Classification with Deep Convolutional Neural Networks, Krizhevsky 2012
Deep neural networks are easily fooled, Nguyen 2014
Selective Search for object Recognition, Uijlings 2013
Combining efficient object localization and image classification, Harzallah 2009
and of course http://deeplearning.net/reading-list/