A package for image hashing
Project description
perception ![ci](https://pypi-camo.freetls.fastly.net/db79ce90e5e45af3f92b944f7a0feba174c21bec/68747470733a2f2f6769746875622e636f6d2f74686f726e2d6f73732f70657263657074696f6e2f776f726b666c6f77732f63692f62616467652e737667)
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
- 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
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
Hashes for perception-0.5.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06a17e3ab4b93cb96f731534bf426706133142f3bf4343004cdba396b25b37ad |
|
MD5 | 7825a1ee3d435e6ea9030fc8c91335d8 |
|
BLAKE2b-256 | 05dbd1087711d01d90b65c466d03a7f8565dbb89021c440730a750458deee606 |
Hashes for perception-0.5.0-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c010990fa20009d1677e7858bbf6ed438eb88be1c8dc4874bed32c98a1a8aafe |
|
MD5 | ff0359f58a45430bb105907bfbca9096 |
|
BLAKE2b-256 | e706f7f36442adcfcd48cc325e3f6bef4f1a37f9b7c9b1d43ac039e668b70176 |
Hashes for perception-0.5.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0247091e03a68284a9535557f72dfea292be3784f60b7614e7e05dced3d987d5 |
|
MD5 | 00e347ee3036cd611b1ec24fab9aac40 |
|
BLAKE2b-256 | bd3d8c4c29332949deaba7afae93de1d24c858a3525c7ca42c8fcbcfa35d21a7 |
Hashes for perception-0.5.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 178cf28f0b5c623b3b164dffa83c73e4502bbe3eeb24b84eb60461fdd5fb740b |
|
MD5 | 290fe5c57ebcc88b820b78daf8c1c548 |
|
BLAKE2b-256 | ec903eb36cec708cb020132f98aa8e76c69de1124f804b641a40fb12e8d0eaf3 |
Hashes for perception-0.5.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dcc60a3421c1e202d8c8555eddd624630bff30fc41792a4a5bac5dd510c165ae |
|
MD5 | 0e7a6c1055e94b0725e12d3d127f411d |
|
BLAKE2b-256 | 776ccc488ddf1c9d195da806d6b42808fc2ec35ee8fd4c74eb90b99402ba987c |
Hashes for perception-0.5.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 944e83f2f8cec8f6fbb27dd0e44a47a3049de110ed221802c0ac300892db1396 |
|
MD5 | c909aec8e154f99391d9dfec4c4959dc |
|
BLAKE2b-256 | bfe95326ff420b2de42390e20fb9edb1cbd6120f94920012e6543b666bb7d52d |
Hashes for perception-0.5.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 482c7c41859a46087f5bf56d19ae1a92c6558f14a355182dd24676292c9acb49 |
|
MD5 | 8e0a6863ccdfb841f3e3a71c397f0f1f |
|
BLAKE2b-256 | 96892d65d82a841eb649446419402dbb10344f322392c495797ef131c6018dd4 |
Hashes for perception-0.5.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed9fe6d7fd71d36097210cdc4b3fc41537f2277cb5640507434eb0407c1f97ca |
|
MD5 | 70d1567f3fc98c6d735edff8eea6781b |
|
BLAKE2b-256 | ae6f6841819b91682257e745db9399171244e995c897fea8440434a2543500e4 |
Hashes for perception-0.5.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f71c767c4d4bc48b42d0399c86a499bf59667bbf6f3beea59c4ec2372380e42a |
|
MD5 | 4008819d891392a521ad306e5c20188d |
|
BLAKE2b-256 | 4384ff912803b70e4be8be9ef938410e453dccebbd4ed7ef51f22149e72e5714 |