AWS shows how to run a separate AI model for each factory camera: a test run for $0.07
When defect detection works on one camera, the factory asks for the same across 40 lines, but a single shared model gets confused: every camera has its own angle, glare, and lighting. AWS has shown a template built on the SageMaker SDK v3. Each camera gets its own trained models, a quality threshold filters out the weak ones, and a run on synthetic data costs about $0.07. It is a foundation for teams managing fleets of thousands of models without manual work.
AI-processed from AWS Machine Learning Blog; edited by Hamidun News
A pilot for production quality control almost always looks successful: one camera, one model, everything works. Problems start when the factory asks to repeat the result across 40 lines, with several cameras on each. Every camera has its own viewing angle, its own glare off the stainless steel, and its own lighting, which changes depending on which shop gates are open. AWS writes that in real deployments, one model trained on shared footage underperforms on too many cameras. So in the end, each camera gets its own fine-tuned model. The task changes: it is no longer about training one model well, but about training, validating, versioning, and delivering thousands of models without manual work on each one.
The AWS Machine Learning blog has published an update to the template from its 2023 series. It has been ported to the SageMaker Python SDK v3, and the deprecated SageMaker Edge Manager has been replaced with SageMaker Neo, which compiles a model for a specific device. A full run on synthetic data costs about $0.07 in compute. The code is in the aws-samples repository and is deployed through AWS CDK.
How the pipeline works for one camera
The training part is a single 13-step SageMaker Pipeline, launched with a "camera" parameter. First, three steps run in parallel: preparing that camera's images and looking up the latest approved models for both branches. Then two models are trained. The first is a small convolutional autoencoder: it learns what a normal part looks like and flags anomalies by how poorly it can reconstruct the image. The second is a ResNet18, fine-tuned to confirm a specific defect.
Each branch exports its model to ONNX, validates the exported file itself on held-out data, and must pass a quality threshold. After passing the threshold, the model is compiled with SageMaker Neo for the chosen device and only then goes into the Model Registry. That is why every approved package comes with a ready build for the hardware. The camera ID is stored in the package metadata, and retraining starts from the latest version for that same camera.
Why the quality threshold is designed this way
In factory data, about 90% of images are good parts. Plain accuracy is useless here: a model that answers "good" to everything scores about 90% and finds zero defects. Balanced accuracy, meaning the average of the detection rate for each class, is better but still misleads.
A model that correctly recognizes 100% of good parts and only 20% of defective ones scores (100% + 20%) / 2 = 60%. So the classifier must pass two conditions at once: balanced accuracy of at least 60% and a defect detection rate of at least 50%. The autoencoder is checked with the AUROC metric, which shows how confidently the model separates normal from anomalous: a threshold of 80%, whereas 50% would mean guessing.
Thresholds are set as pipeline parameters and can change on each run without redeploying. If a branch fails its threshold, the run is marked as failed and the model does not enter the registry. The branches are validated independently, and the camera keeps running on the previous approved model. Class imbalance is also handled during training: batches are assembled with a WeightedRandomSampler using weights inverse to class frequency, while the loss function itself stays unweighted. On small single-camera datasets, fine-tuning from ImageNet-pretrained weights helps keep the model from collapsing to answering "good" for everything.
Training queue and SDK v3 pitfalls
To keep a burst of requests from launching hundreds of trainings at once, the pipeline sits behind a queue and a semaphore. Requests land in SQS FIFO, a Lambda starts a Step Functions execution for each request, and that execution takes a slot through a semaphore in DynamoDB. As a result, a batch of requests is processed at an even rate. By default, no more than five runs execute at the same time, so that training jobs fit within the standard account quota. Completions and failures are sent to SNS, and failures reach an EventBridge rule with the original text.
SDK v3 has two non-obvious quirks for CDK applications. It checks the execution role against live IAM already when the pipeline definition is built, so a two-phase deployment is required: first the role, bucket, and ECR repository, then the pipeline itself. In addition, the validator simulates permissions to pull from ECR without specifying a resource, and a role limited to a single repository fails validation even though it would work in practice. For that reason, the example grants broader ECR access. If you deploy outside the default region, set AWS_REGION, AWS_DEFAULT_REGION, and CDK_DEFAULT_REGION directly in the command, or you will end up with partially deployed stacks.
What to take away
The system's output is versioned models per camera that have passed the thresholds: the ONNX file lives in the Model Registry, while the Neo build, along with the DLR runtime library, is stored in S3. Each factory builds its own delivery method to devices. For developers, this is a working skeleton worth copying for three decisions: the dual threshold for imbalanced data, validating the exact file that gets shipped to the device, and a queue with a semaphore in front of expensive training jobs.
- Dec 2, 2026Amazon Releases Ergo Open Weights for Coding: 1.1 Trillion Parameters and 2,200 Tokens per Second
- Dec 2, 2026Tacit, a Startup With $93.5 Million in Funding, Built Earbuds for Silent Text Input
- Dec 2, 2026Amazon to Speed Up Ergo From 400 to 2,200 Tokens per Second and Buy 2 Million More Nvidia GPUs
- Dec 2, 2026Amazon Releases Ergo: US Open Model Closes the Gap With GPT-6.1 Terra at 38 Points
Key Questions Answered
How the pipeline works for one camera?
The training part is a single 13-step SageMaker Pipeline, launched with a "camera" parameter. First, three steps run in parallel: preparing that camera's images and looking up the latest approved models for both branches. Then two models are trained. The first is a small convolutional autoencoder: it learns what a normal part looks like and flags anomalies by how poorly it can reconstruct the image. The second is a ResNet18, fine-tuned to confirm a specific defect.
Why the quality threshold is designed this way?
In factory data, about 90% of images are good parts. Plain accuracy is useless here: a model that answers "good" to everything scores about 90% and finds zero defects. Balanced accuracy, meaning the average of the detection rate for each class, is better but still misleads. A model that correctly recognizes 100% of good parts and only 20% of defective ones scores (100% + 20%) / 2 = 60%.
What are the key details on Training queue and SDK v3 pitfalls?
To keep a burst of requests from launching hundreds of trainings at once, the pipeline sits behind a queue and a semaphore. Requests land in SQS FIFO, a Lambda starts a Step Functions execution for each request, and that execution takes a slot through a semaphore in DynamoDB. As a result, a batch of requests is processed at an even rate. By default, no more than five runs execute at the same time, so that training jobs fit within the standard account quota.
Test Frontier LLMs & Autonomous Agents in One Workspace
Run Claude Opus 5.5, GPT-6, Gemini 3.1, and DeepSeek side-by-side in Nomad AI (nomadnet.ai) — unified model routing, deep research, and multimodal workflows under one subscription.
Daily 60-sec AI Voice Brief + Weekly Production AI Agent Playbook
Listen to a 60-second AI news brief every morning and get a weekly hands-on playbook for shipping AI agents to production — tools, MCP servers and patterns that work. Curated by Jemal Hamidun, Head of AI at Alpina Digital.
