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.6.tar.gz (1.3 MB view details)

Uploaded Source

Built Distributions

perception-0.6.6-pp38-pypy38_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.5 MB view details)

Uploaded PyPy manylinux: glibc 2.12+ x86-64

perception-0.6.6-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.5 MB view details)

Uploaded PyPy manylinux: glibc 2.12+ x86-64

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

Uploaded CPython 3.10 Windows x86-64

perception-0.6.6-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.12+ x86-64

perception-0.6.6-cp310-cp310-macosx_10_9_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

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

Uploaded CPython 3.9 Windows x86-64

perception-0.6.6-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

perception-0.6.6-cp39-cp39-macosx_10_9_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

perception-0.6.6-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

perception-0.6.6-cp38-cp38-macosx_10_9_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

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

Uploaded CPython 3.7m Windows x86-64

perception-0.6.6-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

perception-0.6.6-cp37-cp37m-macosx_10_9_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

perception-0.6.6-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for perception-0.6.6.tar.gz
Algorithm Hash digest
SHA256 906f33d19d311024520f63f711b6cc9d8703be5d33dcf46479eb5e7a227cd1e4
MD5 388a050ef4f98181a00db4019b24af65
BLAKE2b-256 1ee729eab3e553afca97e5fbafebca8b92e266b5d67b433a2f7fe8bf9faa8c08

See more details on using hashes here.

File details

Details for the file perception-0.6.6-pp38-pypy38_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for perception-0.6.6-pp38-pypy38_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 7d1b6c12508c0f47a912299317b0a13ee2ec14c7adb7c503d3f29dbf00c8269d
MD5 b166beee0e804e36206de486a55a9411
BLAKE2b-256 f5a6917874ea1cd5be8d7c8cb4ee634ed1769eb158d07675759114f4433fbe13

See more details on using hashes here.

File details

Details for the file perception-0.6.6-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for perception-0.6.6-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 01829787cba34d52f5d326c78bebd3a3e1ca41a887b5e1601833b884854eba5a
MD5 fb0c49cb3be4013faecf8a2044d45bb0
BLAKE2b-256 1fcc8cd6e2998a9af1fe8193f98c865531561e7ae84ccfd164e39205199e8547

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for perception-0.6.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3006655cc1b7ec6301e85c72a23e2adae40a2234c2d5dafc569d5658c3aad08d
MD5 f44a593a5e32fbb831245d73aef46782
BLAKE2b-256 ee383a90f95c3364457e0945b34792570a79bda22e23fe97902f7625cd6b73f0

See more details on using hashes here.

File details

Details for the file perception-0.6.6-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for perception-0.6.6-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 f8f03f033e24ef5a4c53a34430a799363290172db574f7438d10b3c4b9b87120
MD5 1c3be338596a78e83fb4877ecd74b1eb
BLAKE2b-256 cba844bb7bd29f372e40f154f981532324b7031352eee21c45ec491282363bd1

See more details on using hashes here.

File details

Details for the file perception-0.6.6-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for perception-0.6.6-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d879f6a317fc61e5022419de98828a23937ac5186eb63270338645fab7df2abe
MD5 73728255f7b42b954409109727000944
BLAKE2b-256 823af402fa902fb5b4a0ee10a2c35c07da4131c17f43f473a678c43ee7ae191f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for perception-0.6.6-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 4733bf007b2403e925af8024a4ea4a2804c6162bc486f610c1dac920a71d5a2a
MD5 0641187739369151fd57e98a03ca925d
BLAKE2b-256 757a0b0f03d89b27fda68c5f7a50c33ad742a6639478335a04bf895195ddadd9

See more details on using hashes here.

File details

Details for the file perception-0.6.6-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for perception-0.6.6-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 ab44761d69eafeaa79105b86e5ce3772e1bbe860d63f05df1d3eb3843fe6f4e3
MD5 45eb4b4c0bee808c3dbb39e953e8f4bb
BLAKE2b-256 31ef0983a060d3112ed45761476c5d4d2e09af79087b52c97db564a19f23b81e

See more details on using hashes here.

File details

Details for the file perception-0.6.6-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for perception-0.6.6-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4b40577c18e948d3502f8dfb070d5d99e5aba27729641d4fcbf50efed3bb08f4
MD5 d9879bc0014c1e9b30f128d113348bdd
BLAKE2b-256 e47484ae41174261eaa8e54adf95d0ab558173c387f49cf01ab10427fcccb24d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for perception-0.6.6-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 9d98569d79abf9074ec3966d445f4f5af1505e84a4da335bac4128f70f805b34
MD5 db3ff51944b33d7a79044438e85c2198
BLAKE2b-256 9390dff7803c3b883fd253869ab9fdf4fe4cc26dacf5372de7817178230097fd

See more details on using hashes here.

File details

Details for the file perception-0.6.6-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for perception-0.6.6-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 3716cdeccbffc040638a0a7239b01e1d91e58d28fe51f91445e0a29f9dfc2942
MD5 cc213e795c0b695f92bc83fbc56f1e9b
BLAKE2b-256 8364bb8d2ebb0709581e2105fcf021517a1a7da00e5be154783888735fc3dfc5

See more details on using hashes here.

File details

Details for the file perception-0.6.6-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for perception-0.6.6-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 37a151fd5030019fbb0ccaeca693674934da06378744570420cea55bd35111bb
MD5 35f4554aadfd21ec6a5ee6853b7bb723
BLAKE2b-256 8c39a542def2dc48b75f66b8a981895c55da4597fb942937c303752d5c234778

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for perception-0.6.6-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 46ed6d7f96bd7527efc002eea10c2aa869334c0e671a584e422a6294a30fa5c0
MD5 60a22d191e3ef5762a916769ccdd5f7f
BLAKE2b-256 6f7da84bf207a835aec7c3591b430192b100bba854a3369238675e2edfba7a56

See more details on using hashes here.

File details

Details for the file perception-0.6.6-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for perception-0.6.6-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 7ce40fe44728448fa393788941f837e523df98d74d307ef0972bdaa3eef67269
MD5 1039ba9bba488df4e2b2b893a6d3cce9
BLAKE2b-256 94c061af198c0c989db0e4220f0cf54e0365ee9adcf8a40c09005a66dca1c031

See more details on using hashes here.

File details

Details for the file perception-0.6.6-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for perception-0.6.6-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b9a21bb7056d644c93e9ddc11c73ec61a803ee89513734b6388170cd950f08e5
MD5 b44bef3daa8f9c8418fc36c14f3ada51
BLAKE2b-256 740afdad13a6e8468a251b82e0a4ecd50538173146f8ae8e98f2b3708f158513

See more details on using hashes here.

File details

Details for the file perception-0.6.6-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for perception-0.6.6-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 77f8338f5fc4899a784f61ab3d06b8d188072deab67a0c4b665f54eb58fb6cf0
MD5 2442b20b4f5414fb394f963e2dca8b73
BLAKE2b-256 50ee7832b65e8d948408173feb2012f0a924d81f8599b92455773796d5baf984

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