Metadata-Version: 2.1
Name: Perception
Version: 0.7.7
Summary: Perception provides flexible, well-documented, and comprehensively tested tooling for perceptual hashing research, development, and production use.
License: Apache-2.0
Author: Thorn
Author-email: info@wearethorn.org
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Provides-Extra: benchmarking
Provides-Extra: experimental
Provides-Extra: matching
Requires-Dist: Cython (>=3,<4)
Requires-Dist: Pillow
Requires-Dist: aiohttp ; extra == "matching"
Requires-Dist: faiss-cpu (>=1.8.0.post1,<2.0.0) ; extra == "experimental"
Requires-Dist: ffmpeg-python ; extra == "benchmarking"
Requires-Dist: imgaug ; extra == "benchmarking"
Requires-Dist: matplotlib ; extra == "benchmarking"
Requires-Dist: networkit (>=11,<12) ; extra == "experimental"
Requires-Dist: numpy (>=1.26,<2.0)
Requires-Dist: opencv-contrib-python-headless (>=4.10,<5.0)
Requires-Dist: pandas
Requires-Dist: pdqhash
Requires-Dist: python-json-logger ; extra == "matching"
Requires-Dist: pywavelets (>=1.5.0,<2.0.0)
Requires-Dist: rich (>=13.7.0,<14.0.0)
Requires-Dist: scikit-learn ; extra == "benchmarking"
Requires-Dist: scipy ; extra == "benchmarking"
Requires-Dist: tabulate ; extra == "benchmarking"
Requires-Dist: tqdm
Requires-Dist: validators (>=0.22,<1.0)
Description-Content-Type: text/markdown

# perception ![ci](https://github.com/thorn-oss/perception/workflows/ci/badge.svg)

`perception` provides flexible, well-documented, and comprehensively tested tooling for perceptual hashing research, development, and production use. See [the documentation](https://perception.thorn.engineering/en/latest/) for details.

## Background

`perception` was initially developed at [Thorn](https://www.thorn.org) 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](https://www.thorn.org/blog/time-is-now-eliminate-csam/).

## Getting Started

### Installation

`pip install perception`

### Hashing

Hashing with different functions is simple with `perception`.

```python
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.

- [Detecting child sexual abuse material](https://perception.thorn.engineering/en/latest/examples/detecting_csam.html)
- [Deduplicating media](https://perception.thorn.engineering/en/latest/examples/deduplication.html)
- [Benchmarking perceptual hashes](https://perception.thorn.engineering/en/latest/examples/benchmarking.html)

## 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.

```bash
# Install local dependencies for
# code completion, etc.
make init

- To do a (close to) comprehensive check before committing code, you can 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.

- [dedupe](https://github.com/dedupeio/dedupe)
- [imagededup](https://idealo.github.io/imagededup/)
- [ImageHash](https://github.com/JohannesBuchner/imagehash)
- [PhotoHash](https://github.com/bunchesofdonald/photohash)
```

