The Celebrity Image Sorter is a Python script that automates the process of sorting images into folders named after celebrities. It utilizes AWS Rekognition to recognize celebrities in the images stored in an AWS S3 bucket.
Before you begin, ensure you have met the following requirements:
- You have installed Python 3.6 or later.
- You have an AWS account with access to AWS S3 and Rekognition services.
- You have installed
boto3
, which is the AWS SDK for Python.
To run this project, follow these steps:
- Sign in to your AWS Management Console.
- Navigate to the IAM (Identity and Access Management) dashboard.
- Create a new IAM user with programmatic access and attach the
AmazonRekognitionFullAccess
andAmazonS3FullAccess
policies. - Download the credentials CSV file after creating the user. It contains the Access Key ID and Secret Access Key.
- Create an S3 bucket where your images will be stored and processed.
-
Create a virtual environment (optional but recommended):
python -m venv .venv source .venv/bin/activate # For Unix/macOS .venv\Scripts\activate # For Windows
-
Install
boto3
anddotenv
using pip:pip install boto3 pip install python-dotenv
-
Place the credentials CSV file you downloaded from AWS in your project directory.
-
Update the bucket_name variable in the script to match the name of your S3 bucket.
-
Place the images you want to sort in a directory named
./images/
relative to the script or modify the images_local_path variable in the script accordingly. -
Create a
.env
file in the root directory, and fill in the following fields:AWS_BUCKET_NAME=bucket_name AWS_REGION=your_region UNSORTED_FOLDER=unsorted/ SORTED_FOLDER=sorted/
Execute the script from the command line:
python .\celebrity_image_sorter.py
The script will upload images from your specified directory to the S3 bucket, sort them into folders named after the recognized celebrities using AWS Rekognition, and move them into the sorted/ folder within your S3 bucket.