Build with RF-DETR

Build a Foreign Object Detection App Free with RF-DETR

Catch contaminants and debris that don't belong, in food, on production lines, or on runways. Label images, train RF-DETR free, and deploy it as a workflow.

  • No credit card
  • No ML team required
  • Edge, on-prem or API
RF-DETRLive inference
Computer vision system detecting a blue plastic foreign object among chopped lettuce on a conveyor belt.
Representative result. Detect foreign objects in food.

Build a Foreign Object Detection App with Roboflow’s Free RF-DETR

In short

A foreign object detection app uses computer vision to find things that do not belong, like plastic, hair, or paper in food, loose bolts and tools on a production line, or debris on a runway, and flags them before they cause harm; the template is trained on food contamination. When you know what the foreign objects look like, train RF-DETR (opens in a new tab), Roboflow's open-source real-time detection model, on labeled examples; to flag anything unusual, including objects you have never seen, Roboflow also trains PatchCore and FoundAD anomaly detection models (opens in a new tab) on clean images only. With Roboflow you label your images, train RF-DETR for free, and deploy it as a workflow that returns an annotated image, a count of foreign objects, and a PASS or FAIL result.

How it works

The workflow behind the foreign object detection app

Use this Foreign Object Detection with RF-DETR workflow: each image goes to an RF-DETR model that finds contaminants in the food, then through a confidence filter and into two tracks. One counts the foreign objects 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.

Foreign Object Detection with RF-DETR
Returns
  • output_image
  • inspection_result
  • foreign_object_count
  • predictions

How to build a foreign object detection app with RF-DETR

  1. Open the workflow and add your images

    Click "Use this free template" to copy the workflow into your Roboflow workspace. Upload images of your scene taken with the camera and lighting you will use, including clean examples and each foreign object you need to catch. The template is trained on food contamination; for loose parts on a conveyor, tools left at a workstation, or runway debris, upload those images and train on them. No images yet? Start from a public foreign object dataset on Roboflow Universe (opens in a new tab).

  2. Label contaminants and train RF-DETR

    If you know what the foreign objects look like, use Auto Label (opens in a new tab) to box each one, review and correct the results, paying close attention to small or low-contrast items, and train an RF-DETR model to select in the detect_foreign_objects block; it fine-tunes well on small custom datasets. To catch anything unusual, including objects you have never seen, mark clean images as Normal and train a PatchCore or FoundAD anomaly detection model, which highlights where an image looks different.

  3. Tune the threshold and the pass/fail rule

    Set the threshold in filter_by_confidence so real foreign objects are caught without flagging normal texture, and add classes for specific contaminants if you need a separate count for each. For small objects in wide, high-resolution views, add an Image Slicer (opens in a new tab) block before detect_foreign_objects and a Detections Stitch (opens in a new tab) block after it. For live video, add a ByteTrack (opens in a new tab) block and alert only when the same object is tracked across several frames, which cuts one-frame false alarms.

  4. Test it in your real environment

    Test on new images from your own line or site, not the ones you trained on, and measure missed objects and false alarms separately. Let operators mark each result as correct or incorrect, and add the corrected images back to your Roboflow dataset to retrain.

  5. Deploy and connect it to your line

    Deploy the workflow as a Serverless Cloud API (opens in a new tab), or on your own edge hardware through Inference (opens in a new tab), or run RF-DETR on the iPhone with the Roboflow iOS SDK (opens in a new tab). Add an Email Notification (opens in a new tab) or Webhook Sink (opens in a new tab) block to alert your team or reject system when something is found, and log each detection with the Vision Events (opens in a new tab) block for a history you can search later.

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 foreign object detection app in natural language, without leaving your editor.

Ask an assistant like Codex or ChatGPT to search Roboflow Universe for food contamination datasets, upload and auto-label your line images, and train an RF-DETR model to find foreign objects. It can then create and run the foreign object detection 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.

Add to Claude (opens in a new tab)

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.

Add to Cursor (opens in a new tab)

Opens the Roboflow plugin listing. Sign in if prompted and confirm the install on Cursor to add MCP and skills.

Add to ChatGPT (opens in a new tab)

Opens the Roboflow plugin listing. Install the plugin and sign in to Roboflow when prompted to connect your account.

Add to Codex (opens in a new tab)

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 foreign object detection app can do

Trained on your images, an RF-DETR model handles the specific, hard-to-catch cases that matter on your line:

  • Spot small fragments of plastic, paper, or packaging in food
  • Find hair and thin fibers that blend into the product
  • Catch contaminants that are similar in color to the food
  • Flag anything that doesn't belong, even objects you have never labeled
  • Find small debris in wide, high-resolution views
  • Tell foreign objects apart from normal food texture and crumbs
  • Inspect every item at line speed, not a sample
  • Flag contaminated product before it is packed and shipped
Roboflow agent · free to start

Want to customize your foreign object detection app?

Describe the foreign object detection app you want in plain English: your product, the contaminants you need to catch, and what should happen when one is found. 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.

RF-DETR licence by model size
ModelsLicence
Detection: Nano, Small, Medium, LargeApache-2.0
Segmentation: every size, Nano to 2XLargeApache-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 foreign object detection app has to find small, unpredictable contaminants in food on a moving line, often close in color to the product, so the model needs to be both accurate and fast. Here is how RF-DETR, fine-tuned on your own product images, compares for real-time inspection.

RF-DETR vs. other free detectors
ModelTasksBest forLicense
RF-DETRDetection, segmentation (keypoints in preview)Real-time detection you fine-tune on your own data, one model across tasksApache-2.0 (Nano to Large, all segmentation); PML 1.0 (Atto, Femto, Pico, XL, 2XL)
D-FINEDetectionPrecision localization when you do not need to fine-tuneApache-2.0
YOLODetection, segmentation, poseFast CNN-based detection with a large ecosystemAGPL-3.0 (commercial license required for closed-source use)
GroundingDINOOpen-vocabulary detectionFinding objects by text prompt with no training, not real-timeApache-2.0
SAM 2 / SAM 3SegmentationPixel-precise masks; SAM 3 adds text-prompted segmentationApache-2.0 (SAM 2), SAM License (SAM 3)
Florence-2Vision-languageReading, captioning, and OCR on imagesMIT

The takeaway for this app: RF-DETR runs in real time, so it can inspect every item as it passes. It fine-tunes well on small custom datasets and is open source, so you can train on your own products and contaminants and run the model wherever you need it.

Build your foreign object detection app free today

Label, train, and deploy your foreign object detection app in one place.