An automated solution to sort images based on facial recognition. This tool scans through folders with large amounts of files and organizes media containing specific people you want to keep.
WhatsApp and other messaging apps often consume large portions of phone storage with unwanted media that we download but don't need long-term. However, some images contain important people (family, friends) that we want to keep. Manually sorting through hundreds or thousands of images is tedious.
Quick Face Sort automates this process using AWS Rekognition to identify and organize images based on faces.
Read this article for more info
quick-face-sort/
├── README.md
├── main.py
├── test_locally.py
├── requirements.txt
├── .gitignore
├── images/
│ ├── automate-instead.jpg
│ ├── quick-face-sort.png
│ ├── quick-face-sort-cloud.png
│ └── quick-face-sort-local.png
└── terraform/
├── main.tf
├── output.tf
└── .terraform.lock.hcl
- AWS Account
- AWS CLI installed and configured
- Terraform installed
- Python 3.9+
- Boto3 library
-
Install AWS CLI
- Install AWS CLI following the official documentation
- Verify installation with:
aws --version
-
Configure AWS Credentials
aws configure
You'll need to provide:
- AWS Access Key ID
- AWS Secret Access Key
- Default region name (e.g., us-east-1)
- Default output format (json recommended)
- Learn more about creating and managing AWS credentials
-
Required IAM Permissions Ensure your AWS user has permissions for:
- S3 (CreateBucket, PutObject, GetObject, etc.)
- Lambda
- IAM Role creation
- CloudWatch Logs
- Rekognition
Consider using the AWS managed policies:
- AmazonS3FullAccess
- AmazonRekognitionFullAccess
- AWSLambda_FullAccess
- IAMFullAccess
- CloudWatchLogsFullAccess
- Clone the repository
git clone https://github.com/sin4ch/quick-face-sort.git cd quick-face-sort
- Install dependencies
pip install -r requirements.txt
- Deploy infrastructure with Terraform
cd terraform terraform init terraform plan terraform apply
- Upload reference images
- Upload photos of people you want to identify to the reference S3 bucket
- Each person should have at least one clear facial image
- Upload images to sort
- Upload images to the database S3 bucket
- The Lambda function will automatically process these images
- View Results
- Images will be organized into folders named after the reference images
- Check CloudWatch logs for processing details
AWS Rekognition supports the following image formats:
- JPEG
- PNG
- Note: Other formats may not be properly analyzed
- Reference photos are stored in a dedicated S3 bucket
- New photos uploaded to the database bucket trigger a Lambda function
- The Lambda function uses AWS Rekognition to compare faces
- Images with matching faces are organized into folders
- Logs are stored in CloudWatch for monitoring
-
Local Version: A local command-line version may be developed to process images (and videos) directly on your computer.
-
API Version: An API version may be developed to allow integration with other application
Other relevant information to add:
-
Cost Warning:
This project uses several AWS services that may incur costs:
- S3 storage for your images
- Lambda function invocations
- Rekognition API calls
- CloudWatch Logs
Please review AWS pricing to understand potential costs.
- "Access Denied" errors: Check your AWS credentials and IAM permissions
- Terraform errors: Ensure your account has permissions to create all resources
- Image not recognized: Ensure faces are clearly visible and well-lit
- Lambda timeout: For large images or many comparisons, consider increasing the Lambda timeout in terraform/main.tf
Check CloudWatch Logs for detailed information:
- Open the AWS Console
- Navigate to CloudWatch > Log Groups
- Find the log group named "/aws/lambda/quicksort_face_processor"
To test the face recognition functionality locally:
- Configure AWS credentials as described above
- Run the main.py script directly:
python main.py
- This will process images using your local AWS credentials but still requires connectivity to AWS services