The Challenge
Saudi Arabia has several distinct local sheep breeds, each with unique physical characteristics. Identifying them accurately requires domain expertise that isn't always available. The goal was to build an accessible web tool that anyone could use — simply upload a photo and get an instant breed classification.
The system needed to:
- Accurately distinguish between 4 local Saudi sheep breeds
- Provide a simple, user-friendly web interface for photo uploads
- Return results with high confidence (≥95%)
- Be deployed as a publicly accessible, containerized service
Architecture Overview
The solution uses a fully AWS-native architecture with Docker containerization, managed container orchestration, and a custom-trained ML model.
Fig 1. AWS Architecture — Sheep Breed Recognition System
How It Works
Docker Image on EC2
The web application was Dockerized and the image was built on a private EC2 instance for security, then pushed to Amazon ECR.
ECS Public Service
The container runs on Amazon ECS as a public-facing web service, exposed through an Internet Gateway within a VPC.
Route 53 DNS
Amazon Route 53 handles domain name resolution, providing a clean URL for users to access the application.
Rekognition Classification
Uploaded photos are stored in S3. Amazon Rekognition (custom-trained model) analyzes the image and returns the breed type to the client.
Implementation
The core classification logic uses the Boto3 SDK to call Amazon Rekognition's custom labels API:
The MinConfidence=95 threshold ensures only high-confidence predictions are returned, reducing false positives across the 4 breed categories.
Tech Stack
Infrastructure Details
- VPC Design: Public subnet hosts the ECS service (Internet Gateway access); private subnet hosts the EC2 build instance for security isolation
- Container Registry: Docker images stored in Amazon ECR, pulled by ECS task definitions at deployment
- Storage: User-uploaded images land in an S3 bucket, which Rekognition reads directly via S3Object references
- DNS: Route 53 provides a human-readable domain pointing to the ECS service endpoint
- Security: Build process isolated on private EC2; ECS service exposed only through controlled Internet Gateway path
Key Takeaways
- Custom-trained Rekognition models can achieve production-grade accuracy for niche classification tasks
- Containerizing the application with Docker + ECS provides scalable, reproducible deployments
- Separating the build environment (private EC2) from the runtime (public ECS) follows security best practices
- The S3 → Rekognition pipeline eliminates the need to transfer image data through the application layer