Skip to main content

A package for image hashing

Project description

perception ci

perception provides flexible, well-documented, and comprehensively tested tooling for perceptual hashing research, development, and production use. See the documentation for details.

Background

perception was initially developed at Thorn as part of our work to eliminate child sexual abuse material from the internet. For more information on the issue, check out our CEO's TED talk.

Getting Started

Installation

pip install opencv-python perception

Hashing

Hashing with different functions is simple with perception.

from perception import hashers

file1, file2 = 'test1.jpg', 'test2.jpg'
hasher = hashers.PHash()
hash1, hash2 = hasher.compute(file1), hasher.compute(file2)
distance = hasher.compute_distance(hash1, hash2)

Examples

See below for end-to-end examples for common use cases for perceptual hashes.

Supported Hashing Algorithms

perception currently ships with:

  • pHash (DCT hash) (perception.hashers.PHash)
  • Facebook's PDQ Hash (perception.hashers.PDQ)
  • dHash (difference hash) (perception.hashers.DHash)
  • aHash (average hash) (perception.hashers.AverageHash)
  • Marr-Hildreth (perception.hashers.MarrHildreth)
  • Color Moment (perception.hashers.ColorMoment)
  • Block Mean (perception.hashers.BlockMean)
  • wHash (wavelet hash) (perception.hashers.WaveletHash)

Contributing

To work on the project, start by doing the following.

# Install local dependencies for
# code completion, etc.
make init

# Build the Docker container to run
# tests and such.
make build
  • Running make init will update this repository's dependencies and preserve the results in Pipfile.lock. We strongly recommend including changes to the lock alongside any other changes that may have been made.
  • You can get a JupyterLab server running to experiment with using make lab-server.
  • To do a (close to) comprehensive check before committing code, you can use make precommit.
  • To view the documentation, use make documentation-server.

To implement new features, please first file an issue proposing your change for discussion.

To report problems, please file an issue with sample code, expected results, actual results, and a complete traceback.

Alternatives

There are other packages worth checking out to see if they meet your needs for perceptual hashing. Here are some examples.

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

perception-0.6.1.tar.gz (1.3 MB view details)

Uploaded Source

Built Distributions

perception-0.6.1-py3-none-any.whl (1.3 MB view details)

Uploaded Python 3

perception-0.6.1-cp310-cp310-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.10 Windows x86-64

perception-0.6.1-cp39-cp39-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.9 Windows x86-64

perception-0.6.1-cp38-cp38-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.8 Windows x86-64

perception-0.6.1-cp37-cp37m-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.7m Windows x86-64

File details

Details for the file perception-0.6.1.tar.gz.

File metadata

  • Download URL: perception-0.6.1.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.13

File hashes

Hashes for perception-0.6.1.tar.gz
Algorithm Hash digest
SHA256 6f52ec96ce62093d37e7c53703e5e2a95c780c9959d1129b97d17145faf75500
MD5 0582bb7c6e2ea347b2cec67b7b736944
BLAKE2b-256 f18427ee04f25a981bf61eef095d98e33122b5a78987dfd93e14d9fe63489c5f

See more details on using hashes here.

File details

Details for the file perception-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: perception-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.13

File hashes

Hashes for perception-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 55a478a1ca96c3c6f7f5951a8a5c4bc4b30cefe2214ad01e33379abffe497f28
MD5 25b14aeed10b21a1985b33699582aa49
BLAKE2b-256 61e5c0503d28013dc137f2d9914c385fe389c9e8335a0607af52bf5e465d2978

See more details on using hashes here.

File details

Details for the file perception-0.6.1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for perception-0.6.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6cf6907ed7d85172c7cd8f4fba146b459a665d65bc625be2d0c299d939500c27
MD5 0b7b8ec12df2f4cb29317c703e98e114
BLAKE2b-256 6db87957c78d497702378d98558851ab26db951de2e7df3e715327a10b1b7edc

See more details on using hashes here.

File details

Details for the file perception-0.6.1-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for perception-0.6.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 f3f7a47c3d580d25b378544a1bf6146ca21337f4f027b04df935169b588b7f3f
MD5 23f9c40505a2f7c8cd4c819e871bb130
BLAKE2b-256 aebd580a35f749b5ece6d6cae67ee7d3ebe48f0478af512e3996fe402f236ef7

See more details on using hashes here.

File details

Details for the file perception-0.6.1-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for perception-0.6.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 0cf59b55f82a071169c10785f1ea345b2cc0ca74aecdb1a1b62017f68e12b86a
MD5 3346460fdc6e2fce05a050dd8ec380b6
BLAKE2b-256 dd2210b33a1ba364f8a10791af2720a222763c7123ae6abe9d4f76630fa3bde3

See more details on using hashes here.

File details

Details for the file perception-0.6.1-cp37-cp37m-win_amd64.whl.

File metadata

File hashes

Hashes for perception-0.6.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 2fdd6b2435c6a3ed6d071f5b9d80fadcf262d5c33187155e327839057835662d
MD5 6cc52ec72d132627108a9baf3b156e5c
BLAKE2b-256 e3cd5ffb6501c0c585f3c7c8039e9a79acd47ed1b6bcb3b9367ad6e2d0cdc2e3

See more details on using hashes here.

Supported by

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