Git Product home page Git Product logo

adult-image-validation's Introduction

Adult image validation

This is a simple PHP class that allows you to check if the image contains adult content or not. We experimented with a lot of images and find out that the image having score greater than 60 should be considered as an adult image in most cases.

How to use ?

Support you have a simple HTML file that allows user to upload an image:

<form method="POST" action="upload.php" enctype="multipart/form-data">
	<input type="file" name="file" />
	<input type="submit" />
</form>

Then in your "upload.php", you can use this class in the following manner:

<?php

require_once "class.ImageFilter.php";

move_uploaded_file($_FILES["file"]["tmp_name"], "image.png");

$filter = new ImageFilter();
$score = $filter->GetScore("image.png");

unlink("image.png");

echo $score;

if ($score > 60)
{
	echo "<p>Image contains adult content.</p>";
}
  1. First, we are simply including the class in our PHP file.
  2. Then we save the image file as "image.png", you can set any name of your choice.
  3. Then we are creating an instance of ImageFilter class.
  4. Then we are getting the score of newly created image file. A score of 61 and above is considered to be contain nudity content.
  5. Then we are removing the image file we saved.
  6. And display the score to the user, you can remove this line if you do not want to show the scores to the user.
  7. Finally, we are putting a condition that says "if score is greater than 60, then display an error message."

You can try with other images too and feel free to give feedback for improvements.

adult-image-validation's People

Contributors

adnanafzal565 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.