Perception provides flexible, well-documented, and comprehensively tested tooling for perceptual hashing research, development, and production use.
Project description
perception 
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 perception
Optional extras
perception provides optional extras for additional functionality:
approximate-deduplication– FAISS-based approximate-nearest-neighbor deduplication and graph community/clique detection (used byperception.approximate_deduplicationandperception.local_descriptor_deduplication)benchmarking– tools for benchmarking perceptual hashesmatching– async matching utilitiespdq– Facebook's PDQ hash support
Note for benchmarking extra users: The benchmarking extra depends on
albumentations, which in turn requires opencv-python-headless. However,
perception already depends on opencv-contrib-python-headless (needed for
contrib modules such as cv2.img_hash and cv2.SIFT_create). Installing both
OpenCV distributions simultaneously causes file-level conflicts.
If you are using uv, this is handled automatically:
uv pip install "perception[benchmarking]"
If you are using plain pip, install the extra and then force-reinstall the
contrib variant to remove the conflicting headless package:
pip install "perception[benchmarking]"
pip install --force-reinstall --no-deps opencv-contrib-python-headless
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,
# testing, and linting.
make init
To do a (close to) comprehensive check before committing code, use make precommit.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file perception-0.9.0.tar.gz.
File metadata
- Download URL: perception-0.9.0.tar.gz
- Upload date:
- Size: 11.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
844c19bd5bb2710c7fd71b1ec876cfcc443cb223ab0122ba94e93172025cd68e
|
|
| MD5 |
24f5605b5dba874ec42494ce031bff59
|
|
| BLAKE2b-256 |
7e2588faf64764e7d2e580445cf07a81a8ccf75357f1626146fbe081ea3eb172
|
File details
Details for the file perception-0.9.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: perception-0.9.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 6.7 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
764dce9e5d82e667fc4359613c045b0d4d5332d5d7ac1755fb67c9bb0c00cf4b
|
|
| MD5 |
95b38c6e869fb4d860d88347b112103f
|
|
| BLAKE2b-256 |
202d03332d49c5c911f6b67373eb395fec75ca480d3dd2a6e8c31d3655e498c5
|
File details
Details for the file perception-0.9.0-cp313-cp313-manylinux_2_24_x86_64.whl.
File metadata
- Download URL: perception-0.9.0-cp313-cp313-manylinux_2_24_x86_64.whl
- Upload date:
- Size: 7.4 MB
- Tags: CPython 3.13, manylinux: glibc 2.24+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
140857463e20892ea69032e1e7f9ef587c1beb3b9042ad332111a3f424a33f23
|
|
| MD5 |
8a3244f834a9d5ca38162794fe879507
|
|
| BLAKE2b-256 |
0f3afb6e1ee2b100d13cd76b014f6bf1b053ff619084aba4dc7290174f22bbd5
|
File details
Details for the file perception-0.9.0-cp313-cp313-macosx_15_0_arm64.whl.
File metadata
- Download URL: perception-0.9.0-cp313-cp313-macosx_15_0_arm64.whl
- Upload date:
- Size: 6.5 MB
- Tags: CPython 3.13, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
349ee9ead473f4223bf14bd797578372a1cfe9cde956c12243256c9e156096b5
|
|
| MD5 |
3eaaf69549130179317aa9dadd6a24c8
|
|
| BLAKE2b-256 |
c410191a884c76cc9bea64f12cf26a852dc8685937b27c173846e3af2b091c38
|
File details
Details for the file perception-0.9.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: perception-0.9.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 6.7 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55092bdc52e0b771a2ffba09196a9808e161af49c87d267e79733dfb09724def
|
|
| MD5 |
c6baf3a8b195fa0d2b5cc829860126ce
|
|
| BLAKE2b-256 |
0ea433a401986b293a6ba38fcfc02e772dfdb6f01be338707aed950b9c167e11
|
File details
Details for the file perception-0.9.0-cp312-cp312-manylinux_2_24_x86_64.whl.
File metadata
- Download URL: perception-0.9.0-cp312-cp312-manylinux_2_24_x86_64.whl
- Upload date:
- Size: 7.2 MB
- Tags: CPython 3.12, manylinux: glibc 2.24+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6e823836613c78f069d3b84cd07ada6fe67ab190b3a01150785743dfdd85029
|
|
| MD5 |
cc9b556e58ecf6b0ee5016cc6148fd39
|
|
| BLAKE2b-256 |
a0dfdd38c59db4232136c6d1975cd9e790c50394efdc4de14698e949b9f71223
|
File details
Details for the file perception-0.9.0-cp312-cp312-macosx_10_13_universal2.whl.
File metadata
- Download URL: perception-0.9.0-cp312-cp312-macosx_10_13_universal2.whl
- Upload date:
- Size: 6.6 MB
- Tags: CPython 3.12, macOS 10.13+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bbedb9cb2a0a0899c5280eaae00d98006858d8ca69c093dc1db0711c3025c92
|
|
| MD5 |
99a9653e211034efbfc34f97029784b8
|
|
| BLAKE2b-256 |
7e6bbc0dd287215167ca10b69e48228c16cc56d9d21a454454777bd32813e442
|
File details
Details for the file perception-0.9.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: perception-0.9.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 6.7 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39654edf06b574f3fa41c94ddc6f1dd5d79b41d5ec4fb6deed95cf222bcb3558
|
|
| MD5 |
7b8cb27a27d09bca4e4f3bacb9c18e0b
|
|
| BLAKE2b-256 |
59796f7bcc22be705ae307eb4757601698240ea7858ba0773d23be77770800ea
|
File details
Details for the file perception-0.9.0-cp311-cp311-manylinux_2_24_x86_64.whl.
File metadata
- Download URL: perception-0.9.0-cp311-cp311-manylinux_2_24_x86_64.whl
- Upload date:
- Size: 7.4 MB
- Tags: CPython 3.11, manylinux: glibc 2.24+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c32a94f99b9a2d66489563199f631716ccba55444a89ed9f403ae1fa00e3f88c
|
|
| MD5 |
f3b69855a30a8d7dcad62437930e28b2
|
|
| BLAKE2b-256 |
cbf2ace214d2d33ced045ccc3df77a1135d7e913c28a993913cd68c1ab91f333
|
File details
Details for the file perception-0.9.0-cp311-cp311-macosx_10_9_universal2.whl.
File metadata
- Download URL: perception-0.9.0-cp311-cp311-macosx_10_9_universal2.whl
- Upload date:
- Size: 6.6 MB
- Tags: CPython 3.11, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56578829a943023cf04f0113584460f1ea133a4b25ab8347a1f2baa18ac93fb9
|
|
| MD5 |
993de0d6d4856e6ddfded37930a3ccdc
|
|
| BLAKE2b-256 |
b6abb98463cb22a150a1f5c6d01266d329441815e5c20b9bf8512e2c66c0e599
|
File details
Details for the file perception-0.9.0-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: perception-0.9.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 6.7 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44afaf3c16220a9e3729baafcbb06caef96822b571d52d2a4f5ccb7a4c28c3d6
|
|
| MD5 |
1feb7ecb101cc69d26268465b815bec3
|
|
| BLAKE2b-256 |
0121ace0607624d75ad5b3aa47252553d18d37f2e5239cce052fcf07d63cc74c
|
File details
Details for the file perception-0.9.0-cp310-cp310-manylinux_2_24_x86_64.whl.
File metadata
- Download URL: perception-0.9.0-cp310-cp310-manylinux_2_24_x86_64.whl
- Upload date:
- Size: 7.4 MB
- Tags: CPython 3.10, manylinux: glibc 2.24+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ade316bd844ef8a2c77e42c93575da1ef3a208e2b056ce75f707a50ee5a15369
|
|
| MD5 |
7f21150c0a276fd6a4d621f06f769951
|
|
| BLAKE2b-256 |
0d60ee96e44c3daacdc6f1b011a75a4290df03a885986dedf4b0d2859389f50b
|
File details
Details for the file perception-0.9.0-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: perception-0.9.0-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 6.5 MB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2c6f92bc8386bdcfe66cf30cb3a3b217c01b9938acc049351ab0347580bea84
|
|
| MD5 |
2eb6c7786dfbd2c56157da14b7a6770f
|
|
| BLAKE2b-256 |
83e180547783a6d4aa2b3657789ad1919672a68605c2f1a47c5537e322488966
|