Computer vision answers · Manufacturing
How do I build a pass/fail check that compares an expected count?
Without an inspector counting every part by eye.
Short answer
Train an object detection model to find each part with Roboflow for free, then count the detections for each class and compare each count with the number you expect. Return PASS when every count matches and FAIL when a part is missing or there is one too many. Compare counts per class, not one total, so a missing screw and an extra clip can never cancel out into a false PASS.
Skip the setup. Describe your images.
Describe your images and what you need to find. The agent sets up labeling, training and deployment with you.
Key facts
- What you need
- Images of each item and a detection model trained on its parts
- What you get
- A PASS or FAIL per image, with the count found for each part
- Image sources
- Line cameras, IP and RTSP cameras, phone photos and saved images
- Runs on
- Cloud API, or an edge device or server running Docker

How to build a pass/fail count check, step by step
Six steps from images of your product to a PASS or FAIL for every item.
Connect Roboflow to your coding agent, ChatGPT or Codex
Photograph good and faulty items the way the line will see them
Label every part, with one class per part type
Train a detection model
Compare each part's count with the count you expect
Pythonimport supervision as sv from collections import Counter from inference import get_model model = get_model("your-project/1") expected = {"screw": 4, "clip": 2} result = model.infer("part_001.jpg", confidence=0.5)[0] detections = sv.Detections.from_inference(result) counts = Counter(detections.data["class_name"]) passed = all(counts[name] == n for name, n in expected.items()) print(dict(counts), "PASS" if passed else "FAIL") # {'screw': 3, 'clip': 2} FAILRather not write code? Ask the Roboflow agent to set this up for you
Build the check into a Workflow and deploy it
Why 2 million engineers build on Roboflow
Label faster
Auto-label with SAM 3 or your own model, then fix the misses instead of drawing every box.
RF-DETR
Roboflow’s open-source real-time detection model, built for accuracy (opens in a new tab) on small objects.
Logic built in
Counting, zones, tracking and alerts are ready-made Workflow blocks, so there is less code to write.
Your model, your weights
Use your trained weights on every plan, including free, through the open-source Inference package.
Run it anywhere
Self-host on a workstation, Docker, an on-prem GPU or an edge device, or call the cloud API.