isadult
v1.0.4
Published
Machine learning algorithm written in JS to check if an image contains adult content
Downloads
10
Maintainers
Readme
IsAdult
IsAdult is a script that detects whether or not an image is an adult image based on a given image element.
Based on ml5, which is a machine learning framework written in JavaScript with TensorFlow, isAdult aim is to be as accurate as possible in its detection.
IsAdult is very easy to use, just add the isAdult.js or isAdult.min.js file into your project and you're done!
IsAdult has only one function for now, which is called checkAdultImage
. This function should receive one parameter,
this parameter is the image
HTML element where the image is shown. This function will return a promise
so its response should be treated as such using then
/catch
or async
/await
.
When the promise is resolved, the response object will contain a status
and a msg
properties.
The status
may contain 3 different statuses with a type of integer:
1
- Image is clear and there is no risk of adult content shown2
- Low risk of adult content in this image3
- High risk of adult image showing. With this status the image most likely contains an adult content
The msg
property is the verbal explanation of the status.
checkAdultImage
function will expose NO_RISK_STATUS, MEDIUM_RISK_STATUS, HIGH_RISK_STATUS as properties,
to allow users to check what the status was without knowing the underlying status code
A few notes before you start:
- It is recommended that the
<image>
tag will contain acrossorigin="anonymous"
attribute, especially if you are dealing with external image sources. Unfortunately, ml5 can not process images from sources that are blocking cross-origin access. - the
<script src="isAdult.js"></script>
should be placed at the bottom of the body tag and not in the header. Since this scripts also injects the ml5 script in the HTML, by adding this script to the body it will reserve the correct hierarchy of the scripts.
Example can be shown in the example.html
file attached to this repository.
A live example is also available here
Created by Shay Kintzlinger :)