PCB Component Classifier

A Random Forest over 33 hand-engineered computer-vision features that classifies discrete electronic components β€” resistors, capacitors, diodes, inductors, transistors and ICs β€” from a single image, and can explain why it reached each decision.

No GPU, no pretrained backbone, ~50 ms per image on a laptop CPU.

Part of the PCB Inspection Suite. Trained on ParsaVictor/pcb-component-classifier. Full pipeline, feature extraction code, and the explanation renderer: GitHub: pcb-component-classifier.

Results

Trained on 1,195 labelled images across 6 classes. Evaluated on a stratified 25% test split, and on a 120-image holdout set never used in training or tuning.

Evaluation Accuracy
Test split (299 samples) 92.98%
Holdout set (120 images) 93.33% (112/120)

Per-class performance (test split)

Class Precision Recall F1 Support
Resistors 0.93 1.00 0.96 154
Transistors 1.00 0.90 0.95 21
ICs 0.97 0.88 0.92 32
Capacitors 0.90 0.92 0.91 59
Inductors 0.88 0.78 0.82 18
Diodes 1.00 0.60 0.75 15
Weighted avg 0.93 0.93 0.93 299

Diodes are the honest weak spot β€” perfect precision but 0.60 recall on only 15 test samples (visually close to small capacitors, under-represented class).

Confidence as a review gate

Threshold Accepted Accuracy on accepted Flagged for review Errors caught
none 100% 93.3% 0 0 / 8
0.50 88% 98.1% 14 6 / 8
0.60 79% 98.9% 25 7 / 8
0.70 66% 98.7% 41 7 / 8

Accepting only predictions above 0.60 confidence leaves 98.9% accuracy on the 79% it handles automatically, and routes 7 of the 8 errors into the fifth it hands to a human.

Usage

import joblib
from huggingface_hub import hf_hub_download

weights = hf_hub_download("ParsaVictor/pcb-component-classifier", "tree_rf.joblib")
clf = joblib.load(weights)

# Requires the 33-feature extractor from the GitHub repo (src/pcb_classifier/features.py)
# pred = clf.predict([features])

See the GitHub repo for the full feature-extraction pipeline and the six-panel decision-path explanation renderer.

Files

  • tree_rf.joblib β€” trained on isolated component photos (this dataset, 93.3% holdout accuracy)
  • feature_importance.csv β€” the 33 features ranked by importance

Related

License

MIT.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Dataset used to train ParsaVictor/pcb-component-classifier

Collection including ParsaVictor/pcb-component-classifier