A benchmarking system that measures OpenCV image-processing performance across AWS Graviton (ARM64) EC2 instances. It spins up real EC2 instances, runs a configurable image pipeline in volatile memory (no S3/disk bottlenecks), and reports throughput, latency, and cost side-by-side.
- The orchestrator (
shared/benchmark-orchestrator.py) exposes a REST API on port8080. It receives benchmark requests from the frontend, launches EC2 instances via the AWS SDK, runs the OpenCV pipeline over SSH/SSM, collects results, and terminates instances when done. - The frontend (
frontend/serve.py) serves a static web UI on port3000that lets you configure and trigger benchmarks, watch live progress, and compare results. - The local asset pool (
assets/, 27 JPEGs) is the benchmark image workload — loaded directly into memory at run time, no API keys or network access required.
- Python 3.10+
- An AWS account with permission to launch EC2 instances (e.g.
t4g,m7g,c7g,m6ifamilies) - An EC2 key pair in your target region
- The AWS Marketplace OpenCV Graviton AMI ID for your region
git clone https://github.com/opencv/COOL-Benchmark
cd COOL-Benchmarkpython3 -m venv cool
source cool/bin/activate # Linux / macOS
# cool\Scripts\activate # Windowspip install -r requirements.txtcp config-marketplace.example.json config-marketplace.jsonOpen config-marketplace.json and replace ami-xxxxxxxxxxxxxxxxx with the OpenCV Graviton AMI ID from AWS Marketplace for your region. You can also set this later through the UI.
Set these before starting either process. Open a terminal and run:
# AWS credentials — used by the orchestrator to launch EC2 instances
export AWS_ACCESS_KEY_ID="YOUR_AWS_ACCESS_KEY_ID"
export AWS_SECRET_ACCESS_KEY="YOUR_AWS_SECRET_ACCESS_KEY"
export AWS_DEFAULT_REGION="us-east-1" # change to your preferred region
# EC2 key pair name — must already exist in the region above
export EC2_KEY_PAIR_NAME="your-ec2-key-pair-name"
# (Optional) Pre-configure the Marketplace AMI ID instead of entering it in the UI
# export MARKETPLACE_AMI_ID="ami-xxxxxxxxxxxxxxxxx"Open two terminals, both with the environment variables above already exported.
cd COOL-Benchmark
python shared/benchmark-orchestrator.pyExpected output:
INFO benchmark-orchestrator - Benchmark orchestrator started on http://0.0.0.0:8080
cd COOL-Benchmark
python frontend/serve.pyExpected output:
Frontend server running at http://localhost:3000/
Press Ctrl+C to stop
Navigate to http://localhost:3000 in your browser.
The benchmark uses a local set of 27 pre-seeded JPEG images shipped in the assets/ directory. No API keys or external network access are needed to load the image workload.
In the UI, click "Load Local Sample Images" to read the images from disk into memory before running a benchmark. The orchestrator resolves the assets/ path relative to the repo root automatically, so no path configuration is required.
COOL-Benchmark/
├── assets/ # Static benchmark image pool (27 JPEGs)
├── shared/
│ ├── benchmark-orchestrator.py # Main backend — REST API + EC2 orchestration
│ ├── benchmark_executor.py # Per-instance benchmark runner
│ ├── build_manager.py # OpenCV build/install logic on remote instances
│ └── shared_instance_benchmark.py
├── agentcore/
│ └── instance-manager.py # EC2 lifecycle management (launch, pool, terminate)
├── opencv-ami/
│ ├── opencv-mcp-server.py # MCP server deployed to every EC2 instance at runtime
│ └── install-opencv-optimized.sh # Graviton-optimised OpenCV build script (used by compile-from-source option)
├── frontend/
│ ├── serve.py # Static file server (port 3000)
│ ├── index.html # Main UI
│ ├── app.js # Frontend logic
│ └── styles.css
├── requirements.txt # All Python dependencies
├── config-marketplace.example.json # Template — copy to config-marketplace.json and fill in your AMI ID
└── README.md
- Processing duration (seconds per scenario)
- Throughput (images per second)
- Cost estimate (USD, live AWS pricing)
- Instance count (active at peak)
- Real-time image preview (cycles through processed results)
Select OpenCV 4 or OpenCV 5 directly in the UI before running a benchmark. The orchestrator installs the corresponding wheel on each EC2 instance at launch time — no code changes needed.
| UI selection | Wheel installed |
|---|---|
| OpenCV 4 | opencv-python-headless==4.12.0.88 |
| OpenCV 5 | opencv-python-headless==5.0.0.93 |
Orchestrator fails to launch instances
- Confirm
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY, andAWS_DEFAULT_REGIONare exported. - Verify your IAM user/role has
ec2:RunInstances,ec2:DescribeInstances,ec2:TerminateInstances, andssm:SendCommandpermissions. - Check that
EC2_KEY_PAIR_NAMEmatches an existing key pair in the configured region.
Frontend shows "Cannot connect to backend"
- Make sure the orchestrator is running and listening on port
8080before opening the UI. - Both processes must be in the same network context (local machine or same EC2 instance).