Calvingcatcher

Website Hugging Face Telegram AI-Detector Repo CowCatcherAI Repo CalvingCatcherAI Repo

Check out the website for all the information: cowcatcherai.com The website is available in multiple languages such as Deutsch, Français, Nederlands, and Español.

We built Calvingcatcher to keep an eye on the maternity pen so we don't have to walk out to the barn every hour through the night. It is a vision model that detect the visual signs of calving in cattle from ordinary barn cameras, and it forms the vision core of our CalvingCatcher system — an extra pair of eyes that watches 24/7.

We are farmers, and we trained these models on our own barn footage. Instead of predicting a single "calving" label, we detect the individual signs we would look for ourselves — the water bag, protruding legs, a head coming through. That way the system around the model can reason about how far along a cow is, not just whether something is happening.

Our latest and best model is CalvingcatcherV10.pt. It is what we run ourselves.

More about the full system: jacobsfarm.github.io/website/projects/calvingcatcher


What we detect

ID Class What it marks
1 waterbag Visible amniotic sac — the first hard evidence of active calving
2 legs Calf legs protruding
3 head Calf head visible
4 body Calf body emerging
5 calf Newborn calf on the ground

The detection head carries one further class from an earlier experiment that we no longer use in production. Ignore anything outside the five classes above.


The models

File Base Train imgsz / epochs Size Notes
CalvingcatcherV10.pt yolo26m 1024 / 150 44 MB What we recommend. Best precision and recall we have
CalvingcatcherV9.pt yolo26m 1024 / 150 44 MB Our previous main model
calvingcatcherV8.pt yolo26m 1024 / 150 44 MB An older, reliable model

All three are Ultralytics 8.4.14 yolo26m detection models.


Getting started

pip install ultralytics
from ultralytics import YOLO

model = YOLO("CalvingcatcherV10.pt")

results = model.predict("pen_frame.jpg", imgsz=1024, conf=0.40)

for r in results:
    for box in r.boxes:
        print(r.names[int(box.cls)], float(box.conf), box.xyxy.tolist())
# Live camera / RTSP stream
for result in model.predict(source="rtsp://camera/stream", stream=True, imgsz=1024, conf=0.40):
    labels = {result.names[int(b.cls)] for b in result.boxes}
    if "waterbag" in labels or "legs" in labels:
        print("Possible calving in progress:", labels)

Run V10, V9 and V8 at imgsz=1024 — that is what we trained them at. Dropping back to the 640 default costs a noticeable amount of recall on small, distant subjects.


How our models compare

The following metrics are based on a recent standardized test set of 360 images across our newer model generations.

Version Training Images Precision % Recall % Total FP
V10 18,258 94.8 54.1 8
V9 11,500 76.2 52.8 79
V8 8,700 84.7 47.8 33
V7 6,900 78.2 35.6 49

V10 comes out significantly ahead on both precision and recall. Thanks to a much larger training set (over 18,000 images), our recall has climbed to 54.1%, and precision reached an impressive 94.8% with drastically reduced false positives (only 8 in our test set).

How to read those numbers

The recall looks low next to a typical single-class detector, and we want to be upfront about why. This is a hard problem: the things we look for are small, often partly hidden by the cow herself, and some of them — a water bag, a pair of legs — are only visible from certain angles and for a limited window. Every individual object in every individual frame counts against recall.

In daily use we don't need to catch every object in every frame. The camera watches the pen continuously, and one confident detection is enough to start recording. A calving lasts long enough that ~50% per-frame recall still catches the event reliably. What matters far more to us is precision — we don't want to be woken for nothing.

If you run these weights standalone, the confidence threshold is your main dial: raise it to cut false alarms, lower it to catch earlier and weaker signs.


How we use them

  1. An IP camera streams the maternity pen over RTSP.
  2. The model analyses a frame every few seconds.
  3. On a reliable detection we start collecting frames and record several seconds of footage, so we have enough material to pick good imagery from.
  4. The clearest images go straight to our phones through Telegram or Home Assistant, with the confidence score, so we can judge the situation before pulling on our boots.

Everything runs locally on the farm. No footage leaves the premises.

What you need to run it

  • A consumer-grade PC, preferably with an NVIDIA GPU (GTX 1000-series or newer)
  • One or more IP/WiFi cameras reachable over RTSP
  • A PoE switch to power the wired cameras
  • LAN cabling for a stable connection
  • An internet connection to send the alerts

What it won't do

  • It will occasionally raise a false alarm. Precision is very good now, but not perfect.
  • It does not read ear tags. It tells you something is happening in the pen, not which animal it is.
  • It does not replace walking the barn. We treat it as a monitoring aid; physical checks stay essential and a stockman's judgement is still indispensable.
  • Detection quality depends on camera placement, lighting and how much of the cow you can see. Heavy occlusion, awkward angles and very distant views are the hard cases.
  • The machine has to stay powered and online, or no alert arrives.
  • We trained on our own barns only — there is no imagery from other farms in here. Good for privacy, but a barn that looks very different from ours may need extra data.

License

AGPL-3.0.

We train these weights with Ultralytics, which is licensed under AGPL-3.0. Every checkpoint here carries the Ultralytics AGPL-3.0 notice in its metadata, so the derived weights inherit that license.

In practice: if you use these models in a network-accessible service, AGPL-3.0 requires you to make the corresponding source of that service available to its users. If that doesn't work for your deployment, Ultralytics sells a commercial Enterprise License that removes the copyleft obligation — see ultralytics.com/license.


See also: Cowcatcher — our sibling model family that detects mounting behaviour for heat detection.

Downloads last month
157
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support