Registry / ai-ml / imagededup

imagededup

JSON →
library0.3.3.post2pypypi✓ verified 23d ago

Imagededup is a Python package that simplifies finding exact and near-duplicate images in a collection. It offers various algorithms like perceptual hashing (PHash, DHash, WHash, AHash) and convolutional neural networks (CNNs) for robust deduplication. The package also includes an evaluation framework and plotting utilities for duplicates. The current version is 0.3.3.post2, and it maintains an active development cadence.

pip install imagededup
INSTALL
IMPORT
SIG · IMAGEDEDUP
I
imagededup
ai-mlpythonv0.3.3.post2
Install
82.9s avg
Import
19927ms
Disk
5120MB
Pass rate
3/ 10
Env Coverage3 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.3.post2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 86.2s
py 3.11
✕ build_error
✓ 86.6s
py 3.12
✕ build_error
✓ 75.8s
py 3.13
✕ build_error
✕ build_error
py 3.9
✕ build_error
✕ timeout
5120MB installed
● package 5120MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PHash
from imagededup.methods import PHash
DHash
from imagededup.methods import DHash
WHash
from imagededup.methods import WHash
AHash
from imagededup.methods import AHash
CNN
from imagededup.methods import CNN
plot_duplicates
from imagededup.utils import plot_duplicates

This quickstart demonstrates how to use the Perceptual Hashing (PHash) method to find duplicate images in a specified directory. It involves initializing the hashing method, generating image encodings, and then finding duplicates based on these encodings. The example includes creating a dummy directory and files for immediate execution.

import os from imagededup.methods import PHash # Create a dummy image directory and some dummy files for demonstration # In a real scenario, 'image_dir' would point to your directory of images. image_dir = './my_images' os.makedirs(image_dir, exist_ok=True) with open(os.path.join(image_dir, 'image1.jpg'), 'w') as f: f.write('dummy image content 1') with open(os.path.join(image_dir, 'image2.png'), 'w') as f: f.write('dummy image content 2') # Add more dummy images as needed to test deduplication # Initialize a perceptual hashing method phasher = PHash() # Generate encodings for all images in the directory encodings = phasher.encode_images(image_dir=image_dir) # Find duplicates using the generated encodings duplicates = phasher.find_duplicates(encoding_map=encodings) print(f"Found duplicates: {duplicates}") # Optionally, remove the dummy directory and files # import shutil # shutil.rmtree(image_dir)
Debug
Known issues
breakingPython 3.8 and older versions are no longer supported. Imagededup now requires Python 3.9 or higher.
fix
Upgrade your Python environment to 3.9 or newer.
affects: <=0.3.2
breakingCNN encodings size has changed from 1024 to 576, and the underlying network might differ. This means CNN encodings from previous versions are incompatible.
fix
Re-generate CNN encodings for your image collection when upgrading from older versions. Also, similarity thresholds might need adjustment for optimal performance with the new encodings.
affects: >=0.3.0
breakingHashes (all types) generated by versions >=0.3.0 may differ from previous versions for a given image, making older hash maps incompatible.
fix
Re-generate all image hashes if upgrading from a version older than 0.3.0.
affects: >=0.3.0
gotchaWhen using CNNs for deduplication, memory usage can increase quadratically with the number of images during retrieval (cosine similarity matrix calculation).
fix
For very large datasets, consider using approximate nearest neighbor libraries (e.g., FAISS) or alternative strategies if memory becomes a bottleneck. Benchmarking with your specific dataset is recommended.
affects: All
gotchaThe optimal `min_similarity_threshold` for CNN and `max_distance_threshold` for hashing methods can vary significantly based on your dataset and the type of duplicates (exact vs. near-duplicates) you are trying to find.
fix
Experiment with different threshold values for your specific dataset. The documentation suggests `min_similarity_threshold` around 0.9 for CNNs and `max_distance_threshold` of 0 for exact duplicates with hashing methods.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'imagededup'
The 'imagededup' package is not installed in the Python environment where the code is being executed.
fix
Install the package using pip: `pip install imagededup`
ERROR: Failed building wheel for imagededup
This error often occurs on Windows systems when the necessary C++ build tools (like Microsoft Visual C++ Build Tools) are not installed, which are required to compile Cython extensions included in 'imagededup' during installation.
fix
Install Microsoft Visual C++ Build Tools 14.0 or greater (available from visualstudio.microsoft.com/visual-cpp-build-tools/) or try installing 'imagededup' within a clean virtual environment where dependencies can be managed without conflicts.
cannot identify image file 'path/to/img/file'
The image file specified could not be opened or read by the Pillow library (used by 'imagededup'), often due to an incorrect file path, an unsupported image format, or a corrupted image file.
fix
Verify that the image file path is correct, ensure the image is not corrupted, and confirm that its format is supported by Pillow (e.g., JPEG, PNG). Sometimes, restarting the runtime or ensuring sufficient memory can resolve transient issues.
AttributeError: 'list' object has no attribute 'astype'
This error arises when a Python list is incorrectly treated as a NumPy array, specifically when attempting to call the `.astype()` method, which is exclusive to NumPy array objects.
fix
Convert the Python list to a NumPy array before attempting to use `.astype()`: `import numpy as np; your_array = np.array(your_list).astype(desired_type)`.
Could not find a version that satisfies the requirement tensorflow==X.Y.Z (from imagededup)
There is a version conflict with TensorFlow, meaning the specific version required by 'imagededup' (especially for its CNN-based methods) cannot be found or is incompatible with other packages already installed in your environment.
fix
Install a compatible version of TensorFlow manually before installing 'imagededup' (e.g., `pip install tensorflow==<compatible_version>`), or install 'imagededup' in a clean virtual environment to allow it to install its preferred TensorFlow dependency without conflicts.
Upgrade
Version history
0.3.3.post2latest on PyPI · released Aug 15, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
31 hits · last 30 days
node
30
Resources