I am currently developing a website for a client. It consists of users being able to upload pictures to be shown in a gallery on the site.
The problem we have is that when a user uploads an image it would obviously need to be verified to make sure it is safe for the website (no pornographic or explicit pictures). However my client would not like to manually have to accept every image that is being uploaded as this would be time consuming and the users' images would not instantly be online.
I am writing my code in PHP. If needs be I could change to ASP.net or C#. Is there any way that this can be done?
2019 Update
A lot has changed since this original answer way back in 2013, the main thing being machine learning. There are now a number of libraries and API's available for programmatically detecting adult content:
Google Cloud Vision API, which uses the same models Google uses for safe search.
NSFWJS uses TensorFlow.js claims to achieve ~90% accuracy and is open source under MIT license.
Yahoo has a solution called Open NSFW under the BSD 2 clause license.
2013 Answer
There is a JavaScript library called nude.js which is for this, although I have never used it. Here is a demo of it in use.
There is also PORNsweeper.
Another option is to "outsource" the moderation work using something like Amazon Mechanical Turk, which is a crowdsourced platform which "enables computer programs to co-ordinate the use of human intelligence to perform tasks which computers are unable to do". So you would basically pay a small amount per moderation item and have an outsourced actual human to moderate the content for you.
The only other solution I can think of is to make the images user moderated, where users can flag inappropriate posts/images for moderation, and if nobody wants to manually moderate them they can simply be removed after a certain number of flags.
Here are a few other interesting links on the topic:
http://thomas.deselaers.de/publications/papers/deselaers_icpr08_porn.pdf
http://www.naun.org/multimedia/NAUN/computers/20-462.pdf
What is the best way to programmatically detect porn images?
The example below does not give you 100% accurate results but it should help you a least a bit and works out of the box.
<?php
$url = 'http://server.com/image.png';
$data = json_decode(file_get_contents('http://api.rest7.com/v1/detect_nudity.php?url=' . $url));
if (#$data->success !== 1)
{
die('Failed');
}
echo 'Contains nudity? ' . $data->nudity . '<br>';
echo 'Nudity percentage: ' . $data->nudity_percentage . '<br>';
If you are looking for an API-based solution, you may want to check out Sightengine.com
It's an automated solution to detect things like adult content, violence, celebrities etc in images and videos.
Here is an example in PHP, using the SDK:
<?php
$client = new SightengineClient('YourApplicationID', 'YourAPIKey');
$output = $client>check('nudity')>image('https://sightengine.com/assets/img/examples/example2.jpg');
The output will then return the classification:
{
"status": "success",
"request": {
"id": "req_VjyxevVQYXQZ1HMbnwtn",
"timestamp": 1471762434.0244,
"operations": 1
},
"nudity": {
"raw": 0.000757,
"partial": 0.000763,
"safe": 0.999243
},
"media": {
"id": "med_KWmB2GQZ29N4MVpVdq5K",
"uri": "https://sightengine.com/assets/img/examples/example2.jpg"
}
}
Have a look at the documentation for more details: https://sightengine.com/docs/#nudity-detection
(disclaimer: I work there)
There is a free API that detects adult content (porn, nudity, NSFW).
https://market.mashape.com/purelabs/sensitive-image-detection
We've using it on our production environment and I would say it works pretty good so far. There are some false detections though, it seems they prefer to mark the image as unsafe if they are unsure.
It all depends on the level of accuracy you are looking for, simple skin tone detection (like nude.js) will prob get you 60-80% accuracy on a generous sample set, for anything more accurate than that, let's say 90-95%, you are going to need some specialized computer vision system with an evolving model that is revised over time. For the latter you might want to check out http://clarifai.com or https://scanii.com (which I work on)
Microsoft Azure has a very cool API called Computer Vision, which you can use for free (either through the UI or programmatically) and has tons of documentation, including for PHP.
It has some amazingly accurate (and sometimes humorous) results.
Outside of detecting adult and "racy" material, it will read text, guess your age, identify primary colours, etc etc.
You can try it out at azure.microsoft.com.
Sample output from a "racy" image:
FEATURE NAME: VALUE:
Description { "tags": [ "person", "man", "young", "woman", "holding",
"surfing", "board", "hair", "laying", "boy", "standing",
"water", "cutting", "white", "beach", "people", "bed" ],
"captions": [ { "text": "a man and a woman taking a selfie",
"confidence": 0.133149087 } ] }
Tags [ { "name": "person", "confidence": 0.9997446 },
{ "name": "man", "confidence": 0.9587285 },
{ "name": "wall", "confidence": 0.9546831 },
{ "name": "swimsuit", "confidence": 0.499717563 } ]
Image format "Jpeg"
Image dimensions 1328 x 2000
Clip art type 0
Line drawing type 0
Black and white false
Adult content true
Adult score 0.9845981
Racy true
Racy score 0.964191854
Categories [ { "name": "people_baby", "score": 0.4921875 } ]
Faces [ { "age": 37, "gender": "Female",
"faceRectangle": { "top": 317, "left": 1554,
"width": 232, "height": 232 } } ]
Dominant color background "Brown"
Dominant color foreground "Black"
Accent Color #0D8CBE
I am using JSON to return a couple of objects, one of which is returned like this :
"information": [{
"title": "Wifi",
"content": "__Network:__ WifiName \n__Password:__ abcde"
}, {
"title": "Address",
"content": "120 10th Ave\n San Francisco, CA 09601\n[Directions](https://goo.gl/maps/fzsXTCxw3Q5)"
}, {
"title": "Help",
"content": "Reach out to support if you have any trouble printing and we’ll be happy to help set you up."
}]
Now I don't have a clue how to decode the content in "content". Is there a way to decode this such that whatever markup is returned is recognized (including links if any are highlighted and clickable). I have no experience with this so kind of lost.
Any ideas?
P.S: currently I get the content as is without any manipulation, I am wondering if there is any mechanism I can apply to recognize this returned markup
Thanks in advance
I have an array of JSON real Points of Interest that came from an API (generated by Java) taken from a PostgreSQL database:
[
{
"code": 18554,
"lat": 43.36161686223077,
"lon": 3.15837302430637,
"taxon": {
"popularNameEN": "Moon trefoil",
"media": {
"thumbnail": "//upload.wikimedia.org/wikipedia/commons/thumb/8/81/Cistus_creticus_1.jpg/240px-Moon_trefoil.jpg"
}
}
},
{
"code": 13826,
"lat": 42.36162882111323,
"lon": 3.158355343054932,
"taxon": {
"popularNameEN": "Rock rose",
"media": {
"thumbnail": "//upload.wikimedia.org/wikipedia/commons/thumb/c/cc/Cistus_creticus_RJB2.JPG/240px-Cistus_creticus_RJB2.JPG"
}
}
}
]
(16000 PoI in an area of 14 hectares).
Currently my app draw them in a 2d regular map (with Leaflet) with the name and a thumbnail (I already have a function that show just the 8 closest, not all 16000).
I want to show same information in a simple and easy Augmented Reality way in Android phones.
I don't care if the result is not perfect because the compass, or anything. I care to use 100% free and open source software and avoid to use an external API, if it is possible. I need just something simple for a show to my client but maybe also something enough good to continue improving my app in the future. What framework/libraries should I use for this and how?
You can start with Google's AR kit.
https://developers.google.com/ar
It is easy and self-explanatory, but for now, it has limited support for devices.
I am trying to get the birthday from the Google API, but the retrieved data in HWIOAuthBundle do not contain it.
I am wondering if the specified scope for google plus api in config.yml is correct or not!
If not, please give a link or the corrected scope.
google:
type: google
client_id: %client_id%
client_secret: %secret_id%
scope: "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"
paths:
email: email
profilepicture: picture
I just used and tested it using Try It. I tested it with all of the different scopes.
https://www.googleapis.com/auth/plus.login Know your basic profile
info and list of people in your circles.
https://www.googleapis.com/auth/plus.me Know who you are on Google
https://www.googleapis.com/auth/userinfo.email View your email address
https://www.googleapis.com/auth/userinfo.profile View basic
information about your account
It doesn't appear to matter you get back the birthday in all of the scopes. But what does matter is that the Users Birthday must be set to public in the Account. If it's set to anything else, your circles, only you, it's not listed. This appears to be true even when you are trying to see your own information. (Sending Me.)
Update and the year is 2018
The People api now returns the birthday of the current user
People.get However i suspect its linked to google+ so if the user hasn't filled it out you probably wont get info.
GET https://people.googleapis.com/v1/{resourceName=people/*}
Send Resournce name of people/me and birthdays personFields
{
"resourceName": "people/117200475532672775346",
"etag": "%EgQBBzcuGgwBAgMEBQYHCAkKCwwiDDQwaGhWYzc3cXJBPQ==",
"birthdays": [
{
"metadata": {
"primary": true,
"source": {
"type": "PROFILE",
"id": "117200475532672775346"
}
},
"date": {
"month": 1,
"day": 6
}
},
{
"metadata": {
"source": {
"type": "ACCOUNT",
"id": "117200475532672775346"
}
},
"date": {
"year": 1971,
"month": 1,
"day": 6
}
}
]
Normally you will only get birthdays that have public visibility. To get private birthdays you need to use the https://www.googleapis.com/auth/user.birthday.read scope. See documentation for which scopes give you which data https://developers.google.com/people/v1/how-tos/authorizing#profile-scopes.
I want to access the Person's gender and age group via Google People API. Can we fetch the information without getting the user signed in from our app?
That depends interlay upon what they have set to public. You can use people.get with a public api key. All you need is the API key from the Google Developer console and the Id of the person in question.
110241806600768156114
The Request
GET https://www.googleapis.com/plus/v1/people/110241806600768156114?key={YOUR_API_KEY}
Response
{
"kind": "plus#person",
"etag": "\"RqKWnRU4WW46-6W3rWhLR9iFZQM/uQPoHyS74SJW3R-WzeaqLgt_EL8\"",
"gender": "male",
"objectType": "person",
"id": "110241806600768156114",
"displayName": "djordje tankosic",
"name": {
"familyName": "tankosic",
"givenName": "djordje"
},
"url": "https://plus.google.com/110241806600768156114",
"image": {
"url": "https://lh6.googleusercontent.com/-XtK8-6zkQHY/AAAAAAAAAAI/AAAAAAAAAJk/hI2NqHzmNrA/photo.jpg?sz=50",
"isDefault": false
},
"isPlusUser": true,
"circledByCount": 18,
"verified": false
}
This person who I just randomly grabbed there Id off Google+ has gender set to public. As you can see there is not much other information available to you.
I suggest you go to the bottom of the people.get page and do some testing with the try me don't authenticate it. This will ensure that you are only checking public access. If you want to see the different authenticate it then use 'me' in the id field. This will show you the response for an authenticated user.