A new reference architecture enables fleet-wide computer vision at the edge using Amazon SageMaker SDK v3.
Why One Model Fails at Scale
Early proof-of-concept models work well with a single camera.
When a plant expands to 40 lines with multiple cameras, each sees a different angle, glare, and lighting.
One model trained on pooled footage fails to detect anomalies specific to individual cameras.
Each camera now needs its own fine-tuned model.
From One Model to Thousands
Training one model is no longer the challenge.
The real problem is managing thousands of models—training, evaluating, versioning, and deploying them without human intervention.
Manual oversight becomes impossible at scale.
How the Architecture Works
The solution uses a dual-branch SageMaker Pipeline.
Each branch trains an anomaly detector and a defect classifier for a single camera.
The pipeline runs 13 steps per execution, with three entry steps running in parallel.
Parallel Entry Steps
- Preprocess: prepares the camera’s images.
- Fetch Latest Anomaly: retrieves the most recent approved model for the anomaly branch.
- Fetch Latest Classifier: retrieves the most recent approved model for the classifier branch.
Model Training
The anomaly detector uses a small convolutional autoencoder.
It learns what normal product looks like and flags anomalies by reconstruction error.
The defect classifier uses a fine-tuned ResNet18 model.
It confirms the presence of defects with a two-class head.
Model Evaluation
Each model is evaluated using the exported ONNX artifact, not the in-memory PyTorch model.
Only the artifact shipped to devices is evaluated.
This prevents broken models from slipping through.
Quality Gates
The anomaly branch requires an AUROC of at least 0.8.
The classifier branch requires two metrics:
- Balanced accuracy of at least 0.6.
- Defect recall of at least 0.5.
Accuracy alone is meaningless in such cases.
These thresholds ensure the model catches real defects, not just normal images.
ConditionStep Logic
The quality gate uses a ConditionStep with two conditions.
Both must pass for the model to proceed.
If either fails, a FailStep marks the execution as failed.
The model does not register in the registry.
The fleet continues serving the previous approved model for that camera.
Compiling for Edge Devices
After quality gates, models are compiled with SageMaker Neo.
Compilation happens inside the pipeline, after evaluation.

Only approved models with compiled artifacts are registered.
Compilation Requirements
- The input tarball must contain only the ONNX model.
- Dynamic batch axes in exports are replaced with a fixed batch size of 1.
- Compilation job names are derived from the execution ID to support retries.
Target Device Selection
NeoTargetDevice selects a device like jetson_xavier or rasp4b.
Default compilation targets LINUX/X86_64.
The output includes a compiled.so file and the DLR runtime.
Compilation incurs no charge.
Costs come from the training instance and S3 storage.
Model Registry Structure
Each branch registers into its own model package group.
Every model package includes the camera ID and evaluation metrics.
Camera identity is stored in customer_metadata_properties.
Warm-Start Capability
Each camera has a fetch step that finds the latest approved model by camera ID.
On first run, no prior model exists, so training uses cold-start initialization.
On later runs, it resumes from the previous model.
This enables frequent, low-cost retraining across the fleet.
What the Registry Catalogs
The registry holds versioned, quality-gated artifacts.
It does not host inference endpoints.
It supports downstream systems that pull artifacts and deploy them to devices.
Orchestrating Training at Scale
Each AWS account has quotas on concurrent SageMaker training jobs.
Each pipeline execution launches multiple training jobs.
A burst of 500 requests could exceed these limits.
Concurrency Control
The system uses a DynamoDB semaphore with five available slots.
Before starting a pipeline, a Lambda function acquires a slot.
It waits if all slots are taken.
After completion, it releases the slot.
Atomic Operations
The DynamoDB condition expression enforces the cap in one atomic operation.
This avoids race conditions that could occur with a read-and-decision step.
Scalability Limits
The default cap of five is low to avoid quota requests.
It can be adjusted to match account-level training quotas.
For larger fleets, scaling options include:
- Raising service quotas.
- Spreading training across instance types or regions.
- Distributing the fleet across multiple AWS accounts.
- Holding work in SQS and admitting it only when capacity frees up.
Deployment and Execution
Deployment follows a two-phase process.
First, a bootstrap deploy creates IAM roles, S3 bucket, and ECR repository.
Second, the pipeline is deployed with the full orchestration layer.
Setup Steps
- Clone the GitHub repository.
- Set up a Python virtual environment.
- Install dependencies from requirements.txt.
- Run cdk bootstrap once per account and region.
- Deploy the stack with bootstrap=true to create roles and resources.
- Deploy the full pipeline with cdk deploy –all.
- Run a script to build and push the training image to ECR.
Cost and Performance
A full pipeline run on synthetic data takes about 15 minutes.
It costs roughly $0.07 in compute (US East (Ohio) Region, July 2026).
Orchestration resources cost under $0.10 per month at sample scale.
Real-World Data Support
The repository includes a script to download the BCCD dataset.
It contains 364 annotated blood smear images in Pascal VOC format.
Platelet presence is mapped to a defect class.
The script simulates a fleet by splitting images per camera.
A notebook runs the full pipeline on real data and compares ONNX inference on normal and anomalous samples.
Limitations and Considerations
Model packages are created at runtime and cannot be deleted by CloudFormation.
Manual cleanup is required using the AWS CLI.
Stacks must be destroyed with cdk destroy –all -c bootstrap=true –force.
The sample does not include inference endpoints.
It is designed for device deployment, not for real-time inference via Amazon SageMaker endpoints.
Why This Matters
Many AI tools offer managed solutions like Amazon Lookout for Vision.
These are simpler but do not support per-camera, fleet-scale use cases.
This architecture fills a gap for industrial environments with diverse camera views.
Design Principles for Other Use Cases
- Gate on balanced accuracy and minority-class recall, not overall accuracy.
- Evaluate and compile the artifact you ship.
- Make operational failures notify rather than terminate silently.
Next Steps for Users
Users can clone the repository and run the sample.
They can point the BCCD downloader at a real bucket.
They can set NeoTargetDevice to match their hardware.
They can adjust the orchestration cap to match their fleet size.
For SDK v3 migration, refer to the official documentation and the two-part series announcing the new SDK.
If you need help adapting this pattern to your environment, contact your AWS account team.
For a visual example of data mapping and device deployment, see Visualize Points and Routes with GeoJSON in Amazon Quick Sight Layer Maps.
Sources & further reading
Featured image: original publisher image. Via original publisher. Image source

