• Stars
    star
    325
  • Rank 129,350 (Top 3 %)
  • Language
    Python
  • Created over 9 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Porn images detector with python, tensorflow, scikit-learn and opencv.

PornDetector

Two python porn images (nudity) detectors.

First one (pcr.py) use scikit-learn and opencv. I was able to get ~85% accuracy on markup with 1500 positive and 1500 negative samples. It use two machine-learned classifiers - one of them use HSV colors histogram, and another use SIFT descriptors.

Second one (nnpcr.py) uses tensorflow neural network. I was able to get ~90% accuracy on the same markup. It use 4 convolutional (3x3 filters) combined with max_pool (2x2) layers, one 1024 fully connected layer and a softmax classifier at the end.

Requirements of opencv & sklearn detector

  • python 2.7
  • scikit-learn 0.15
  • opencv 2.4 (build it from sources, cause it missing SIFT by default)

Requirements of tensorlflow detector

  • python 2.7
  • opencv 2.4 (you can take binary from repository)
  • latest tensorflow

This is my configuration, may be it can work with another library versions.

Usage of opencv & sklearn detector

  • Url prediction demo: ./pcr.py url http://example.com/img.jpg
  • Code usage:
from pcr import PCR
model = PCR()
model.loadModel('model.bin')
predictions = model.predict(['image1.jpg', 'image2.jpg', 'image3.jpg'])
print predictions

Usage of tensorlflow detector

  • Url prediction demo: ./nnpcr.py url http://example.com/img.jpg
  • Code usage:
from nnpcr import NNPCR
model = NNPCR()
model.loadModel('nnmodel.bin')
predictions = model.predict(['image1.jpg', 'image2.jpg', 'image3.jpg'])
print predictions

Train model

  • create directory 1 (with non-porn images), 2 (with porn images), cache (empty)
  • Run ./pcr.py train (to train opencv & sklearn) or ./nnpcr.py train (for tensorflow one).

After train finish you will see accuracy and you will get "model.bin" file with your trained model. Now you can use it to detect porn (see functions predictTest and predictUrl). I added a sample model (model.bin) - you can test it without training your own model, but I recomend you to gather some huge collection of images (eg, 50K) for best results.

License

Public domain (but it may use some patented algorithms, eg. SIFT - so you should check license of all used libraries).

More Repositories

1

PySyncObj

A library for replicating your python class between multiple servers, based on raft protocol
Python
681
star
2

JamSpell

Modern spell checking library - accurate, fast, multi-language
C++
601
star
3

Pastexen

Quick screenshots and source code publish
PHP
47
star
4

LibQtScreen

Qt library for making directx and opengl screenshots.
C
42
star
5

Vavaja

Repo for my virtual machine
C++
32
star
6

Epsilon5

Epsilon5 - 2D multiplayer shooter with vehicles
C++
20
star
7

wing_telemetry_overlay

A tool to add telemetry overlay on top of the video files
Python
16
star
8

SeaCraft

Sea battle client and server
C++
13
star
9

delta3-server

Universal remote control system
C++
8
star
10

delta3-admin

Universal remote control system
C++
8
star
11

rk_latency

Rockchip low latency video decoding
C++
7
star
12

udt-nat-traverse

Example of nat traversing using udt library.
C++
7
star
13

ozifi

ozifi - personal central repository
C
6
star
14

DbSyncer

Utility for fault-tolerant database replication, based on raft protocol
Python
5
star
15

MPAuth

C
4
star
16

delta3-client

Universal remote control system
C++
4
star
17

HandyPack

Tiny C++ serializer
C++
3
star
18

wasp

p2p backup service
Python
2
star
19

htf

HTTP Fetcher - Simple cross-platform headers-only library for downloading url in C++
C++
2
star
20

Exhauster

Html content extraction library & service
C++
2
star
21

wildcard

Simple multi-state-ndfa based wildcard matching algorithm implementation
C++
2
star
22

Jamsmtpd

SMTP proxy server
C++
2
star
23

management-laba1

C++
1
star
24

puzzleSolver

Python
1
star
25

bfmon

Battlefield 1942 monitor
Component Pascal
1
star
26

JamSpell-models

1
star