Build with RF-DETR
Build a Surface Defect Detection App Free with RF-DETR
Find scratches, dents, corrosion, and stains on metal, plastic, or painted surfaces. Label images, train RF-DETR free, and deploy it as a workflow.
- No credit card
- No ML team required
- Edge, on-prem or API

Build a Surface Defect Detection App with Roboflow’s Free RF-DETR
In short
A surface defect detection app uses computer vision to find flaws such as scratches, dents, corrosion, stains, and pitting on metal, painted, plastic, or fabric surfaces, then decides whether each surface passes inspection; the template is trained on steel defects like crazing, inclusions, and rolled-in scale. The model to train for it is RF-DETR (opens in a new tab), Roboflow's open-source real-time detection model, for boxes around known defects, or RF-DETR Seg for pixel-level outlines; if you mostly have images of good surfaces, Roboflow also trains PatchCore and FoundAD anomaly detection models (opens in a new tab) that return an anomaly score and a heatmap of unusual regions. With Roboflow you label your images, train RF-DETR for free, and deploy it as a workflow that returns an annotated image, a defect count, and a PASS or FAIL result.
How it works
The workflow behind the surface defect detection app
Use this Surface Defect Detection with RF-DETR workflow: each image goes to an RF-DETR model and a per-class confidence filter, then splits into two tracks. One counts the defects and turns the count into PASS or FAIL, the other draws boxes and labels, and both meet where the verdict is written onto the image. Every block is editable in the low-code builder, and the Roboflow Agent can build it from a description.
- output_image
- inspection_result
- defect_count
- predictions
How to build a surface defect detection app with RF-DETR
Open the workflow and add your images
Click "Use this free template" to copy the workflow into your Roboflow workspace. Upload images of your surfaces taken with the camera and lighting on your line, including clean surfaces with normal variation and defective ones. The template is trained on steel; for painted, plastic, glass, or other surfaces, upload those images and train on them. No images yet? Start from a public surface defect dataset on Roboflow Universe (opens in a new tab).
Label surface defects and train RF-DETR
Use Auto Label (opens in a new tab) to draw boxes for the defect types you see, such as scratches, inclusions, and rolled-in scale, review and correct them, and train an RF-DETR model to select in the detect_surface_defects block; it fine-tunes well on small custom datasets. For pixel-level outlines of crazing or irregular scratches, label polygons and train RF-DETR Seg instead. If you mostly have images of good surfaces, mark them Normal and train a PatchCore or FoundAD anomaly detection model, which returns an anomaly score and a heatmap of where a surface looks different.
Crop, set thresholds, and add severity rules
Add an Absolute Static Crop (opens in a new tab) block before detect_surface_defects so the model only looks at the surface, not the conveyor or fixtures around it. Set the thresholds in filter_by_confidence based on which costs more on your line, a missed defect or a good sheet rejected, and for an anomaly model pick the anomaly-score threshold on held-out images, since the score is not a probability. Then set severity rules in pass_fail_result, for example pass light patches, send small scratches to NEEDS REVIEW for an inspector, and fail any inclusion or pitting.
Test it before you rely on it
Test the model on images it has not seen, keeping all photos of the same sheet or part in one split so results are not inflated, and check your thresholds on a test set you did not use to choose them. Use Roboflow's model evaluation (opens in a new tab) to check missed defects and false rejections separately, measure end-to-end inspection time on the hardware you will use, then pilot with an inspector reviewing every result before you let the app reject parts on its own.
Deploy, review, and retrain
Deploy the workflow as a Serverless Cloud API (opens in a new tab), or on your own hardware such as an NVIDIA Jetson through Inference (opens in a new tab); PatchCore and FoundAD anomaly models deploy the same way and can run on image slices to catch small defects on large surfaces. Each run returns output_image, inspection_result, defect_count, and predictions; save them with the inspector's final decision and the model version as your inspection history, and add corrected images back to your Roboflow dataset to retrain.
Roboflow MCP
Build it from your AI assistant with the Roboflow MCP
Connect the Roboflow MCP Server to Claude, Cursor, or any MCP-compatible assistant and build the whole surface defect detection app in natural language, without leaving your editor.
Ask an assistant like Codex or ChatGPT to search Roboflow Universe for steel surface defect datasets, upload and auto-label your images, and train an RF-DETR model on crazing, inclusion, patches, scratches, pitted surface, and rolled-in scale. It can then create and run the workflow on test images and deploy it to your devices.
Paste it into your coding agent and it walks you through the rest. Setting up by hand? The server is https://mcp.roboflow.com/mcp.
Open the Roboflow listing, select Connect, then sign in to Roboflow. Available on desktop, web and mobile.
Run these commands in your terminal, then sign in to Roboflow. Claude Code CLI has no documented browser install link.
Opens the Roboflow plugin listing. Sign in if prompted and confirm the install on Cursor to add MCP and skills.
Opens the Roboflow plugin listing. Install the plugin and sign in to Roboflow when prompted to connect your account.
Opens the Roboflow plugin listing shared by ChatGPT and Codex. Install the plugin and sign in to Roboflow when prompted to connect your account.
Then run /mcp auth roboflow in Gemini CLI to sign in. Gemini CLI has no documented browser install link.
What your surface defect detection app can do
Trained on your images, an RF-DETR model handles the specific, hard-to-catch cases that matter on your line:
- Tell rolled-in scale apart from patches and normal surface texture
- Find fine crazing and hairline scratches on brushed or reflective steel
- Outline irregular defects like crazing and scratches at pixel level
- Spot small inclusions and pitting that are easy to miss by eye
- Flag unusual regions on a heatmap before you have labeled examples of a defect
- Catch several defect types on the same surface in one pass
- Keep detecting defects as lighting and surface finish vary
- Inspect every sheet or strip at line speed
Want to customize your surface defect detection app?
Describe the surface defect detection app you want in plain English: the material, the defects, and what counts as a fail. The Roboflow Agent finds the data, trains an RF-DETR model, and assembles the workflow for you.
Open source
Roboflow’s RF-DETR is open source, Apache-2.0, and free to use
RF-DETR is an open-source, Apache-2.0 licensed real-time object detection model developed by Roboflow. The rfdetr Python package and most RF-DETR models are free to use, including in commercial products, and you can train and run everything on your own hardware. No account or lock-in required.
Apache-2.0 and free
The rfdetr package, Nano to Large detection, every segmentation size and Keypoint are Apache-2.0 licensed and free to use, including commercially.
Install and train locally
pip install rfdetr on Python 3.10+. Fine-tune on your own data in a few lines and run it entirely on your machine.
State of the art on COCO
RF-DETR is a real-time detector that is SOTA on COCO. RF-DETR-Large reaches 56.5 AP at 6.8 ms on an NVIDIA T4, and uses a DINOv2 backbone.
Deploy anywhere
Export to ONNX or TensorRT and run on GPU, CPU, or NVIDIA Jetson at the edge, or serve it through the Roboflow hosted API.
| Models | Licence |
|---|---|
| Detection: Nano, Small, Medium, Large | Apache-2.0 |
| Segmentation: every size, Nano to 2XLarge | Apache-2.0 |
| Keypoint (preview) | Apache-2.0 |
| Detection: Atto, Femto, Pico, XL, 2XL (rfdetr[plus]) | PML 1.0: commercial use included on Roboflow; commercial self-hosting needs the Enterprise add-on |
RF-DETR vs. other free detectors
A surface defect detection app has to find small, low-contrast flaws on every sheet or part as it passes, so the model needs to be both accurate and fast. Here is how RF-DETR, fine-tuned on your own surface images, compares for real-time inspection.
| Model | Tasks | Best for | License |
|---|---|---|---|
| RF-DETR | Detection, segmentation (keypoints in preview) | Real-time detection you fine-tune on your own data, one model across tasks | Apache-2.0 (Nano to Large, all segmentation); PML 1.0 (Atto, Femto, Pico, XL, 2XL) |
| D-FINE | Detection | Precision localization when you do not need to fine-tune | Apache-2.0 |
| YOLO | Detection, segmentation, pose | Fast CNN-based detection with a large ecosystem | AGPL-3.0 (commercial license required for closed-source use) |
| GroundingDINO | Open-vocabulary detection | Finding objects by text prompt with no training, not real-time | Apache-2.0 |
| SAM 2 / SAM 3 | Segmentation | Pixel-precise masks; SAM 3 adds text-prompted segmentation | Apache-2.0 (SAM 2), SAM License (SAM 3) |
| Florence-2 | Vision-language | Reading, captioning, and OCR on images | MIT |
The takeaway for this app: RF-DETR runs in real time, so it keeps up with steel moving down a line. It fine-tunes well on small custom datasets and is open source, so you can train on your own surface images and run the model wherever you need it.
Build your surface defect detection app free today
Label, train, and deploy your surface defect detection app in one place.