Perception 0.8.4__tar.gz → 0.9.0__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 (100) hide show
  1. perception-0.9.0/.dockerignore +2 -0
  2. perception-0.9.0/.git-blame-ignore-revs +2 -0
  3. perception-0.9.0/.gitattributes +1 -0
  4. perception-0.9.0/.github/dependabot.yaml +7 -0
  5. perception-0.9.0/.github/workflows/ci.yaml +56 -0
  6. perception-0.9.0/.github/workflows/gh-pages.yaml +31 -0
  7. perception-0.9.0/.github/workflows/release.yaml +123 -0
  8. perception-0.9.0/.gitignore +41 -0
  9. perception-0.9.0/.pre-commit-config.yaml +40 -0
  10. perception-0.9.0/.readthedocs.yaml +16 -0
  11. perception-0.9.0/CHANGELOG.md +47 -0
  12. perception-0.9.0/CODE_OF_CONDUCT.md +76 -0
  13. perception-0.9.0/MANIFEST.in +7 -0
  14. perception-0.9.0/Makefile +58 -0
  15. {perception-0.8.4 → perception-0.9.0}/PKG-INFO +65 -37
  16. perception-0.9.0/Perception.egg-info/PKG-INFO +143 -0
  17. perception-0.9.0/Perception.egg-info/SOURCES.txt +95 -0
  18. perception-0.9.0/Perception.egg-info/dependency_links.txt +1 -0
  19. perception-0.9.0/Perception.egg-info/requires.txt +34 -0
  20. perception-0.9.0/Perception.egg-info/top_level.txt +1 -0
  21. {perception-0.8.4 → perception-0.9.0}/README.md +37 -4
  22. perception-0.9.0/docs/api/benchmarking.rst +31 -0
  23. perception-0.9.0/docs/api/hashers.rst +45 -0
  24. perception-0.9.0/docs/api/index.rst +10 -0
  25. perception-0.9.0/docs/api/tools.rst +7 -0
  26. perception-0.9.0/docs/conf.py +65 -0
  27. perception-0.9.0/docs/examples/benchmarking.rst +648 -0
  28. perception-0.9.0/docs/examples/deduplication.rst +197 -0
  29. perception-0.9.0/docs/examples/detecting_csam.rst +23 -0
  30. perception-0.9.0/docs/examples/index.rst +10 -0
  31. perception-0.9.0/docs/index.rst +48 -0
  32. perception-0.9.0/docs/requirements.txt +14 -0
  33. perception-0.9.0/perception/_optional.py +42 -0
  34. {perception-0.8.4 → perception-0.9.0}/perception/approximate_deduplication/__init__.py +5 -2
  35. {perception-0.8.4 → perception-0.9.0}/perception/approximate_deduplication/_graph_backend.py +4 -6
  36. {perception-0.8.4 → perception-0.9.0}/perception/approximate_deduplication/index.py +9 -2
  37. {perception-0.8.4 → perception-0.9.0}/perception/approximate_deduplication/serve.py +10 -8
  38. {perception-0.8.4 → perception-0.9.0}/perception/benchmarking/common.py +9 -2
  39. perception-0.9.0/perception/benchmarking/extensions.c +31202 -0
  40. {perception-0.8.4 → perception-0.9.0}/perception/benchmarking/image.py +9 -2
  41. {perception-0.8.4 → perception-0.9.0}/perception/benchmarking/video.py +3 -1
  42. {perception-0.8.4 → perception-0.9.0}/perception/benchmarking/video_transforms.py +3 -1
  43. perception-0.9.0/perception/extensions.cpp +33687 -0
  44. {perception-0.8.4 → perception-0.9.0}/perception/hashers/hasher.py +0 -1
  45. {perception-0.8.4 → perception-0.9.0}/perception/hashers/image/pdq.py +3 -2
  46. {perception-0.8.4 → perception-0.9.0}/perception/local_descriptor_deduplication.py +8 -2
  47. {perception-0.8.4 → perception-0.9.0}/perception/testing/__init__.py +3 -1
  48. {perception-0.8.4 → perception-0.9.0}/perception/tools.py +3 -3
  49. perception-0.9.0/pyproject.toml +104 -0
  50. perception-0.9.0/setup.cfg +4 -0
  51. perception-0.9.0/setup.py +19 -0
  52. perception-0.9.0/tests/images/chair-square.png +0 -0
  53. perception-0.9.0/tests/images/chair-tall.png +0 -0
  54. perception-0.9.0/tests/images/chair.png +0 -0
  55. perception-0.9.0/tests/images/chair3.png +0 -0
  56. perception-0.9.0/uv.lock +4149 -0
  57. perception-0.8.4/build.py +0 -15
  58. perception-0.8.4/pyproject.toml +0 -80
  59. perception-0.8.4/setup.py +0 -59
  60. {perception-0.8.4 → perception-0.9.0}/LICENSE +0 -0
  61. {perception-0.8.4 → perception-0.9.0}/perception/__init__.py +0 -0
  62. {perception-0.8.4 → perception-0.9.0}/perception/approximate_deduplication/debug.py +0 -0
  63. {perception-0.8.4 → perception-0.9.0}/perception/benchmarking/__init__.py +0 -0
  64. {perception-0.8.4 → perception-0.9.0}/perception/benchmarking/extensions.pyx +0 -0
  65. {perception-0.8.4 → perception-0.9.0}/perception/benchmarking/image_transforms.py +0 -0
  66. {perception-0.8.4 → perception-0.9.0}/perception/extensions.pyx +0 -0
  67. {perception-0.8.4 → perception-0.9.0}/perception/hashers/__init__.py +0 -0
  68. {perception-0.8.4 → perception-0.9.0}/perception/hashers/image/__init__.py +0 -0
  69. {perception-0.8.4 → perception-0.9.0}/perception/hashers/image/average.py +0 -0
  70. {perception-0.8.4 → perception-0.9.0}/perception/hashers/image/dhash.py +0 -0
  71. {perception-0.8.4 → perception-0.9.0}/perception/hashers/image/opencv.py +0 -0
  72. {perception-0.8.4 → perception-0.9.0}/perception/hashers/image/phash.py +0 -0
  73. {perception-0.8.4 → perception-0.9.0}/perception/hashers/image/wavelet.py +0 -0
  74. {perception-0.8.4 → perception-0.9.0}/perception/hashers/tools.py +0 -0
  75. {perception-0.8.4 → perception-0.9.0}/perception/hashers/video/__init__.py +0 -0
  76. {perception-0.8.4 → perception-0.9.0}/perception/hashers/video/framewise.py +0 -0
  77. {perception-0.8.4 → perception-0.9.0}/perception/hashers/video/tmk.py +0 -0
  78. {perception-0.8.4 → perception-0.9.0}/perception/py.typed +0 -0
  79. {perception-0.8.4 → perception-0.9.0}/perception/testing/images/README.md +0 -0
  80. {perception-0.8.4 → perception-0.9.0}/perception/testing/images/image1.jpg +0 -0
  81. {perception-0.8.4 → perception-0.9.0}/perception/testing/images/image10.jpg +0 -0
  82. {perception-0.8.4 → perception-0.9.0}/perception/testing/images/image2.jpg +0 -0
  83. {perception-0.8.4 → perception-0.9.0}/perception/testing/images/image3.jpg +0 -0
  84. {perception-0.8.4 → perception-0.9.0}/perception/testing/images/image4.jpg +0 -0
  85. {perception-0.8.4 → perception-0.9.0}/perception/testing/images/image5.jpg +0 -0
  86. {perception-0.8.4 → perception-0.9.0}/perception/testing/images/image6.jpg +0 -0
  87. {perception-0.8.4 → perception-0.9.0}/perception/testing/images/image7.jpg +0 -0
  88. {perception-0.8.4 → perception-0.9.0}/perception/testing/images/image8.jpg +0 -0
  89. {perception-0.8.4 → perception-0.9.0}/perception/testing/images/image9.jpg +0 -0
  90. {perception-0.8.4 → perception-0.9.0}/perception/testing/logos/README.md +0 -0
  91. {perception-0.8.4 → perception-0.9.0}/perception/testing/logos/logoipsum.png +0 -0
  92. {perception-0.8.4 → perception-0.9.0}/perception/testing/videos/README.md +0 -0
  93. {perception-0.8.4 → perception-0.9.0}/perception/testing/videos/expected_tmk.json.gz +0 -0
  94. {perception-0.8.4 → perception-0.9.0}/perception/testing/videos/extra_channel_attached_pic.mp4 +0 -0
  95. {perception-0.8.4 → perception-0.9.0}/perception/testing/videos/extra_channel_attached_pic_audio.mp4 +0 -0
  96. {perception-0.8.4 → perception-0.9.0}/perception/testing/videos/rgb.m4v +0 -0
  97. {perception-0.8.4 → perception-0.9.0}/perception/testing/videos/v1.m4v +0 -0
  98. {perception-0.8.4 → perception-0.9.0}/perception/testing/videos/v2.m4v +0 -0
  99. {perception-0.8.4 → perception-0.9.0}/perception/testing/videos/v2s.mov +0 -0
  100. {perception-0.8.4 → perception-0.9.0}/perception/utils.py +0 -0
