Case 2: Plastic Discs — Dual-Pipeline Front & Back with YOLO Crop & Anomaly
Training Exercise 2 — Two front/back inspection pipelines for one plastic disc, with YOLO cropping, anomaly detection, and is_pretrained during training.
Scenario Overview
Inspect one plastic disc at a time with two pipelines, one for the front and one for the back. Each pipeline uses YOLO to locate and crop the piece before passing the cropped image to its own Anomaly Detection model:
- Front Surface Inspection: Cosmetic imperfections, laser engraving readability, scratches, and molding short shots.
- Back Surface Inspection: Ejector pin marks, cracks, molding weld lines, and perimeter flash.
- Worst-Case Decision: The overall quality verdict must aggregate both inspections: if either the front or the back is defective, the disc is rejected.
The Challenge of Variable Part Positioning
On conveyors or transfer fixtures, the disc does not always arrive in the exact same pixel coordinates:
- Running Anomaly Detection on the entire camera frame includes varying background areas (conveyor belt texture, shadows, fixture edges), leading to false positives.
- To achieve repeatable inspection, YOLO must first locate the single disc’s bounding box in each pipeline.
- A Plugin crops the original frame around the detected disc with a safety margin.
- The model inspects only the isolated disc surface.
Tips & Practical Guidance
Key Concept: The is_pretrained Setting during Acquisition:
When collecting training images for the Anomaly Detection models, the system runs in Acquisition mode. Under default settings (is_pretrained = false), an inference module skips inference to collect data for itself. If your Object Detection locator has is_pretrained = false, it will not run in Acquisition mode, producing no bounding box for your crop script. Setting is_pretrained: true forces the YOLO detector to run live inference even in Acquisition mode, allowing the crop script to supply cropped disc images to the anomaly model’s dataset.
Cropping Script Best Practices:
Retrieve the original frame and detections using Data.get(). Add a padding margin (e.g. 10–20 pixels) around bounding box coordinates, and always clamp coordinates to frame boundaries (0 to width-1, 0 to height-1) to avoid indexing errors. If no detection is found, log a warning and skip that sample rather than adding an uncropped frame to the anomaly dataset. Export the cropped sub-image using Data.export("cropped_disc", cropped_image).
Multi-Pipeline Aggregation:
BIION-D automatically aggregates compliance across all pipelines in an active Action Plan using the BAD_UNC_GOOD hierarchy: $\text{Overall} = \max(\text{Front}, \text{Back})$. A part is accepted as Compliant (0) only if both Front_Inspection and Back_Inspection return 0. If either pipeline returns Defected (2), the entire Action Plan evaluates as Defected (2).
Acceptance Criteria
Your solution will be evaluated against the following criteria:
- [ ] The Action Plan contains two distinct pipelines (
Front_InspectionandBack_Inspection) that inspect the front and back of one disc. - [ ] In both pipelines, the Object Detection module has
is_pretrained: trueenabled. - [ ] In Acquisition mode, the crop script executes correctly and only tightly cropped disc images are collected in the anomaly training datasets.
- [ ] Both front and back anomaly models train successfully on the cropped datasets.
- [ ] A disc with a front-only scratch evaluates to Front = Defected, Back = Compliant, Overall = Defected.
- [ ] A disc with a back-only scratch evaluates to Front = Compliant, Back = Defected, Overall = Defected.
- [ ] A completely defect-free disc evaluates to Front = Compliant, Back = Compliant, Overall = Compliant.