Skip to main content

Perception provides flexible, well-documented, and comprehensively tested tooling for perceptual hashing research, development, and production use.

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 perception

Optional extras

perception provides optional extras for additional functionality:

  • benchmarking – tools for benchmarking perceptual hashes
  • matching – async matching utilities
  • pdq – 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


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

Uploaded Source

Built Distributions

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

perception-0.8.5-cp313-cp313-win_amd64.whl (6.7 MB view details)

Uploaded CPython 3.13Windows x86-64

perception-0.8.5-cp313-cp313-manylinux_2_24_x86_64.whl (7.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ x86-64

perception-0.8.5-cp313-cp313-macosx_15_0_arm64.whl (6.5 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

perception-0.8.5-cp312-cp312-win_amd64.whl (6.7 MB view details)

Uploaded CPython 3.12Windows x86-64

perception-0.8.5-cp312-cp312-manylinux_2_24_x86_64.whl (7.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ x86-64

perception-0.8.5-cp312-cp312-macosx_10_13_universal2.whl (6.6 MB view details)

Uploaded CPython 3.12macOS 10.13+ universal2 (ARM64, x86-64)

perception-0.8.5-cp311-cp311-win_amd64.whl (6.7 MB view details)

Uploaded CPython 3.11Windows x86-64

perception-0.8.5-cp311-cp311-manylinux_2_24_x86_64.whl (7.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64

perception-0.8.5-cp311-cp311-macosx_10_9_universal2.whl (6.6 MB view details)

Uploaded CPython 3.11macOS 10.9+ universal2 (ARM64, x86-64)

perception-0.8.5-cp310-cp310-win_amd64.whl (6.7 MB view details)

Uploaded CPython 3.10Windows x86-64

perception-0.8.5-cp310-cp310-manylinux_2_24_x86_64.whl (7.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ x86-64

perception-0.8.5-cp310-cp310-macosx_11_0_arm64.whl (6.5 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: perception-0.8.5.tar.gz
  • Upload date:
  • Size: 11.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","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

Hashes for perception-0.8.5.tar.gz
Algorithm Hash digest
SHA256 6a2a2df8eba2241db08c5956b15fe9fed57446496edd124e34f15c302292fe9f
MD5 1f9fd048493c0a2551108e046324ce35
BLAKE2b-256 ca8426ccb455b33b559fb103d5ab43c342be9ec2a896b2a919d395899a684023

See more details on using hashes here.

File details

Details for the file perception-0.8.5-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: perception-0.8.5-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.13 {"installer":{"name":"uv","version":"0.11.13","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

Hashes for perception-0.8.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 5a5263881576f00dff55b501564fd9024cd7e1471f5ae7a8002f54291bd82fb8
MD5 900e0511bde4cf3d1d6fdaabe44fff7c
BLAKE2b-256 991b94d7f903d39eac0390c0105d24eeba874b56a7d76f9acd6683bc799d50e8

See more details on using hashes here.

File details

Details for the file perception-0.8.5-cp313-cp313-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: perception-0.8.5-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.13 {"installer":{"name":"uv","version":"0.11.13","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

Hashes for perception-0.8.5-cp313-cp313-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 963e683f5204b76f88e501179ac97dbfeda9e27d3866b17aab7d463eb714e513
MD5 2b85d1367a545fbca2c27472ca01b036
BLAKE2b-256 be9d412e70a578b18133e2930c75b8733d5331e6e3a15153fa89ef3458ef8731

See more details on using hashes here.

File details

Details for the file perception-0.8.5-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

  • Download URL: perception-0.8.5-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.13 {"installer":{"name":"uv","version":"0.11.13","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

Hashes for perception-0.8.5-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 114ddb439561604b9ecdc0122b869a1cc9abd9106b688fbc8645690ab1d420cf
MD5 9c36217ee55b27f8913651a24e322e8e
BLAKE2b-256 018927cea2024f70d5e570052bb25a012534942ddaca075e62ecaf0e1463036e

See more details on using hashes here.

File details

Details for the file perception-0.8.5-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: perception-0.8.5-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.13 {"installer":{"name":"uv","version":"0.11.13","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

Hashes for perception-0.8.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c129235f826b46885f7b72809de1793db7dde6cbdcb74ff2a3cc1f4c3e01e1a1
MD5 24655b8a2a423b7c27d07e28f2019e1a
BLAKE2b-256 4b067cba6cc7e4c49aec582824d94617aae6201b9344d0f448e5789f636bdb6b

See more details on using hashes here.

File details

Details for the file perception-0.8.5-cp312-cp312-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: perception-0.8.5-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.13 {"installer":{"name":"uv","version":"0.11.13","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

Hashes for perception-0.8.5-cp312-cp312-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 df3f5c6cb7cc6e3102f6f957444fec5bd6439e3903fe9c781b2acd713494e272
MD5 e3ff6a3b68a73932d86e5c26c0ebdaee
BLAKE2b-256 94782dbe6b975fe6f46c003f6ae49ce9bd502f90e191ae079484c26374f649b3

See more details on using hashes here.

File details

Details for the file perception-0.8.5-cp312-cp312-macosx_10_13_universal2.whl.

File metadata

  • Download URL: perception-0.8.5-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.13 {"installer":{"name":"uv","version":"0.11.13","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

Hashes for perception-0.8.5-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 25d1cae6279c7caeec093e8b35d4cf8008ea6107448a874aa9f667aa429a13fa
MD5 d80ced3dfb8fe0018c553323dc080fe7
BLAKE2b-256 b93dd3570c8fd105df3e116f8f2bf15b3a8f9d64d6e730fce3ad778a951f5e2b

See more details on using hashes here.

File details

Details for the file perception-0.8.5-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: perception-0.8.5-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.13 {"installer":{"name":"uv","version":"0.11.13","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

Hashes for perception-0.8.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a90dddec40d9e88bba429d3e26bfbb0e54c54897ae9100ada05c553fc0401f1a
MD5 4d2ef5e49e7d183550584eb22a1f59fc
BLAKE2b-256 56fb0aa431c909eb6662ebb05acfb4476ae1bb8c34da90576e44a60aab8fa5a0

See more details on using hashes here.

File details

Details for the file perception-0.8.5-cp311-cp311-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: perception-0.8.5-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.13 {"installer":{"name":"uv","version":"0.11.13","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

Hashes for perception-0.8.5-cp311-cp311-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 a6c9742bc13cf5c94afcdc5c22534ecead90d794425a6930f7d12feda56e2a69
MD5 f25d85885b323fbd80c65b50fc50fd93
BLAKE2b-256 9b843527427303a692ba7123a5723595d62e5dfcb9b74a37c5356d45f828e3e3

See more details on using hashes here.

File details

Details for the file perception-0.8.5-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

  • Download URL: perception-0.8.5-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.13 {"installer":{"name":"uv","version":"0.11.13","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

Hashes for perception-0.8.5-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 04fb60b8048a92e1ca718599ef2e6c0c7440a7703fb6434e6121911fb118f255
MD5 a8818a139950bb470f564f866b5f3d24
BLAKE2b-256 ae24629dd813b430c3e963e354d1058275ee2fc0fc2e607541f922904f2b97ac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: perception-0.8.5-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.13 {"installer":{"name":"uv","version":"0.11.13","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

Hashes for perception-0.8.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e485b551cfec9e6db01bf574073ae160b80c74fb4cbb8f5d8195f2d6e0210ebd
MD5 6a8e2a4662a8249573f4029449b96108
BLAKE2b-256 55664919f7526bc97aa456e75a8b1232e8700beefcec7c07a0c22c666a1ce78b

See more details on using hashes here.

File details

Details for the file perception-0.8.5-cp310-cp310-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: perception-0.8.5-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.13 {"installer":{"name":"uv","version":"0.11.13","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

Hashes for perception-0.8.5-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 3e977cafb8e54b3313e24f0193a5dd8aacf017f511e42fad45751f99bf37352b
MD5 04d1debc06e762bd7023fecdf28759fe
BLAKE2b-256 6e1bbf43b49e888d6b5c2af91b84d37f3a0923dcc4729e898ff60b5e704279a6

See more details on using hashes here.

File details

Details for the file perception-0.8.5-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

  • Download URL: perception-0.8.5-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.13 {"installer":{"name":"uv","version":"0.11.13","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

Hashes for perception-0.8.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 11e2891a0797c08a82bb5e7586b538d0f9b0f71b349d3c2bde6e60cb1feb7287
MD5 a5becc0be4b7b5578f3d15fe5aaebe14
BLAKE2b-256 5ac9a6c274e9dc01af1bf8382879e71a093599f08b1712142538362ec69e889f

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