Python code to find and display all the exact duplicate images and videos in a folder and delete them (optional).
Begins search at the current folder. Repeats it for all sub-directories as well.
Type | Run command |
---|---|
Images | python images_duplicate_exact.py |
Videos | python videos_duplicate_exact.py |
Or Run "duplicate_media_exact.bat" on a Windows system to run both programs sequentially (images followed by videos).
Argument | Usage | Default |
---|---|---|
folder | Folder to begin the search. Subfolders are included. | Current path |
keep_largest | Keep the file with the largest or smallest size among the duplicates. 1 for largest and 0 for smallest. | 1: Keep largest |
compare_size | Images are resized to this value for comparison. Higher value compares more pixels but requires more RAM and runs slower. |
300 gives accurate and fast results. |
This program requires Python with numpy and tqdm libraries to function.
Run the following command to install the dependent libraries in the Python environment if they are not present already:
pip install -r requirements.txt
Images are compared using pixel-wise comparison using cosine distance after setting them to a fixed size.
Videos are compared using pixel-wise comparisons using cosine distance on the first frame (with a fixed size) and by matching their frame length.