Giter VIP home page Giter VIP logo

nude.py's Introduction

nude.py

Build status

About

Nudity detection with Python. Port of nude.js to Python.

Installation

from pip:

$ pip install --upgrade nudepy

from easy_install:

$ easy_install -ZU nudepy

Requirements

  • Python2.7+ and Python3.3+
  • Cython
  • Pillow

Usage

via command-line

$ nudepy IMAGE_FILE

via Python Module

import nude
from nude import Nude

print(nude.is_nude('./nude.rb/spec/images/damita.jpg'))

n = Nude('./nude.rb/spec/images/damita.jpg')
n.parse()
print("damita :", n.result, n.inspect())

see examples .

nude.py's People

Contributors

adalekin avatar anandjeyahar avatar andrey-justo avatar bobloy avatar dlebech avatar fabaff avatar goaxe avatar hhatto avatar jabbalaci avatar kevgathuku avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nude.py's Issues

Slow performance overall

Performance is kind of random. A 1.9 MiB image of my cat takes about 2 minutes to process (which is really unusable in the context of a web server handling POST data). I profiled this run:

   783201   44.737    0.000   44.739    0.000 .../site-packages/nude.py:147(_add_merge)
     4906   19.164    0.004   19.164    0.004 /usr/lib64/python2.7/copy.py:113(_copy_with_constructor)
        1   18.591   18.591  105.226  105.226 .../site-packages/nude.py:80(parse)
        1   17.738   17.738   36.937   36.937 .../site-packages/nude.py:181(_merge)
 12192768    2.073    0.000    2.073    0.000 {skin_classifier.skin_classifier}
 12192768    1.819    0.000    3.892    0.000 .../site-packages/nude.py:279(_classify_skin)

This is sorted by total time.

  • _add_merge is called a lot, and also takes a lot of time overall, not in itself
  • Calls to copy are expensive, somewhat expected; would have to figure out a way to avoid copy calls
  • _classify_skin should be converted to C if possible?

False Negative

I was testing this script for some of my system use. When testing this code it gave me FALSE NEGATIVE on a full nude image. I can email you that image if you want to test, though I ca't upload it here because that is complete nude. Need help please have a look.
Thanks for your time.

I'm a getting a installation error.

$ pip install --upgrade nudepy

ERROR: Command errored out with exit status 1:
  command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-lbjhc6pt/nudepy_3b195ab8384e42f987f0811934cf8ca8/setup.py'"'"'; __file__='"'"'/tmp/pip-install-lbjhc6pt/nudepy_3b195ab8384e42f987f0811934cf8ca8/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-psp1didq                                        
      cwd: /tmp/pip-install-lbjhc6pt/nudepy_3b195ab8384e42f987f0811934cf8ca8/         
 Complete output (9 lines):                                                           
 running bdist_wheel                                                                  
 running build                                                                        
 running build_py                                                                     
 creating build                                                                       
 creating build/lib.linux-x86_64-3.9                                                  
 copying nude.py -> build/lib.linux-x86_64-3.9                                        
 running build_ext                                                                    
 cythoning skin_classifier.pyx to skin_classifier.c                                   
 error: /tmp/pip-install-lbjhc6pt/nudepy_3b195ab8384e42f987f0811934cf8ca8/skin_classifier.pyx                                                                                
 ----------------------------------------                                             
 ERROR: Failed building wheel for nudepy

help me

Traceback (most recent call last):
File "/usr/local/bin/nudepy", line 9, in
load_entry_point('nudepy==0.2', 'console_scripts', 'nudepy')()
File "/usr/local/lib/python2.7/dist-packages/nudepy-0.2-py2.7.egg/nude.py", line 438, in main
callback(_testfile(fname, resize=args.resize))
File "/usr/local/lib/python2.7/dist-packages/nudepy-0.2-py2.7.egg/nude.py", line 373, in _testfile
n.parse()
File "/usr/local/lib/python2.7/dist-packages/nudepy-0.2-py2.7.egg/nude.py", line 89, in parse
pixels = self.image.load()
File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFile.py", line 203, in load
d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 420, in _getdecoder
raise IOError("decoder %s not available" % decoder_name)
IOError: decoder zip not available

Installation error

Hi, I am trying to install the package via python3 -m pip install --upgrade nudepy howevrer I am running into the following error:

Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in /home/lskywalker416/.local/lib/python3.7/site-packages (21.2.4)
Collecting install
  Using cached install-1.3.4-py3-none-any.whl (3.1 kB)
Collecting nudepy
  Using cached nudepy-0.5.1.tar.gz (35 kB)