@@ -0,0 +1,2 @@
1
+ notebooks
2
+ .venv/
@@ -0,0 +1,2 @@
1
+ # Format with black
2
+ 6c03f96a9335e548685ece233474125fe453c262
@@ -0,0 +1 @@
1
+ perception/_version.py export-subst
@@ -0,0 +1,7 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ # Check for updates to GitHub Actions every week.
7
+ interval: "weekly"
@@ -0,0 +1,56 @@
1
+ name: ci
2
+ on:
3
+ push:
4
+ branches:
5
+ - "**"
6
+ tags-ignore:
7
+ - v*
8
+ permissions:
9
+ contents: read
10
+ jobs:
11
+ test:
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
15
+ os: ["ubuntu-latest", "windows-latest", "macos-latest"]
16
+ runs-on: ${{ matrix.os }}
17
+ steps:
18
+ - name: checkout
19
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
20
+ - name: Set up uv
21
+ uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+ enable-cache: true
25
+ cache-python: true
26
+ cache-dependency-glob: |
27
+ pyproject.toml
28
+ uv.lock
29
+ cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
30
+ - name: Setup FFMPEG on Ubuntu
31
+ if: startsWith(matrix.os, 'ubuntu')
32
+ run: |
33
+ sudo apt-get update
34
+ sudo apt-get install -y ffmpeg
35
+ - name: Setup FFMPEG on Windows
36
+ if: startsWith(matrix.os, 'windows')
37
+ run: choco install ffmpeg --yes --no-progress
38
+ - name: Setup Dependencies with Homebrew
39
+ if: startsWith(matrix.os, 'macos')
40
+ run: |
41
+ brew install llvm ffmpeg
42
+ echo "CC=$(brew --prefix)/opt/llvm/bin/clang" >> $GITHUB_ENV
43
+ echo "CXX=$(brew --prefix)/opt/llvm/bin/clang++" >> $GITHUB_ENV
44
+ - name: Verify FFMPEG
45
+ run: |
46
+ ffmpeg -version
47
+ ffprobe -version
48
+ - name: Setup Project
49
+ run: uv sync --all-extras --frozen
50
+ - name: Run checks
51
+ run: |
52
+ uv lock --check
53
+ uv run ruff check perception tests
54
+ uv run mypy perception
55
+ uv run black --check .
56
+ uv run pytest tests/
@@ -0,0 +1,31 @@
1
+ name: Deploy Sphinx documentation to Pages
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - dunnack/sphinx-to-github-pages
7
+ - main
8
+ paths:
9
+ - .github/workflows/gh-pages.yaml
10
+ - docs/**
11
+
12
+ jobs:
13
+ pages:
14
+ runs-on: ubuntu-latest
15
+ environment:
16
+ name: github-pages
17
+ url: ${{ steps.deployment.outputs.page_url }}
18
+ permissions:
19
+ contents: read
20
+ pages: write
21
+ id-token: write
22
+ steps:
23
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
24
+ with:
25
+ fetch-depth: 0
26
+ - id: deployment
27
+ uses: sphinx-notes/pages@e9c8f79f285fb41a150ba6e08a3c2a29635e7ee1 # 3.5
28
+ with:
29
+ checkout: false
30
+ documentation_path: docs
31
+ requirements_path: docs/requirements.txt
@@ -0,0 +1,123 @@
1
+ name: release
2
+ on:
3
+ release:
4
+ types: [published]
5
+ workflow_dispatch:
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ jobs:
11
+ build-wheels:
12
+ runs-on: ${{ matrix.os }}
13
+ strategy:
14
+ matrix:
15
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
16
+ os: ["ubuntu-latest", "windows-latest", "macos-latest"]
17
+ name: Build for ${{ matrix.os }} on Python ${{ matrix.python-version }}
18
+ steps:
19
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
20
+ with:
21
+ # Full clone for version calculation
22
+ fetch-depth: 0
23
+ fetch-tags: true
24
+ ref: ${{ github.event_name == 'release' && format('refs/tags/{0}', github.event.release.tag_name) || github.ref }}
25
+ - name: Set up uv
26
+ uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
27
+ with:
28
+ python-version: ${{ matrix.python-version }}
29
+ enable-cache: false
30
+ - name: Setup Build Dependencies with Homebrew
31
+ if: startsWith(matrix.os, 'macos')
32
+ run: |
33
+ brew install llvm
34
+ echo "CC=$(brew --prefix)/opt/llvm/bin/clang" >> $GITHUB_ENV
35
+ echo "CXX=$(brew --prefix)/opt/llvm/bin/clang++" >> $GITHUB_ENV
36
+ - name: Build Project
37
+ shell: bash
38
+ run: |
39
+ rm -rf build Perception.egg-info
40
+ echo "uv: $(uv --version)"
41
+ echo "Python: $(uv run python --version)"
42
+ echo "Git describe: $(git describe --tags --always)"
43
+ uv build --wheel --out-dir="dist-tmp" --clear
44
+ uv tool run --from repairwheel repairwheel -o dist dist-tmp/*.whl
45
+ find dist -name "*.whl" -type f | sed -n "s/\(.*\)\.linux.*\.whl$/& \1.whl/p" | xargs -r -n 2 mv
46
+ rm -rf dist-tmp
47
+ - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
48
+ with:
49
+ name: package-wheels-${{ matrix.os }}-${{ matrix.python-version }}
50
+ path: dist/*
51
+
52
+ build-sdist:
53
+ runs-on: ubuntu-latest
54
+ name: Build sdist
55
+ steps:
56
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
57
+ with:
58
+ # Full clone for version calculation
59
+ fetch-depth: 0
60
+ fetch-tags: true
61
+ ref: ${{ github.event_name == 'release' && format('refs/tags/{0}', github.event.release.tag_name) || github.ref }}
62
+ - name: Set up uv
63
+ uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
64
+ with:
65
+ python-version: "3.13"
66
+ enable-cache: false
67
+ - name: Build Project
68
+ shell: bash
69
+ run: |
70
+ rm -rf build Perception.egg-info
71
+ echo "uv: $(uv --version)"
72
+ echo "Python: $(uv run python --version)"
73
+ echo "Git describe: $(git describe --tags --always)"
74
+ uv build --sdist --out-dir="dist"
75
+ - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
76
+ with:
77
+ name: package-sdist
78
+ path: dist/*
79
+
80
+ publish:
81
+ needs: [build-wheels, build-sdist]
82
+ runs-on: ubuntu-latest
83
+ if: ${{ github.repository_owner == 'thorn-oss' && github.event_name == 'release' }}
84
+ steps:
85
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
86
+ with:
87
+ # Full clone for version calculation
88
+ fetch-depth: 0
89
+ fetch-tags: true
90
+ ref: refs/tags/${{ github.event.release.tag_name }}
91
+ - name: Set up uv
92
+ uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
93
+ with:
94
+ python-version: "3.13"
95
+ enable-cache: false
96
+ - name: Download wheels
97
+ uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
98
+ with:
99
+ path: dist
100
+ pattern: package-*
101
+ merge-multiple: true
102
+ - name: Load PyPI Token
103
+ uses: 1password/load-secrets-action@7ce42673ba9ed69053d678faeba29ea36bd25755 # v4.0.0
104
+ with:
105
+ # Export loaded secrets as environment variables
106
+ export-env: true
107
+ env:
108
+ OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.DATA_SCIENCE_OP_SERVICE_ACCOUNT_TOKEN }}
109
+ UV_PUBLISH_TOKEN: op://data-science-oss/perception-pypi-api-key/secret/value
110
+ - name: Verify artifacts
111
+ run: |
112
+ mapfile -t artifacts < <(find dist -type f \( -name "*.whl" -o -name "*.tar.gz" \))
113
+ if [ ${#artifacts[@]} -eq 0 ]; then
114
+ echo "No artifacts found in dist"
115
+ exit 1
116
+ fi
117
+ printf '%s\n' "${artifacts[@]}"
118
+ if printf '%s\n' "${artifacts[@]}" | grep -E -- '-0\.0\.0([.-]|$)'; then
119
+ echo "Refusing to publish placeholder version 0.0.0 artifacts"
120
+ exit 1
121
+ fi
122
+ - name: Publish package
123
+ run: uv publish --trusted-publishing never --no-attestations
@@ -0,0 +1,41 @@
1
+ # MacOS stuff
2
+ .DS_Store
3
+
4
+ # Python artifacts
5
+ *.egg-info
6
+
7
+ # Cache
8
+ .mypy_cache
9
+ .pytest_cache
10
+ __pycache__
11
+ .ipynb_checkpoints
12
+ dist
13
+
14
+ # Any temporary images or CSV files
15
+ notebooks
16
+
17
+ # Local environment
18
+ .venv
19
+ .python-version
20
+ .pre-commit-cache/
21
+
22
+ # Coverage file
23
+ .coverage
24
+
25
+ # Versioneer artifacts
26
+ /versioneer.pyc
27
+
28
+ # Build artifacts
29
+ /build
30
+
31
+ # Docs build artifacts
32
+ /docs/_build
33
+
34
+ # Remove .vscode folder
35
+ .vscode
36
+
37
+ # Extension artifacts
38
+ *.c
39
+ *.cpp
40
+ *.so
41
+ debug-image*
@@ -0,0 +1,40 @@
1
+ # See https://pre-commit.com for more information
2
+ # See https://pre-commit.com/hooks.html for more hooks
3
+ repos:
4
+ - repo: https://github.com/pre-commit/pre-commit-hooks
5
+ rev: v4.5.0
6
+ hooks:
7
+ - id: trailing-whitespace
8
+ - id: end-of-file-fixer
9
+ - id: check-yaml
10
+ - id: check-added-large-files
11
+ - repo: https://github.com/psf/black
12
+ rev: 26.3.1
13
+ hooks:
14
+ - id: black
15
+ language_version: python3
16
+ - repo: https://github.com/astral-sh/ruff-pre-commit
17
+ # Ruff version.
18
+ rev: v0.11.13
19
+ hooks:
20
+ # Run the linter.
21
+ - id: ruff
22
+ args: [ --fix ]
23
+ - repo: https://github.com/pre-commit/mirrors-mypy
24
+ rev: v1.8.0
25
+ hooks:
26
+ - id: mypy
27
+ # Limit to package sources; `[tool.mypy] exclude` is ignored when
28
+ # pre-commit passes file paths as arguments.
29
+ files: ^perception/
30
+ # mirrors-mypy runs in an isolated env, so re-list any deps mypy
31
+ # needs to follow imports / type-check our code. Keep in sync
32
+ # with the dev dependency group in pyproject.toml.
33
+ additional_dependencies:
34
+ - numpy>=1.26.4,<3.0.0
35
+ - pandas
36
+ - pandas-stubs
37
+ - scipy
38
+ - typing_extensions>=4.0,<5.0
39
+ - types-pillow
40
+ - types-tqdm
@@ -0,0 +1,16 @@
1
+ version: 2
2
+
3
+ # Build documentation in the docs/ directory with Sphinx
4
+ sphinx:
5
+ configuration: docs/conf.py
6
+
7
+ formats: all
8
+
9
+ # Installs the package and the docs requirements.
10
+ python:
11
+ version: 3.9
12
+ install:
13
+ - requirements: docs/requirements.txt
14
+ - method: pip
15
+ path: .
16
+ system_packages: true
@@ -0,0 +1,47 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.9.0] - 2026-05-13
8
+ This release moves heavyweight dependencies behind optional extras so they are not installed for users who only need core hashing functionality, and standardizes the error users see when an extra is missing.
9
+
10
+ ### Breaking changes
11
+ - `faiss-cpu`, `networkit`, and `networkx` are no longer core dependencies. They are pulled in by the new `approximate-deduplication` extra (`pip install perception[approximate-deduplication]`), which is required to use `perception.approximate_deduplication` or `perception.local_descriptor_deduplication`.
12
+ - `pandas` is no longer a core dependency. It is pulled in by the `approximate-deduplication` and `benchmarking` extras (the only modules that use it). Code that imports `perception.benchmarking`, `perception.approximate_deduplication`, `perception.local_descriptor_deduplication`, or `perception.testing` should install the appropriate extra.
13
+
14
+ ### Enhancements
15
+ - All optional-dependency import sites — across the `approximate-deduplication`, `benchmarking`, `matching`, and `pdq` extras — now raise a uniform, actionable `ImportError` pointing at the correct `pip install perception[<extra>]` command when the relevant extra is not installed. This is implemented via a single helper, `perception._optional.import_optional`.
16
+ - `typing_extensions` is now an explicit core dependency (it was previously transitive via `faiss-cpu` / `pandas`).
17
+
18
+ ## [0.4.0] - 2020-10-17
19
+ This release switches from using false positive rates in benchmarking to reporting precision, which is more intuitive.
20
+
21
+ ### Breaking changes
22
+ All references to fpr_threshold now refer to precision_threshold.
23
+
24
+ ### Bug fixes
25
+ The PDQHash hasher now correctly returns the hash vector instead of the (vector, quality) tuple.
26
+
27
+ ## [0.3.0] - 2020-04-27
28
+ This release adds significantly more support for video.
29
+
30
+ ### Breaking changes
31
+ - Previously, `read_video` returned `(frame, index, timestamp)` tuples where `index` reflected the index of the yielded frame (i.e., it always increased by exactly 1). It now reflects the index of the frame in the original video. This means that, if the requested framerate is higher than the encoded video framerate, this index may repeat the same value, indicating that we have repeated the same frame.
32
+
33
+ ### Enhancements
34
+ - We now include a `SimpleSceneDetection` hasher that can wrap other video hashers using scene detection.
35
+ - `compute_metrics` is much faster now for integer-valued hashes that use a euclidean distance metric.
36
+ - We now include an unsigned 8-bit integer version of `PHash`, called `PHashU8`. This provides a useful framewise hasher for averaging across frames (e.g., using TMK) while being more compact than `PHashF`.
37
+ - We include more thorough support for benchmarking video hashes.
38
+
39
+ ### Bug fixes
40
+ - When using `hasher.vector_to_string` with hashers that return multiple hashes, the `hash_format` argument was not respected.
41
+ - The `compute_threshold_recall` and `show_histograms` functions did not work properly when `grouping=[]`.
42
+
43
+ ## [0.2.0] - 2019-12-20
44
+ This release adds more support for hashing videos (including TMK L2 and TMK L2). As part of that, it also includes a re-factor to separate `benchmarking.BenchmarkDataset` and `benchmarking.BenchmarkTransforms` into image and video variants.
45
+
46
+ ## [0.1.0] - 2019-11-04
47
+ Initial release
@@ -0,0 +1,76 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to make participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socio-economic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies within all project spaces, and it also applies when
49
+ an individual is representing the project or its community in public spaces.
50
+ Examples of representing a project or community include using an official
51
+ project e-mail address, posting via an official social media account, or acting
52
+ as an appointed representative at an online or offline event. Representation of
53
+ a project may be further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at conduct@thorn.org. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72
+
73
+ [homepage]: https://www.contributor-covenant.org
74
+
75
+ For answers to common questions about this code of conduct, see
76
+ https://www.contributor-covenant.org/faq
@@ -0,0 +1,7 @@
1
+ include perception/testing/images/*
2
+ include perception/testing/videos/*
3
+ include perception/testing/logos/*
4
+ include perception/**/*.pyx
5
+ include perception/*.pyx
6
+ include perception/py.typed
7
+ exclude tests/*
@@ -0,0 +1,58 @@
1
+ TEST_SCOPE?=tests/
2
+
3
+ .PHONY: build build-wheel build-sdist verify-version init-project init test lint_check type_check format format_check precommit clean-build
4
+
5
+ init-project:
6
+ uv sync --all-extras
7
+
8
+ init: init-project
9
+ uv run pre-commit install
10
+
11
+ test:
12
+ uv run pytest $(TEST_SCOPE)
13
+
14
+ lint_check:
15
+ uv run ruff check perception tests
16
+
17
+ type_check:
18
+ uv run mypy perception
19
+
20
+ format:
21
+ uv run black .
22
+
23
+ format_check:
24
+ uv run black --check . || (echo '\nUnexpected format.' && exit 1)
25
+
26
+ precommit:
27
+ uv lock --check
28
+ uv run ruff check perception tests
29
+ uv run mypy perception
30
+ uv run black --check . || (echo '\nUnexpected format.' && exit 1)
31
+ uv run pytest $(TEST_SCOPE)
32
+
33
+ verify-version:
34
+ @echo "uv: $$(uv --version)"
35
+ @echo "Python: $$(uv run python --version)"
36
+ @echo "Git describe: $$(git describe --tags --always)"
37
+
38
+ clean-build:
39
+ @rm -rf build Perception.egg-info
40
+
41
+ build-wheel:
42
+ @rm -rf build Perception.egg-info
43
+ @echo "uv: $$(uv --version)"
44
+ @echo "Python: $$(uv run python --version)"
45
+ @echo "Git describe: $$(git describe --tags --always)"
46
+ uv build --wheel --out-dir="dist-tmp" --clear
47
+ uv tool run --from repairwheel repairwheel -o dist dist-tmp/*.whl
48
+ @find dist -name "*.whl" -type f | sed -n "s/\(.*\)\.linux.*\.whl$$/& \1.whl/p" | xargs -r -n 2 mv # Fix wheel name
49
+ @rm -rf dist-tmp
50
+
51
+ build-sdist:
52
+ @rm -rf build Perception.egg-info
53
+ @echo "uv: $$(uv --version)"
54
+ @echo "Python: $$(uv run python --version)"
55
+ @echo "Git describe: $$(git describe --tags --always)"
56
+ uv build --sdist --out-dir="dist"
57
+
58
+ build: build-wheel build-sdist
@@ -1,43 +1,39 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Perception
3
- Version: 0.8.4
3
+ Version: 0.9.0
4
4
  Summary: Perception provides flexible, well-documented, and comprehensively tested tooling for perceptual hashing research, development, and production use.
5
+ Author-email: Thorn <info@wearethorn.org>
5
6
  License-Expression: Apache-2.0
7
+ Requires-Python: <4.0,>=3.10
8
+ Description-Content-Type: text/markdown
6
9
  License-File: LICENSE
7
- Author: Thorn
8
- Author-email: info@wearethorn.org
9
- Requires-Python: >=3.10,<4.0
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.10
12
- Classifier: Programming Language :: Python :: 3.11
13
- Classifier: Programming Language :: Python :: 3.12
14
- Classifier: Programming Language :: Python :: 3.13
15
- Classifier: Programming Language :: Python :: 3.14
10
+ Requires-Dist: numpy<3.0.0,>=1.26.4
11
+ Requires-Dist: opencv-contrib-python-headless<5.0.0,>=4.10.0
12
+ Requires-Dist: Pillow
13
+ Requires-Dist: pywavelets<2.0.0,>=1.5.0
14
+ Requires-Dist: validators<1.0.0,>=0.22.0
15
+ Requires-Dist: rich<14.0.0,>=13.7.0
16
+ Requires-Dist: scipy
17
+ Requires-Dist: tqdm<5.0.0,>=4.67.1
18
+ Requires-Dist: typing_extensions<5.0,>=4.0
19
+ Provides-Extra: approximate-deduplication
20
+ Requires-Dist: faiss-cpu<2.0.0,>=1.8.0; extra == "approximate-deduplication"
21
+ Requires-Dist: networkit<12.0.0,>=11.1; sys_platform != "darwin" and extra == "approximate-deduplication"
22
+ Requires-Dist: networkx<4.0,>=3.0; sys_platform == "darwin" and extra == "approximate-deduplication"
23
+ Requires-Dist: pandas; extra == "approximate-deduplication"
16
24
  Provides-Extra: benchmarking
25
+ Requires-Dist: matplotlib; extra == "benchmarking"
26
+ Requires-Dist: albumentations<3.0.0,>=2.0.8; extra == "benchmarking"
27
+ Requires-Dist: pandas; extra == "benchmarking"
28
+ Requires-Dist: tabulate; extra == "benchmarking"
29
+ Requires-Dist: scikit-learn; extra == "benchmarking"
30
+ Requires-Dist: ffmpeg-python; extra == "benchmarking"
17
31
  Provides-Extra: matching
32
+ Requires-Dist: aiohttp; extra == "matching"
33
+ Requires-Dist: python-json-logger; extra == "matching"
18
34
  Provides-Extra: pdq
19
- Requires-Dist: Cython (>=3.0.0,<4.0.0)
20
- Requires-Dist: Pillow
21
- Requires-Dist: aiohttp ; extra == "matching"
22
- Requires-Dist: albumentations (>=2.0.8,<3.0.0) ; extra == "benchmarking"
23
- Requires-Dist: faiss-cpu (>=1.8.0,<2.0.0)
24
- Requires-Dist: ffmpeg-python ; extra == "benchmarking"
25
- Requires-Dist: matplotlib ; extra == "benchmarking"
26
- Requires-Dist: networkit (>=11.1,<12.0.0) ; sys_platform != "darwin"
27
- Requires-Dist: networkx (>=3.0,<4.0) ; sys_platform == "darwin"
28
- Requires-Dist: numpy (>=1.26.4,<3.0.0)
29
- Requires-Dist: opencv-contrib-python-headless (>=4.10.0,<5.0.0)
30
- Requires-Dist: pandas
31
- Requires-Dist: pdqhash (>=0.2.7,<0.3.0) ; extra == "pdq"
32
- Requires-Dist: python-json-logger ; extra == "matching"
33
- Requires-Dist: pywavelets (>=1.5.0,<2.0.0)
34
- Requires-Dist: rich (>=13.7.0,<14.0.0)
35
- Requires-Dist: scikit-learn ; extra == "benchmarking"
36
- Requires-Dist: scipy
37
- Requires-Dist: tabulate ; extra == "benchmarking"
38
- Requires-Dist: tqdm (>=4.67.1,<5.0.0)
39
- Requires-Dist: validators (>=0.22.0,<1.0.0)
40
- Description-Content-Type: text/markdown
35
+ Requires-Dist: pdqhash<0.3.0,>=0.2.7; extra == "pdq"
36
+ Dynamic: license-file
41
37
 
42
38
  # perception ![ci](https://github.com/thorn-oss/perception/workflows/ci/badge.svg)
43
39
 
@@ -53,6 +49,39 @@ Description-Content-Type: text/markdown
53
49
 
54
50
  `pip install perception`
55
51
 
52
+ #### Optional extras
53
+
54
+ `perception` provides optional extras for additional functionality:
55
+
56
+ - `approximate-deduplication` – FAISS-based approximate-nearest-neighbor
57
+ deduplication and graph community/clique detection (used by
58
+ `perception.approximate_deduplication` and
59
+ `perception.local_descriptor_deduplication`)
60
+ - `benchmarking` – tools for benchmarking perceptual hashes
61
+ - `matching` – async matching utilities
62
+ - `pdq` – Facebook's PDQ hash support
63
+
64
+ **Note for `benchmarking` extra users:** The `benchmarking` extra depends on
65
+ `albumentations`, which in turn requires `opencv-python-headless`. However,
66
+ `perception` already depends on `opencv-contrib-python-headless` (needed for
67
+ contrib modules such as `cv2.img_hash` and `cv2.SIFT_create`). Installing both
68
+ OpenCV distributions simultaneously causes file-level conflicts.
69
+
70
+ If you are using [uv](https://docs.astral.sh/uv/), this is handled
71
+ automatically:
72
+
73
+ ```bash
74
+ uv pip install "perception[benchmarking]"
75
+ ```
76
+
77
+ If you are using plain `pip`, install the extra and then force-reinstall the
78
+ contrib variant to remove the conflicting headless package:
79
+
80
+ ```bash
81
+ pip install "perception[benchmarking]"
82
+ pip install --force-reinstall --no-deps opencv-contrib-python-headless
83
+ ```
84
+
56
85
  ### Hashing
57
86
 
58
87
  Hashing with different functions is simple with `perception`.
@@ -92,11 +121,12 @@ See below for end-to-end examples for common use cases for perceptual hashes.
92
121
  To work on the project, start by doing the following.
93
122
 
94
123
  ```bash
95
- # Install local dependencies for
96
- # code completion, etc.
124
+ # Install local dependencies for code completion,
125
+ # testing, and linting.
97
126
  make init
127
+ ```
98
128
 
99
- - To do a (close to) comprehensive check before committing code, you can use `make precommit`.
129
+ To do a (close to) comprehensive check before committing code, use `make precommit`.
100
130
 
101
131
  To implement new features, please first file an issue proposing your change for discussion.
102
132
 
@@ -111,5 +141,3 @@ examples.
111
141
  - [imagededup](https://idealo.github.io/imagededup/)
112
142
  - [ImageHash](https://github.com/JohannesBuchner/imagehash)
113
143
  - [PhotoHash](https://github.com/bunchesofdonald/photohash)
114
- ```
115
-