tensorturnBETA
HomeUse Cases

How to Build a Defect Detection Model Without Code

TensorTurn builds a visual defect detection model from your own inspection images with no code. You choose the framing — classify each part as good vs defective (a CNN with transfer learning) or locate and box each defect (Ultralytics YOLO) — upload the images, describe the task in chat, and it trains on an isolated cloud GPU, self-heals errors, and deploys a /predict API. Because defects are usually rare, the model is judged on catching them (recall on the defect class), not on raw accuracy, and cleaning mislabeled or duplicate images first is what actually moves the numbers.

Two ways to frame defect detection

Decide what output you need before you label anything. If you only need a pass/fail verdict per part, treat it as image classification: good vs defective (or one class per defect type), trained as a CNN with transfer learning in PyTorch or Keras. If you need to know where the defect is — to locate a scratch, count pinholes, or measure a flaw — treat it as object detection with Ultralytics YOLO, which draws a box around each defect. Classification is simpler and needs less labeling; detection tells you location and count.

What data you need

Rare defects and imbalance (the core challenge)

The defining difficulty of defect detection is imbalance: good parts vastly outnumber defective ones, so a model that calls everything 'good' can look 98% accurate and catch zero defects. That is why accuracy is the wrong headline metric — judge the model on recall for the defect class (the share of real defects you catch) while tracking precision (how many flagged parts are truly defective) so quality control is not buried in false alarms. Ask the chat to use class weighting or augmentation to give rare defects more influence, and set the threshold to match the cost of a missed defect versus a false reject. Be realistic about the ceiling: obvious, high-contrast defects with a few hundred examples can reach 90%+ recall, while subtle or rare defects land lower and need you to keep collecting hard examples over time.

Clean the images before you train

TensorTurn's automated image health check finds exact and near-duplicate images with perceptual hashing, blurry and over/under-exposed shots, corrupt files and odd resolutions, and runs a DINOv2 semantic pass for near-duplicates, train/test leakage and likely-mislabeled images, suggesting a corrected label with a confidence score. This matters doubly for defect data: a handful of mislabeled 'good' parts that are actually defective, or the same part leaking into train and test, will quietly wreck a model whose whole job is catching the rare case.

How to build a defect detection model with TensorTurn (no code)

Two framings at a glance

FramingGood vs defective (classification)Locate defects (detection)
ModelCNN + transfer learning (PyTorch/Keras)Ultralytics YOLO
LabelsImages in good / defective foldersBounding boxes (YOLO/COCO/VOC)
Key metricRecall & precision on the defect classmAP50 and per-class recall
Tells youPass or fail per partWhere each defect is, and how many
Deploy/predict returns a class + confidence/predict returns boxes + classes

Deploy on the line, or on your own GPU

Publish an authenticated /predict endpoint on Modal that scales to zero when idle, secured with a SHA-256-hashed Bearer key and per-call logging, and call it from your inspection station with the provided cURL, JavaScript, Python and Rust snippets. If you would rather keep images inside the factory, connect your own GPU with a single outbound-HTTPS-only command that works behind any firewall, and even pool several of your own machines into one training run.

Start building free

Frequently asked questions

Should defect detection be classification or object detection?

Use classification for a simple pass/fail per part; use object detection (YOLO) when you need to locate, count or measure each defect. Classification needs less labeling; detection gives you position and count.

What data do I need for a defect detection model?

Consistent inspection images covering good parts and each defect type — sorted into folders for pass/fail, or box-annotated for localisation. Gather as many real defective images as possible, since defects are the rare, important class.

Why is my model 98% accurate but missing defects?

Because good parts outnumber defects, so accuracy is misleading. Judge the model on recall for the defect class and the confusion matrix, and use class weighting or a tuned threshold to catch more real defects.

How does TensorTurn help with mislabeled or duplicate images?

The image health check flags exact and near-duplicates, train/test leakage and likely-mislabeled images via a DINOv2 pass, with suggested corrections — critical when a few wrong labels can hide the rare defect case.

Can I run defect detection on my own hardware?

Yes. Connect your own GPU with a one-line, outbound-HTTPS-only agent that works behind any firewall, keep images on-site, and optionally pool several of your own machines into one run.

Can I deploy the defect model to the production line?

Yes. Publish a /predict endpoint that returns a class and confidence (or boxes for detection) and call it from your inspection station with the provided snippets. It scales to zero when idle.