Quantcast
Channel: Planet Python
Viewing all articles
Browse latest Browse all 23375

Catalin George Festila: Detect nudity with nudepy python module.

$
0
0
Today I tested another python module named nudepy.
You can find it here.
This python module is a port of nude.js to Python.
Let's start the tutorial with the installation:
C:\Python364\Scripts>cd ..

C:\Python364>cd Scripts

C:\Python364\Scripts>pip install nudepy
Requirement already satisfied: nudepy in c:\python364\lib\site-packages (0.4)
Requirement already satisfied: pillow in c:\python364\lib\site-packages (from nu
depy) (5.3.0)
To test this python module, I used four images with the idea of a nude image
This image is the result of all images of the test.

This image files are named:
  • test_nude_001.jpg
  • test_nude_002.jpg
  • test_nude_003.jpg
  • test_nude_004.jpg
Let's see the script:
# for select jpeg files
import os, fnmatch
# import nude python module
import nude
from nude import Nude
#
nude_jpegs=fnmatch.filter(os.listdir('.'), '*nude*.jpg')
print(nude_jpegs)
for found_file in nude_jpegs:
print (found_file)
print("Nude file: ",nude.is_nude(str(found_file)))
n = Nude(str(found_file))
n.parse()
print("and test result: ", n.result, n.inspect())
print("====================")
The result of the output script is this:
C:\Python364>python.exe test_nude.py
['test_nude_001.jpg', 'test_nude_002.jpg', 'test_nude_003.jpg', 'test_nude_004.j
pg']
test_nude_001.jpg
Nude file: False
and test result: False #
x500'): result=False message='Less than 3 skin regions (0)'>
====================
test_nude_002.jpg
Nude file: False
and test result: False #
x564'): result=False message='The biggest region contains less than 45 (40.209%)
'>
====================
test_nude_003.jpg
Nude file: False
and test result: False #
x674'): result=False message='Less than 3 skin regions (0)'>
====================
test_nude_004.jpg
Nude file: True
and test result: True #
746'): result=True message='Nude!!'>
====================

Viewing all articles
Browse latest Browse all 23375

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>