Perception 0.8.1__tar.gz → 0.8.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. {perception-0.8.1 → perception-0.8.2}/PKG-INFO +4 -2
  2. {perception-0.8.1 → perception-0.8.2}/perception/hashers/tools.py +28 -0
  3. {perception-0.8.1 → perception-0.8.2}/pyproject.toml +1 -1
  4. {perception-0.8.1 → perception-0.8.2}/setup.py +1 -1
  5. {perception-0.8.1 → perception-0.8.2}/LICENSE +0 -0
  6. {perception-0.8.1 → perception-0.8.2}/README.md +0 -0
  7. {perception-0.8.1 → perception-0.8.2}/build.py +0 -0
  8. {perception-0.8.1 → perception-0.8.2}/perception/__init__.py +0 -0
  9. {perception-0.8.1 → perception-0.8.2}/perception/approximate_deduplication/__init__.py +0 -0
  10. {perception-0.8.1 → perception-0.8.2}/perception/approximate_deduplication/debug.py +0 -0
  11. {perception-0.8.1 → perception-0.8.2}/perception/approximate_deduplication/index.py +0 -0
  12. {perception-0.8.1 → perception-0.8.2}/perception/approximate_deduplication/serve.py +0 -0
  13. {perception-0.8.1 → perception-0.8.2}/perception/benchmarking/__init__.py +0 -0
  14. {perception-0.8.1 → perception-0.8.2}/perception/benchmarking/common.py +0 -0
  15. {perception-0.8.1 → perception-0.8.2}/perception/benchmarking/extensions.pyx +0 -0
  16. {perception-0.8.1 → perception-0.8.2}/perception/benchmarking/image.py +0 -0
  17. {perception-0.8.1 → perception-0.8.2}/perception/benchmarking/image_transforms.py +0 -0
  18. {perception-0.8.1 → perception-0.8.2}/perception/benchmarking/video.py +0 -0
  19. {perception-0.8.1 → perception-0.8.2}/perception/benchmarking/video_transforms.py +0 -0
  20. {perception-0.8.1 → perception-0.8.2}/perception/extensions.pyx +0 -0
  21. {perception-0.8.1 → perception-0.8.2}/perception/hashers/__init__.py +0 -0
  22. {perception-0.8.1 → perception-0.8.2}/perception/hashers/hasher.py +0 -0
  23. {perception-0.8.1 → perception-0.8.2}/perception/hashers/image/__init__.py +0 -0
  24. {perception-0.8.1 → perception-0.8.2}/perception/hashers/image/average.py +0 -0
  25. {perception-0.8.1 → perception-0.8.2}/perception/hashers/image/dhash.py +0 -0
  26. {perception-0.8.1 → perception-0.8.2}/perception/hashers/image/opencv.py +0 -0
  27. {perception-0.8.1 → perception-0.8.2}/perception/hashers/image/pdq.py +0 -0
  28. {perception-0.8.1 → perception-0.8.2}/perception/hashers/image/phash.py +0 -0
  29. {perception-0.8.1 → perception-0.8.2}/perception/hashers/image/wavelet.py +0 -0
  30. {perception-0.8.1 → perception-0.8.2}/perception/hashers/video/__init__.py +0 -0
  31. {perception-0.8.1 → perception-0.8.2}/perception/hashers/video/framewise.py +0 -0
  32. {perception-0.8.1 → perception-0.8.2}/perception/hashers/video/tmk.py +0 -0
  33. {perception-0.8.1 → perception-0.8.2}/perception/local_descriptor_deduplication.py +0 -0
  34. {perception-0.8.1 → perception-0.8.2}/perception/py.typed +0 -0
  35. {perception-0.8.1 → perception-0.8.2}/perception/testing/__init__.py +0 -0
  36. {perception-0.8.1 → perception-0.8.2}/perception/testing/images/README.md +0 -0
  37. {perception-0.8.1 → perception-0.8.2}/perception/testing/images/image1.jpg +0 -0
  38. {perception-0.8.1 → perception-0.8.2}/perception/testing/images/image10.jpg +0 -0
  39. {perception-0.8.1 → perception-0.8.2}/perception/testing/images/image2.jpg +0 -0
  40. {perception-0.8.1 → perception-0.8.2}/perception/testing/images/image3.jpg +0 -0
  41. {perception-0.8.1 → perception-0.8.2}/perception/testing/images/image4.jpg +0 -0
  42. {perception-0.8.1 → perception-0.8.2}/perception/testing/images/image5.jpg +0 -0
  43. {perception-0.8.1 → perception-0.8.2}/perception/testing/images/image6.jpg +0 -0
  44. {perception-0.8.1 → perception-0.8.2}/perception/testing/images/image7.jpg +0 -0
  45. {perception-0.8.1 → perception-0.8.2}/perception/testing/images/image8.jpg +0 -0
  46. {perception-0.8.1 → perception-0.8.2}/perception/testing/images/image9.jpg +0 -0
  47. {perception-0.8.1 → perception-0.8.2}/perception/testing/logos/README.md +0 -0
  48. {perception-0.8.1 → perception-0.8.2}/perception/testing/logos/logoipsum.png +0 -0
  49. {perception-0.8.1 → perception-0.8.2}/perception/testing/videos/README.md +0 -0
  50. {perception-0.8.1 → perception-0.8.2}/perception/testing/videos/expected_tmk.json.gz +0 -0
  51. {perception-0.8.1 → perception-0.8.2}/perception/testing/videos/rgb.m4v +0 -0
  52. {perception-0.8.1 → perception-0.8.2}/perception/testing/videos/v1.m4v +0 -0
  53. {perception-0.8.1 → perception-0.8.2}/perception/testing/videos/v2.m4v +0 -0
  54. {perception-0.8.1 → perception-0.8.2}/perception/testing/videos/v2s.mov +0 -0
  55. {perception-0.8.1 → perception-0.8.2}/perception/tools.py +0 -0
  56. {perception-0.8.1 → perception-0.8.2}/perception/utils.py +0 -0
