analitics

Pages

Monday, January 28, 2019

Testing imageio python module.

This python module comes with this intro from pypi website:
Imageio is a Python library that provides an easy interface to read and write a wide range of image data, including animated images, volumetric data, and scientific formats. It is cross-platform, runs on Python 2.7 and 3.4+, and is easy to install.
Let's install this python module:
C:\>cd C:\Python364
C:\Python364>cd Scripts
C:\Python364\Scripts>pip3.6.exe install imageio
Collecting imageio
...
Successfully built imageio
Installing collected packages: imageio
Successfully installed imageio-2.4.1
You are using pip version 18.0, however version 18.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' comm
and.
I tested with a simple read medical data (DICOM - CT-MONO2-16-brain), see here.
The Digital Imaging and Communications in Medicine (DICOM) standard start with the basic idea is that patient and machine-readable information is embedded within a file (usually an image) as it’s created or converted.
This is a simple example without security.
Without encrypted connections between applications, anyone on the network could intercept the DICOM files and extract the patient information.
The Imageio provides a range of example images:
  1. Read an image;
  2. Iterate over frames in a movie;
  3. Grab screenshot or image from the clipboard;
  4. Convert a movie;
  5. Writing videos with FFMPEG and vaapi;
All file formats (93 files type ) can be read by this python module, see webpage here.
The examples from the official webpage work well.
Only the example with the DICOM file cannot be tested.
The main reason: I try to find a DICOM file but I don't find one.

Saturday, January 26, 2019

Testing the webpy python module.

Today I wrote about another python module named web.py.
The reasons I start this tutorial come from google page of SDK for App Engine.
The Google come with these options of the following frameworks can be used with Python programming language:
  • Flask;
  • Django;
  • Pyramid;
  • Bottle;
  • web.py
  • Tornado
I started in the past to learn and use Django and I tested with Flask and Bottle and today is web.py python module.
First, about this python module I can tell you is a simple web framework and comes with a web.py slogan:
Think about the ideal way to write a web app. Write the code to make it happen.
C:\Python364\Scripts>pip install web.py==0.40-dev1
Collecting web.py==0.40-dev1
  Downloading https://files.pythonhosted.org/packages/db/a5/8dfacc190908f9876632
69a92efa682175c377e3f7eab84ed0a89c963b47/web.py-0.40.dev1.tar.gz (117kB)
    100% |████████████████████████████████| 122kB 936kB/s
Building wheels for collected packages: web.py
  Building wheel for web.py (setup.py) ... done
  Stored in directory: C:\Users\catafest\AppData\Local\pip\Cache\wheels\1b\15\12
\4fd91f5ed7e3c8aae085050cce83f72b7ca4f463bf3e67d2b7
Successfully built web.py
Installing collected packages: web.py
Successfully installed web.py-0.40.dev1
Let's test the example from the official website:
C:\Python364>python.exe
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)]
 on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import web
>>>
... urls = (
...     '/(.*)', 'hello'
... )
>>> app = web.application(urls, globals())
>>>
>>> class hello:
...     def GET(self, name):
...         if not name:
...             name = 'World'
...         return 'Hello, ' + name + '!'
...
>>> if __name__ == "__main__":
...     app.run()
...
http://0.0.0.0:8080/
127.0.0.1:50542 - - [27/Jan/2019 07:30:28] "HTTP/1.1 GET /" - 200 OK
127.0.0.1:50542 - - [27/Jan/2019 07:30:28] "HTTP/1.1 GET /favicon.ico" - 200 OK
The server starts at 0.0.0.0 (invalid address) and can see the result at 127.0.0.1:8080.

Tuesday, January 1, 2019

Detect nudity with nudepy python module.

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 #
====================
test_nude_002.jpg
Nude file:  False
and test result:  False #
====================
test_nude_003.jpg
Nude file:  False
and test result:  False #
====================
test_nude_004.jpg
Nude file:  True
and test result:  True #
====================