Book a free call

Object Detection Best Practices That Hold Up in Production

Object detection holds up when training data matches the real scene and failures are watched after launch. These practices cover data, training and monitoring.

Hertiv engineering teamReviewed by a senior engineer
7 min read
Object Detection Best Practices That Hold Up in Production
On this page

Short answer

Object detection best practices start with training data that matches the cameras, lighting and objects the system will see in real use. Label a varied sample, test on scenes the model has not seen, measure misses as well as hits, and keep watching accuracy after launch, because scenes change. A small, well-tested model usually beats a large one trained on the wrong data.

What is object detection?

Object detection is the task of finding objects in an image or video frame and marking each one with a box and a label, such as "parcel", "person" or "defect". It answers two questions at once: what is in the scene, and where is it.

It differs from image classification, which labels the whole image, and from segmentation, which marks every pixel. Detection is the right tool when you need to count objects, track them, or act on their position, such as routing a parcel or flagging a hazard on a factory floor.

TaskWhat it answersExample use
ClassificationWhat is in this image?Sorting photos into categories
Object detectionWhat is here, and where?Counting parcels on a belt
SegmentationWhich pixels belong to what?Measuring a defect area
TrackingWhere did it move?Following a vehicle across frames

Most production systems pair detection with a second step, such as reading text on the detected object or checking it against a rule. For the wider field, see what computer vision is and how it works.

How should you build the training data?

You build training data for object detection by collecting images from the real cameras, in the real lighting, with the real objects the system will see. Data from stock photos or a different site teaches the model the wrong scene.

Label quality matters more than label volume. A small set of carefully drawn boxes beats a large set with sloppy boxes, because the model learns the box edges from your labels. Have a second person review a sample of labels, and write down the labelling rules: when two objects overlap, when a partial object counts, and how small an object can be before it is ignored.

Cover the hard cases on purpose. Collect images at night, in rain, with glare, with crowded scenes and with objects partly hidden. If the training set only shows clean daytime scenes, the first rainy shift will break the system.

Keep a separate test set that the model never sees during training. It should come from different days and different cameras than the training images, so it measures how the model handles new scenes rather than memorised ones.

How do you pick the right model?

You pick a detection model by balancing accuracy, speed and where it will run. A model that is accurate but too slow for the camera frame rate is useless in production, and a fast model that misses small objects is worse than no model at all.

Start from a pretrained model rather than training from scratch. Public models trained on large image sets already know edges, shapes and common objects, so fine-tuning on your own labelled data is usually faster and more accurate than starting empty.

Match the model to the hardware. A server with a graphics card can run a larger model; a camera or edge device needs a small, fast one. Test the actual speed on the actual device, not on a developer laptop, because frame rates drop sharply on weaker hardware.

Consider the object sizes in your scene. Small objects need higher input resolution or a model designed for small targets. If the objects are tiny in the frame, moving the camera closer is often cheaper than a bigger model.

How do you train and test it properly?

You train and test a detection model by splitting the data into training, validation and test sets, then measuring misses as well as hits. Accuracy alone hides the two failure modes that matter: objects the model misses, and objects it invents.

Track precision and recall separately. Precision is the share of detections that are real; recall is the share of real objects the model found. A warehouse system that misses parcels needs higher recall, while a safety system that stops a line on false alarms needs higher precision.

Test on the hard cases, not the average ones. Build a test set of crowded scenes, poor lighting, partial objects and unusual angles, and report results on that set separately from the easy cases.

Watch for overfitting. If training accuracy keeps rising while test accuracy stalls, the model is memorising the training images. More varied data helps more than more training rounds.

Example (hypothetical): a warehouse parcel check

Example (hypothetical): a warehouse uses a camera above a conveyor to count parcels and flag any that are damaged. The first version of the model is trained on 2,000 daytime images from one camera. In live use it checks 1,200 parcels a day and misses 96 of them, an 8% miss rate, mostly at night when the lighting changes.

The team adds 800 images from night shifts and from a second camera angle, relabels the boxes with a written rule for partly hidden parcels, and retrains. The miss rate falls to 2%: the model now misses 24 parcels a day instead of 96, which is 72 fewer missed parcels each day.

