Skip to main content

Detect faces and draw overlay images

Project description

Snappy 2

PyPI version

Introduction

Snappy2 makes it easy to draw fun overlays on images. It uses a neural network to detect face keypoints and then uses those key points to draw overlays such as glasses, mustaches, hats, ears, and custom overlays on the face. The library is easy to use and comes with several code examples to get started quickly with a variety of drawing options:

  • draw glasses
  • draw mustache
  • draw hat
  • draw ears
  • draw any overlay
  • draw text

Click here for live snappy2 demo.

Classes

  1. Snappy2: the main class object and one place for all snappy library control.
  2. Detector: provides advanced functionality for getting face keypoints.
  3. FacePainter: helper functions for drawing on top of images based on the received keypoints.

Imports

from snappy2 import Snappy2

Code Examples (How to)

  • Draw Mustache on face (3 lines)
snappy = Snappy2()

human_image = snappy.load_image('<file_path>')
snappy.set_mustache(human_image, mus_index=0)
  • Draw glasses on face (3 lines)
snappy = Snappy2()

human_image = snappy.load_image('<file_path>')
snappy.set_glasses(human_image, gls_index=0)
  • Draw ears on face (3 lines)
snappy = Snappy2()

human_image = snappy.load_image('<file_path>')
snappy.set_ears(human_image, gls_index=0)
  • Draw text
snappy = Snappy2()

human_image = snappy.load_image('<file_path>')
# parameters: path, text, text size, drawing location.
snappy.set_text(human_image, 'Snappy2', 60, v_position='bottom')
  • Display image for validation
human_image.show()

Github setup

Github code available here.
For more examples check the (Demo.py).

Disclaimer

This library utilizes photos that are freely accessible on the web. If any of the example photos have licensing restrictions, please reach out to the library owner directly for clarification or removal.

License

The MIT License (MIT)

Copyright (c) 2017 Ahmad Barqawi (github.com/Barqawiz)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

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

snappy2-0.3.tar.gz (22.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snappy2-0.3-py3-none-any.whl (44.7 MB view details)

Uploaded Python 3

File details

Details for the file snappy2-0.3.tar.gz.

File metadata

  • Download URL: snappy2-0.3.tar.gz
  • Upload date:
  • Size: 22.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for snappy2-0.3.tar.gz
Algorithm Hash digest
SHA256 5d3f3301d625c624698e90c21790d37baecc79231f50eeece480b7a41d6887ff
MD5 bf168deeea6281900bf975709d7faf5b
BLAKE2b-256 81074c8e6b37819f0e1d94caf43483f0682474f498c453ae9ced19a9aa77f191

See more details on using hashes here.

File details

Details for the file snappy2-0.3-py3-none-any.whl.

File metadata

  • Download URL: snappy2-0.3-py3-none-any.whl
  • Upload date:
  • Size: 44.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for snappy2-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 60d002a69b254bc79a09d4c7e8d46d41a50871c439e71e2648cee7631c0da172
MD5 471464146e545a3d2924cada9e4db2d9
BLAKE2b-256 7d307db8aa3e38f4eb5b9399ed06feb0e842c7bc0b5f9c6a95cfe8293dfe8b18

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page