Some useful extensions to thumbor - extra filters and detectors.
Project description
thumbor_extras
Some useful extensions to thumbor - extra filters and detectors.
pip install thumbor_extras
Detectors
Add these detectors to your thumbor.conf
:
DETECTORS = [
'thumbor_extras.detectors.dnn_face_detector',
'thumbor_extras.detectors.dnn_object_detector'
]
dnn_face_detector
An improved face detector that uses a deep neural network. More specifically, it uses the SSD object detection model, trained specifically on faces. According to the OpenCV repo, it was trained with "some huge and available online dataset." :/
For more information on how the normal thumbor face detector compares to this one in both accuracy and efficiency, see this comparison script.
dnn_object_detector
The full SSD object detection model, trained on the COCO dataset. It was built as a MobileNet, a class of efficient, light weight deep neural network models meant to work well in mobile and embedded applications.
Filters
Add these filters to your available filters in thumbor.conf
:
FILTERS = [
...other filters,
'thumbor_extras.filters.draw_center_of_mass',
'thumbor_extras.filters.draw_focal_points'
]
draw_center_of_mass
Draws a circle at the calculated center of mass, according to the focal points.
Usage: draw_center_of_mass([r, g, b])
Examples:
draw_center_of_mass()
: draws a circle with default red color.draw_center_of_mass(0,0,255)
: draws a blue circle.
draw_focal_points
Draws a box around the focal points, for displaying the results of the detectors on a given image. Takes optional arguments for box color and line width.
Usage: draw_focal_points([line_width, show_heatmap, show_labels, show_rainbow, r, g, b])
Arguments:
line_width
: the width of the box linesshow_heatmap
: make the box more opaque for higher-confidence detections, more transparent for less confident detectionsshow_labels
: print the class label at the top of the boxshow_rainbow
: use a different color for each focal point box; pass false to provide a single color RGB value for all boxesr
: R component of RGB color of box, default 0g
: G component of RGB color of box, default 255b
: B component of RGB color of box, default 0
Examples:
draw_focal_points()
: draws boxes with defaults (green color and 3 pixel line width).draw_focal_points(5,false,false,false,255,0,0)
: draws solid red boxes with 5 pixel line width, and no class labels.
TODO
- Choose thresholds empirically
Development
Because I will definitely forget. Python development can be a pain.
# use python 2 - thumbor doesn't support 3 yet.
virtualenv thumbor_env --python=/path/to/python2
source thumbor_env/bin/activate
# develop
pip install -e .
# test
# i don't know why setup.py can't install pytest...but it fails without manual install.
# it could be a python2 / mac thing.
pip install pytest
python setup.py test
# distribute to pip
python setup.py sdist bdist_wheel
pip install twine
python
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for thumbor_extras-1.0.0-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c796df4ba092f4b9ae162a564e8fd97c87f781fdcd7e0163ecc2725c1b34fe30 |
|
MD5 | 94c84b6ebeddb143d831e7704f7937a7 |
|
BLAKE2b-256 | 8b7d78ca14849835919bfca79240c02774da0da030bfa847650a37c683d33f44 |