Defect Detection Where Nine Examples Is the Whole Class
A manufacturer runs six assembly lines with fixed cameras. Over 14 months the team labeled 2,600 images: 2,410 OK and 190 defective, across five defect types. Two types account for 168 of the images; one type has 12 examples, one has 9, one has 1. Inspection runs at one frame per second per camera, and the line PLC must reject a part within 150 ms, so inference has to run on-premise on the industrial PC. A cloud region round trip measured 300 ms. The data science team proposes training a custom CNN in OCI Data Science, exporting it, and serving it at the edge. Procurement asks why not simply use OCI Vision custom image classification.
1. Resolve the build-versus-buy question on its actual deciding constraint.
Read the worked answer
The deciding constraint is latency and location, not model quality.
OCI Vision custom image classification is managed, quick to start, and would probably learn the two well-represented defect types faster than anything hand-built. But inference runs in the OCI region: a 300 ms round trip per frame, times six cameras at one frame per second, breaches the 150 ms PLC budget and scales network dependency into the production line. OCI Vision does not hand you an exportable artifact to run on the industrial PC, so the edge requirement is disqualifying for the real-time loop.
A custom model in OCI Data Science fits: train there, export to ONNX, run on the line's industrial PC, no network in the control path. You are buying latency isolation at the price of owning the MLOps.
Do not throw away the managed option. Use OCI Vision in batch over archived images as a benchmark and second opinion, and as a quick way to establish how far a pretrained model gets before committing engineering time to a bespoke pipeline.
2. With 190 defects and one class containing a single example, which modeling approach and which metric?
Read the worked answer
Metric first. 2,410 of 2,600 images are OK, so a model that always says OK scores 92.7% accuracy and catches nothing. Report recall at a fixed false-reject budget - for example at least 95% recall at no more than 2% false rejects - broken down per defect type, because aggregate recall will be dominated by the two large classes.
Supervised where data supports it. Transfer learning from a pretrained backbone, aggressive augmentation, class weighting. The two large defect types are trainable.
Unsupervised where it does not. Nine and twelve examples cannot define a class, and one certainly cannot. Treat the rare and single-example types as novelty: train a one-class or anomaly model on OK images so an unfamiliar appearance is flagged as 'unlike anything seen', and let a human classify what it is. That is a different model and a different output than a five-way classifier, and it is the honest representation of what the data supports.
Data plan. Target roughly 50 labeled examples per class before claiming detection of that class, and get them by having inspectors save and label rejected parts rather than by mining the archive.
3. Design the rollout and the operating model after go-live, given that the edge device sits outside OCI.
Read the worked answer
Rollout. Shadow mode on one line for two weeks: the model scores every frame, writes predictions, and changes nothing, while inspectors record their own verdicts. Compare before enabling auto-reject. Then enable on that line, keep a human review queue for flagged parts, and expand line by line.
Drift is the main long-run risk. Lighting changes, lens cleaning schedules, new suppliers, and seasonal part finishes all shift the input distribution with no error message. Monitor input statistics and per-camera reject rates with alarms on step changes; a sudden drop in rejects is as suspicious as a spike.
Retraining and versioning. OCI Data Science jobs and ML pipelines for scheduled retraining, the model catalog for versioning, and a defined artifact distribution process to the industrial PCs - the deployment endpoint inside OCI is not the serving path, so version control and rollback live on the edge and must be rehearsed. Keep the previous artifact installed and switchable in one step.
Labels keep coming. The human review queue is the labeling pipeline; without it the model freezes at whatever the 14-month dataset captured. Define in advance which reject-rate or recall degradation triggers a retrain, rather than waiting for quality complaints.