项目作者: jgarber623

项目描述 :
A Python package for analyzing images using Caffe and Yahoo's open_nsfw models.
高级语言: Python
项目地址: git://github.com/jgarber623/python-nsfw.git
创建时间: 2018-05-17T18:52:28Z
项目社区:https://github.com/jgarber623/python-nsfw

开源协议:MIT License

下载


python-nsfw

A Python package for analyzing images using Caffe and Yahoo’s open_nsfw models.

PyPI
Python

Prerequisites

python-nsfw requires Python 3 and runs on Caffe-compatible systems.

Caffe

If you’re using macOS and Homebrew, the easiest way to install Caffe is with Homebrew:

  1. brew install caffe

Alternatively, you could use a Docker Linux image (e.g. debian:stretch-slim) and install the necessary dependencies:

  1. apt update && apt install caffe-cpu python3 python3-pip wget

Installation

python-nsfw may be installed using pip:

  1. pip3 install nsfw

Usage

  1. import PIL.Image as Image
  2. from nsfw import classify
  3. image = Image.open("/path/to/image.jpg")
  4. sfw, nsfw = classify(image)
  5. print("SFW Probability: {}".format(sfw))
  6. print("NSFW Probability: {}".format(nsfw))

License

python-nsfw is freely available under the MIT License. Use it, learn from it, fork it, improve it, change it, tailor it to your needs.

python-nsfw ships with copies of Yahoo’s open_nsfw Caffe models (nsfw/deploy.prototxt and nsfw/resent_50_1by2_nsfw.caffemodel) which are licensed under the BSD 2-Clause License.