From a public dataset of printed circuit boards to a detector you can deploy: import, split, train, test and export to ONNX and TensorRT in one graph.
Overview
- Model: DEIM detector (DEIMv2-S, a small real-time transformer detector), fine-tuned from a pre-trained checkpoint
- Task: Object detection (electronic components on PCB images)
- Input: Nothing of your own: the graph imports the public PCB Component Detection dataset from Dataset Ninja
- Pipeline: import -> split into train / validation / test -> train -> predict on the test part -> evaluate -> export to ONNX and TensorRT
- Output: A trained detector, an evaluation report on the held-out test part, and the model exported as an ONNX file and a TensorRT engine
When you need it
You want to see the whole path from data to a deployable model before you commit your own data to it, or you want a working starting point to point at your own dataset. The graph runs unchanged; replace the import with your own dataset and the rest stays the same. For the same chain without the import and export, see Train DEIM detector.
What you need
Nothing for the case study itself; the import step downloads the dataset. To use your own data, swap the import for a dataset you already have in OvalBee (see Import from Dataset Ninja or the other import templates). Exporting TensorRT needs a GPU on the machine that runs the export.
How it works
| Step | What happens |
|---|---|
| Import | The PCB Component Detection dataset is copied into OvalBee with its box labels |
| Split | The images are divided 70 / 15 / 15 into training, validation and test parts |
| Train | DEIMv2-S is fine-tuned for 24 epochs with a batch of 2 images; the validation part picks the best checkpoint |
| Predict | The detector runs on the test part only, keeping every box above a confidence of 0.05 |
| Evaluate | The predictions are scored against the test labels |
| Export | The trained model is written out as an ONNX file and a TensorRT engine and attached to the model in OvalBee, with the class list |
What a run gives you
One recorded run on a shared cloud GPU: the dataset has 9 component classes and was split into 987 training, 212 validation and 211 test images. Import took 91 seconds, the split 20 seconds, training 52 minutes (24 epochs, batch size 2), prediction 2 minutes 22 seconds, evaluation 51 seconds and export 3 minutes 24 seconds. Batch size 2 is what fits the shared GPUs here; an earlier attempt with larger batches ran out of GPU memory.
On the 211 test images (1,597 labeled objects) the detector scored mAP (50:95) 0.682, AP50 0.871 and AP75 0.807; at the automatically chosen confidence of 0.653, F1 was 0.701, precision 0.686 and recall 0.718. This is one run with one random split.
Per class, AP (50:95) ranges from 0.62 to 0.81 across the eight classes that have enough test objects: Transformer 0.81, MOSFET 0.79, Cap1 0.79, Mov 0.77, Cap3 0.77, Cap4 0.72, Cap2 0.72 and Resistor 0.62. Resistor is the weakest: 164 test objects, with 55 false positives and 49 misses at that confidence. The class Resestor has a single object in the test part and scored an AP of 0.13, so its figure says nothing about the model; it looks like a misspelling of Resistor in the dataset's own labels. The report's largest error source is classification: fixing only the class mix-ups would lift AP50 from 0.871 to 0.913, mostly among Resestor, Resistor and Cap4, and the boxes themselves are placed well, with a mean overlap of 0.89.
The exported ONNX file and TensorRT engine are both full precision (fp32) and are attached to the model.
When you run it yourself, pick DEIMv2-S@pre-trained as the model in the training step: the template leaves it unset.
Related templates
- Train DEIM detector - the same training chain on your own dataset, without import and export
- Detector evaluation - score any detector against a labeled set
- Import from Dataset Ninja - bring another public dataset in by its link