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 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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

perception-0.7.2-cp310-cp310-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.10 Windows x86-64

perception-0.7.2-cp310-cp310-manylinux_2_28_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.28+ x86-64

perception-0.7.2-cp310-cp310-macosx_12_0_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.10 macOS 12.0+ x86-64

perception-0.7.2-cp39-cp39-manylinux_2_28_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.28+ x86-64

perception-0.7.2-cp39-cp39-macosx_12_0_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.9 macOS 12.0+ x86-64

File details

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

File metadata

File hashes

Hashes for perception-0.7.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 75c2840d1ee8fa4f69f4f138b04ded172801279174d1ee309b14e2d61e862a98
MD5 b88aa7c8b7a7694d07ffa91d9f49d213
BLAKE2b-256 c17416f9dfb133b400914ae259a307c253f3b8edd2345f1fe426c859f615eb1b

See more details on using hashes here.

Provenance

File details

Details for the file perception-0.7.2-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for perception-0.7.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ff5416904c73e10bdb6db0559740b24a9fbdc4e9a7e38b94652bde3a73eea7c0
MD5 388139be87eb6b9d69bdf50bab2f89de
BLAKE2b-256 de9b5c40a138b729232bea5a4fa213981543db74700eef41ec6d5e9731b11e54

See more details on using hashes here.

Provenance

File details

Details for the file perception-0.7.2-cp310-cp310-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for perception-0.7.2-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 e5c9c78ee00a63ddda7cef9267b6b651ecfa62dd01396c02a5a911c1b8983309
MD5 4c2c2218f81677387725ab9ed260a125
BLAKE2b-256 e302c7af37e1828d24216d7130516eba292d103cf1da11bf7016c52eca163946

See more details on using hashes here.

Provenance

File details

Details for the file perception-0.7.2-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for perception-0.7.2-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e52ca07d63fa416e8da4a5fc8c9ddf9ef6eb8c4cb24580c99cb6b36a7734466e
MD5 0d6d1d4b76581b71b71aac0afebd94a8
BLAKE2b-256 ca2e688957da365e3eb6292b96275b911eaa12fe23fc1946d50c93fdf0adb4c1

See more details on using hashes here.

Provenance

File details

Details for the file perception-0.7.2-cp39-cp39-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for perception-0.7.2-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 f4fdac274c6a2d3ba2370b725e6778456d4cbd811ffb0d665bcda1a52dc05373
MD5 731f2ffa3265bc3ed1b006ae87687a1d
BLAKE2b-256 b5f5c875f6995609b2e4f68d41f23fd2d01bc39476077cbad11b719f32803d4d

See more details on using hashes here.

Provenance

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