@@ -1,8 +1,9 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: Perception
3
- Version: 0.8.1
3
+ Version: 0.8.2
4
4
  Summary: Perception provides flexible, well-documented, and comprehensively tested tooling for perceptual hashing research, development, and production use.
5
5
  License: Apache-2.0
6
+ License-File: LICENSE
6
7
  Author: Thorn
7
8
  Author-email: info@wearethorn.org
8
9
  Requires-Python: >=3.10,<4.0
@@ -12,6 +13,7 @@ Classifier: Programming Language :: Python :: 3.10
12
13
  Classifier: Programming Language :: Python :: 3.11
13
14
  Classifier: Programming Language :: Python :: 3.12
14
15
  Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
15
17
  Provides-Extra: benchmarking
16
18
  Provides-Extra: experimental
17
19
  Provides-Extra: matching
@@ -1070,3 +1070,31 @@ def unletterbox(
1070
1070
  bounds = (x1, x2 + 1), (y1, y2 + 1)
1071
1071
 
1072
1072
  return bounds
1073
+
1074
+
1075
+ def unletterbox_crop(
1076
+ image: np.ndarray, min_fraction_meaningful_pixels: float = 0.1
1077
+ ) -> np.ndarray | None:
1078
+ """Detect and crop the letterboxed regions from an image.
1079
+
1080
+ Args:
1081
+ image: The image from which to remove letterboxing.
1082
+ min_fraction_meaningful_pixels: 0 to 1: if cropped version is
1083
+ smaller than this fraction of the image do not unletterbox.
1084
+ 0.1 == 10% of the image.
1085
+ Returns:
1086
+ The cropped image or None if the image is mostly blank space.
1087
+ """
1088
+ assert isinstance(
1089
+ image, np.ndarray
1090
+ ), "Please send np.ndarray to unletterbox_image()."
1091
+
1092
+ bounds = unletterbox(
1093
+ image, min_fraction_meaningful_pixels=min_fraction_meaningful_pixels
1094
+ )
1095
+ if bounds is None:
1096
+ return None
1097
+ (x1, x2), (y1, y2) = bounds
1098
+ cropped = np.ascontiguousarray(image[y1:y2, x1:x2])
1099
+ assert cropped.data.contiguous
1100
+ return cropped
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "Perception"
3
- version = "0.8.1"
3
+ version = "0.8.2"
4
4
  description = "Perception provides flexible, well-documented, and comprehensively tested tooling for perceptual hashing research, development, and production use."
5
5
  authors = ["Thorn <info@wearethorn.org>"]
6
6
  license = "Apache License 2.0"
@@ -37,7 +37,7 @@ extras_require = \
37
37
 
38
38
  setup_kwargs = {
39
39
  'name': 'Perception',
40
- 'version': '0.8.1',
40
+ 'version': '0.8.2',
41
41
  'description': 'Perception provides flexible, well-documented, and comprehensively tested tooling for perceptual hashing research, development, and production use.',
42
42
  'long_description': "# perception ![ci](https://github.com/thorn-oss/perception/workflows/ci/badge.svg)\n\n`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.\n\n## Background\n\n`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/).\n\n## Getting Started\n\n### Installation\n\n`pip install perception`\n\n### Hashing\n\nHashing with different functions is simple with `perception`.\n\n```python\nfrom perception import hashers\n\nfile1, file2 = 'test1.jpg', 'test2.jpg'\nhasher = hashers.PHash()\nhash1, hash2 = hasher.compute(file1), hasher.compute(file2)\ndistance = hasher.compute_distance(hash1, hash2)\n```\n\n### Examples\n\nSee below for end-to-end examples for common use cases for perceptual hashes.\n\n- [Detecting child sexual abuse material](https://perception.thorn.engineering/en/latest/examples/detecting_csam.html)\n- [Deduplicating media](https://perception.thorn.engineering/en/latest/examples/deduplication.html)\n- [Benchmarking perceptual hashes](https://perception.thorn.engineering/en/latest/examples/benchmarking.html)\n\n## Supported Hashing Algorithms\n\n`perception` currently ships with:\n\n- pHash (DCT hash) (`perception.hashers.PHash`)\n- Facebook's PDQ Hash (`perception.hashers.PDQ`)\n- dHash (difference hash) (`perception.hashers.DHash`)\n- aHash (average hash) (`perception.hashers.AverageHash`)\n- Marr-Hildreth (`perception.hashers.MarrHildreth`)\n- Color Moment (`perception.hashers.ColorMoment`)\n- Block Mean (`perception.hashers.BlockMean`)\n- wHash (wavelet hash) (`perception.hashers.WaveletHash`)\n\n## Contributing\n\nTo work on the project, start by doing the following.\n\n```bash\n# Install local dependencies for\n# code completion, etc.\nmake init\n\n- To do a (close to) comprehensive check before committing code, you can use `make precommit`.\n\nTo implement new features, please first file an issue proposing your change for discussion.\n\nTo report problems, please file an issue with sample code, expected results, actual results, and a complete traceback.\n\n## Alternatives\n\nThere are other packages worth checking out to see if they meet your needs for perceptual hashing. Here are some\nexamples.\n\n- [dedupe](https://github.com/dedupeio/dedupe)\n- [imagededup](https://idealo.github.io/imagededup/)\n- [ImageHash](https://github.com/JohannesBuchner/imagehash)\n- [PhotoHash](https://github.com/bunchesofdonald/photohash)\n```\n",
43
43
  'author': 'Thorn',
File without changes
File without changes
File without changes