The team also adds a confidence rule: detections below a threshold go to a person for a quick check instead of being trusted. That catches most of the remaining misses without slowing the belt. The lesson is that the fix came from better data and a review step, not from a bigger model.

How do you run it in production?

You run object detection in production by setting a latency budget first, then designing the pipeline around it. If the camera sends 30 frames a second and the model needs 100 milliseconds per frame, you either need faster hardware or you process fewer frames.

Process only the frames you need. Many systems run detection on every third or fifth frame and track objects between detections, which cuts compute without losing much accuracy.

Plan for low-confidence detections. A detection the model is unsure about should go to a human queue or trigger a second check, not be silently accepted or silently dropped. Decide the threshold before launch and review it weekly at first.

Log every detection with its confidence and a sample of the image. Logs are what let you find failures after launch, and a week of production logs is worth more than another round of offline testing.

How do you keep accuracy from sliding?

You keep detection accuracy from sliding by watching it after launch, because scenes change. New packaging, a moved camera, a new light fitting or a seasonal product can all shift what the camera sees.

Measure accuracy on a fixed sample of production images each week. If the miss rate rises, collect the failing images, label them and retrain. This loop, sometimes called a data flywheel, is what keeps a system accurate over months rather than weeks.

Watch for new object types. A new parcel size or a new product line may need new labels. Keep a process for adding classes, and test the retrained model on the old test set as well as the new one, so fixing one problem does not break another.

Version the model and the data together. If a new version performs worse, you need to roll back to the exact model and data that worked, not guess at what changed.

What are the common mistakes?

The most common object detection mistakes are training on the wrong images, trusting a single accuracy number, and launching without a plan for failures.

  • Training on stock images. If the training images do not match the real cameras and lighting, the model fails on the first real shift.
  • Sloppy labels. Inconsistent boxes teach the model inconsistent edges. Write labelling rules and review a sample.
  • Testing on the training set. Results on images the model has seen mean nothing. Keep a held-out test set from different days and cameras.
  • Ignoring small objects. If the objects are tiny in the frame, fix the camera position or the resolution before blaming the model.
  • No low-confidence plan. Unsure detections need a human queue or a second check, not silent acceptance.
  • No monitoring after launch. Scenes drift, and accuracy slides quietly. Measure a fixed production sample every week.

If you are planning the build rather than the practices, how to implement object detection step by step covers the build sequence.

For working with a team on the system, see computer vision development.

Key takeaways

  • Training data must match the real cameras, lighting and objects the system will see
  • Label quality matters more than label volume, and the rules should be written down
  • Measure misses and false alarms separately, and test on hard cases, not average ones
  • A small, well-tested model usually beats a large one trained on the wrong data
  • Accuracy slides after launch unless a fixed production sample is measured every week

Frequently asked questions

How much training data does object detection need?

It depends on how varied the scenes are. A few hundred well-labelled images from the real cameras can be enough for a narrow task with a pretrained model, while varied scenes and many object types need thousands. Data variety matters more than raw count.

What is the difference between precision and recall?

Precision is the share of detections that are real objects. Recall is the share of real objects the model found. A system that misses parcels needs higher recall; a system that stops a line on false alarms needs higher precision.

Can object detection run on a camera instead of a server?

Yes, if the model is small and fast enough for the device. Edge devices need compact models, and you should test the actual frame rate on the actual hardware, since speed on a developer laptop does not predict speed on a camera.

How do you handle objects the model has never seen?

New object types need new labels and retraining. Keep a process for collecting failing images, labelling them and testing the retrained model on the old test set too, so fixing one problem does not break another.

Why does detection accuracy drop after launch?

Scenes change: new packaging, a moved camera, different lighting or a new product line all shift what the camera sees. A fixed weekly sample of production images shows the slide early, before it becomes a visible failure.

Do I need to train a model from scratch?

Usually not. Start from a pretrained model and fine-tune it on your own labelled data. Pretrained models already know edges, shapes and common objects, so fine-tuning is faster and usually more accurate than starting empty.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: AI and agent systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Building a vision system that has to work on real cameras? Talk to Hertiv.

A senior engineer replies within one business day. Or see our Computer Vision service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to contact@hertiv.com.

Prefer email? Write to contact@hertiv.com
Estimate costBook a call