Giter Club home page Giter Club logo

pyopennsfwdetector's Introduction

title

PyOpenNSFWDetector

GitHub stars GitHub forks GitHub watchers GitHub followers

PyOpenNSFWDetector is a project that uses machine learning to detect NSFW (Not Safe For Work) content in photos. It can be useful for content filtering on social media, online stores, and other platforms where content control is required.

The result has binary values:

  • 0 if there is no NSFW content in the photo
  • 1 if NSFW content is detected.

Quick start

git clone https://github.com/imitatehappiness/PyOpenNSFWDetector.git
cd PyOpenNSFWDetector
pip install -r requirements.txt
python example.py 

Examples

1. Example Usage

from detector.detector import NSFWDetector

model_path = 'model/nude_detector_model.h5'
NSFW_detector = NSFWDetector(model_path)

# url path
path = 'https://s.pfst.net/2024.02/8081984667080bec99cc7d12e65a5c11aa8a70ef9cefc_b.jpg'
print("predict:", NSFW_detector.predict(path))

path = 'https://s.pfst.net/2022.08/6971621667080909e89391f886395410b385c888ab881_b.jpg'
print("predict:", NSFW_detector.predict(path))

# local path
path = "resources\\local_image_adult.jpg"
print("predict:", NSFW_detector.predict(path))

path = "resources\\local_image_adult.jpg"
print("predict:", NSFW_detector.predict(path))

Execution time

Execution time for 1 image: 1.008302927017212 seconds

Execution time for 10 images: 2.7786076068878174 seconds

Execution time for 100 images: 28.80970525741577 seconds

Execution time for 1000 images: 287.2076916694641 seconds

2. Example Usage (API)

from detector.detector import NSFWDetector
from flask import Flask, jsonify, request

model_path = 'model/nude_detector_model.h5'
NSFW_detector = NSFWDetector(model_path)

app = Flask(__name__)

@app.route('/predict', methods=['POST'])
def predict():
	url = request.json.get('url')
	prediction = NSFW_detector.predict(url)
	return jsonify({'prediction': prediction})

if __name__ == '__main__':
	app.run(debug=True)

API

/predict (POST)

curl -X POST -H "Content-Type: application/json" -d '{"url": "https://example.com/image.jpg"}' http://127.0.0.1:5000/predict

Model

Model from NSFWGuard

pyopennsfwdetector's People

Contributors

imitatehappiness avatar

Stargazers

zen avatar Alex avatar

Watchers

 avatar

pyopennsfwdetector's Issues

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.