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.2a6-cp310-cp310-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.10 Windows x86-64

perception-0.7.2a6-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.2a6-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.2a6-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.2a6-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.2a6-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for perception-0.7.2a6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e44966533ddf71c11bb91d9a07a8c29001db55aafff4e26709e054b8aa415202
MD5 7a8d4458744281c22362b3116785fd93
BLAKE2b-256 5b580cb763ee9435f141e3f9224b46677849b590c951191454f11dbaf95af16d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for perception-0.7.2a6-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ea8ac1a3b6c5ae2a646fb9acf3f02dee1366543ae939ec9500a2d5d08a8c5d7f
MD5 66b14180a66c7843a4742a212c1e362b
BLAKE2b-256 4e8d165dc4135027410addc5752aa06559d0ef0d864f6946645527db4c0dec47

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for perception-0.7.2a6-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 2b7a1a807b752a55930f7c4034547aaee05d4918085a79b740a3fb18ade358db
MD5 37b6d8735c926002523ebc508a782e2b
BLAKE2b-256 9ef3e213dc03562fd93e5e346c0d22e08a5ca437f3fb5cf0d2a9537b563248ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for perception-0.7.2a6-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 26902d1a2d9e880107798b3198f5cdb89b061bcdab7f6fd79c56e5d967970411
MD5 09710a9fa09177e4274227dd94b1ab61
BLAKE2b-256 e2ff216ea1a587937ed9069814b266b4245cc82d9302edeaaded077481fd9ca6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for perception-0.7.2a6-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 0ca19ef141e7e699a0e2666f1b499299653873d61c8b9ee9654bb8fd67c00842
MD5 e708639d9d0f746313d416889846d225
BLAKE2b-256 a74be37126909767322141bed7b8d29264f16ee1476efdd5d59fe17a9de0dc71

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