DeepFace Based Batch Face Similarity Sorting Gradio APP For Windows, RunPod and Massed Compute - 1-Click to Install - Uses TensorFlow GPU - Very Fast
A batch face similarity sorting Gradio APP that utilizes DeepFace library - Extremely useful to sort AI generated images according to their
Please visit Patreon exclusive posts index to find all of our Patreon scripts, posts, apps and more.
Join discord to get help, chat, discuss and also tell me your discord username to get your special rank : SECourses Discord
Please also Star, Watch and Fork our Stable Diffusion & Generative AI GitHub repository and join our Reddit subreddit and follow me on LinkedIn (my real profile)
=======
Latest zip file : sort_by_similarity_v12.zip
22 July 2025 Update v12
All Windows, RunPod and Massed Compute installers updated
Now RunPod uses below template so be careful
Runpod Pytorch 2.1
runpod/pytorch:2.1.0-py3.10-cuda11.8.0-devel-ubuntu22.04
For Windows, now the app will auto download and use Cuda 11.8 runtime, cudnn 8.9 runtime and tensorrt runtime so it should work with just Python 3.10.11 you have installed
23 June 2025 Update v8
New option Use Best Match (Minimum Distance) added
Printed messages on CMD significantly improved
Multi-threading logic improved
GPU usage logic improved
16 June 2025 Update
Now supports RTX 5000 series GPUs too
Now you can sort sub folders too
This APP is based on DeepFace
https://github.com/serengil/deepface
It is fully multi-threaded and higher batch size increase your processing speed
Make sure to have accurately installed CUDA and cuDNN for TensorFlow library to use your GPU or else it will be ultra slow
It uses minimal amount of VRAM so should work on every GPU pretty much
What this APP does is that, it takes source images folder, target images folder and optionally extracted faces folder
Then it calculates every target image similarity / distance to the source images individually (if multiple source images used it averages them) and at the end sort all target images according to their similarity / distance
When you use more than 1 image in source images folder, it will sort according to the average of the source images but be careful it will increase processing time linearly since each image compared with each target image
If few images gives error at first run, you can run again and it usually fixes error occurred images - i am still not sure why this happens - probably related to DeepFace library
This app can be extremely useful to sort AI generated images according to the original training images to get the best ones comparatively
The images in target folder will be renamed as the followings
Image_Similarity_Rank - Image_Similarity_Score - Older File Name
e.g. image_rock.png will become 33 - 0.55 - image_rock.png
33 is similarity rank, 0.55 is its distance (lesser is more similar)
Following DeepFace models supported but I didn't test them except Facenet512 which is best
This zip file has example code of how to auto download and use CUDA 11.8, cuDNN 8.9 and TensorRT on Windows without system wide installing.
It also has example code of installing CUDA 11.8 on Linux without breaking installed NVIDIA driver.
Moreover, this app has example code and install for TensorFlow GPU for all GPUs including RTX 5090.
Windows Requirements
Python 3.10, FFmpeg
If it doesn't work make sure to below tutorial and install everything exactly as shown in this below tutorial
How To Install and Use:
Windows:
First watch above requirements tutorial and follow every step
Extract zip archive into a drive like c:/face_sort
Longer directory path causes issues
Double click and install with Windows_Install.bat and that is it
Then run with Windows_Start_App.bat to start Similarity Sorter SECourses APP
And follow above and below attached screenshot
Massed Compute (Recommend Cloud) :
Please register via this link : https://vm.massedcompute.com/signup?linkId=lp_034338&sourceId=secourses&tenantId=massed-compute
We have a special coupon for all GPUs : SECourses
If you want to learn more about GPUs and prices read this link : https://www.patreon.com/posts/126671823
Select RTX A6000 or Better GPU - like L40S or A6000 ADA or A100 or H100
Then select our image SECourses from Creator dropdown
Then follow Massed_Compute_Instructions_READ.txt
Same as my any other Massed Compute installer script
Example tutorial for learn how to install and use Massed Compute
(Starts at 12:58) : https://youtu.be/KW-MHmoNcqo?si=G1WbG-Qw4ujWvOtG&t=778
RunPod (Cloud):
Please register via this link : https://get.runpod.io/955rkuppqv4h
Then follow Runpod_Instructions_READ.txt
Same as my any other RunPod installer script
Use the template written in Runpod_Instructions_READ.txt file
Example tutorial for learn how to install and use RunPod
(starts at 22:03) : https://youtu.be/KW-MHmoNcqo?si=QN8X8Sjn13ZYu-EU&t=1323