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

Uploaded Source

Built Distributions

perception-0.5.3-py3-none-any.whl (1.3 MB view details)

Uploaded Python 3

perception-0.5.3-cp38-cp38-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.7m Windows x86-64

File details

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

File metadata

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

File hashes

Hashes for perception-0.5.3.tar.gz
Algorithm Hash digest
SHA256 ea8da779220ff8159d7835ddeeb3650ccb677b8d40bae93e4d72d1b7cd6728c5
MD5 d8b9ed24a3c04eeb4e72e6406291f417
BLAKE2b-256 8d557d3e9c82e191f90d3946c5c1dfe8272c0af9ae82b26c9748e581239f8cb2

See more details on using hashes here.

File details

Details for the file perception-0.5.3-py3-none-any.whl.

File metadata

  • Download URL: perception-0.5.3-py3-none-any.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.12

File hashes

Hashes for perception-0.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 400ba45aaca956e7c57a5b4c413ff3fce5720dd984236ddb86a144be207d5322
MD5 c436028d10bfb4f72bd68f934f741a32
BLAKE2b-256 9c7dd87b7892c64d68b2884072abe0d00e39f687343cdfec6dc56963bbd9e77b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for perception-0.5.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 5e9a148682898b22264ff2666e92cfe8d5a300a47bc73f25ee68f5599e90b365
MD5 01199fc5347fcbd7ad0d0f927729ec03
BLAKE2b-256 17bb62a33e907fea8e4303a0a7b8f7e50c6920d9d33acff87b1c43cb916ea8f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for perception-0.5.3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 8527fdd5e813485b0cf0d7abfafbc29110ea905ab1df31c5e2c4ccf1cc4b256c
MD5 7be5426ed3f169f1b1c2729917b438e8
BLAKE2b-256 4b493127a575767a203b6c6642446397023f6d256ceac4f3174f064273e45128

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