Requirement already satisfied: pillow in /usr/lib/python3/dist-packages (from nudepy) (5.4.1)
Building wheels for collected packages: nudepy
  Building wheel for nudepy (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-efz9gp75/nudepy_370d0f97a460431abc3646fde64bad7d/setup.py'"'"'; __file__='"'"'/tmp/pip-install-efz9gp75/nudepy_370d0f97a460431abc3646fde64bad7d/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-7_jmbwcy
       cwd: /tmp/pip-install-efz9gp75/nudepy_370d0f97a460431abc3646fde64bad7d/
  Complete output (9 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.7
  copying nude.py -> build/lib.linux-x86_64-3.7
  running build_ext
  cythoning skin_classifier.pyx to skin_classifier.c
  error: /tmp/pip-install-efz9gp75/nudepy_370d0f97a460431abc3646fde64bad7d/skin_classifier.pyx
  ----------------------------------------
  ERROR: Failed building wheel for nudepy
  Running setup.py clean for nudepy
Failed to build nudepy
Installing collected packages: nudepy, install
    Running setup.py install for nudepy ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-efz9gp75/nudepy_370d0f97a460431abc3646fde64bad7d/setup.py'"'"'; __file__='"'"'/tmp/pip-install-efz9gp75/nudepy_370d0f97a460431abc3646fde64bad7d/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-hb578l86/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/lskywalker416/.local/include/python3.7m/nudepy
         cwd: /tmp/pip-install-efz9gp75/nudepy_370d0f97a460431abc3646fde64bad7d/
    Complete output (9 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    copying nude.py -> build/lib.linux-x86_64-3.7
    running build_ext
    cythoning skin_classifier.pyx to skin_classifier.c
    error: /tmp/pip-install-efz9gp75/nudepy_370d0f97a460431abc3646fde64bad7d/skin_classifier.pyx
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-efz9gp75/nudepy_370d0f97a460431abc3646fde64bad7d/setup.py'"'"'; __file__='"'"'/tmp/pip-install-efz9gp75/nudepy_370d0f97a460431abc3646fde64bad7d/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-hb578l86/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/lskywalker416/.local/include/python3.7m/nudepy Check the logs for full command output.

Host: Google Cloud VM
Release: Debian GNU/Linux 10 (buster)
Python version: Python 3.7.3
Pip version: pip 21.2.4

Create Amenities Table

--Create Amenities Table
CREATE TABLE Amenities (
amenity_id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(100)
);

-- Create Property_Amenities Table (to represent the amenities associated with each property)
CREATE TABLE Property_Amenities (
property_id INT,
amenity_id INT,
PRIMARY KEY (property_id, amenity_id),
FOREIGN KEY (property_id) REFERENCES Properties(property_id),
FOREIGN KEY (amenity_id) REFERENCES Amenities(amenity_id)
);

-- Create Neighborhoods Table
CREATE TABLE Neighborhoods (
neighborhood_id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(100)
);

-- Create Property_Neighborhoods Table (to represent the neighborhoods associated with each property)
CREATE TABLE Property_Neighborhoods (
property_id INT,
neighborhood_id INT,
PRIMARY KEY (property_id, neighborhood_id),
FOREIGN KEY (property_id) REFERENCES Properties(property_id),
FOREIGN KEY (neighborhood_id) REFERENCES Neighborhoods(neighborhood_id)
);

False positive for a test example

I cloned the project and ran the tests immediately and got "True" for damita2.jpg from the examples. I will investigate to see what causes this.

Support for BytesIO (or StringIO) image ?

I currently want to integrate nudepy with one of my IRC Bot. (Some friends of me sends NSFW pics and people should be warned that it's NSFW)
The fact is that I don't want to write the image on disk before analyzing it.
Using requests, I can store the whole image in a BytesIO (or StringIO for python 2) in RAM instead of on disk.
Is there a workaround to work with in RAM files ?

not build at m1

>pip install nudepy
Collecting nudepy
  Using cached nudepy-0.5.1.tar.gz (35 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: pillow in ./.venv/lib/python3.11/site-packages (from nudepy) (9.5.0)
Installing collected packages: nudepy
  DEPRECATION: nudepy is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
  Running setup.py install for nudepy ... error
  error: subprocess-exited-with-error
  
  × Running setup.py install for nudepy did not run successfully.
  │ exit code: 1
  ╰─> [17 lines of output]
      running install
      /Users/vvzvlad/Downloads/nudecrawler/.venv/lib/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.macosx-13-arm64-cpython-311
      copying nude.py -> build/lib.macosx-13-arm64-cpython-311
      running build_ext
      building 'skin_classifier' extension
      creating build/temp.macosx-13-arm64-cpython-311
      clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/vvzvlad/Downloads/nudecrawler/.venv/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c skin_classifier.c -o build/temp.macosx-13-arm64-cpython-311/skin_classifier.o
      skin_classifier.c:196:12: fatal error: 'longintrepr.h' file not found
        #include "longintrepr.h"
                 ^~~~~~~~~~~~~~~
      1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> nudepy

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

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.