Object Detection
ultralytics
yolo
agriculture
livestock
cattle
calving
animal-welfare
computer-vision
Run this model with HF Jobs
Run CowcatcherAI/Calvingcatcher on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/CowcatcherAI/Calvingcatcher. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/CowcatcherAI/Calvingcatcher on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use CowcatcherAI/Calvingcatcher with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ultralytics
How to use CowcatcherAI/Calvingcatcher with ultralytics:
from huggingface_hub import hf_hub_download from ultralytics import YOLO # pick the weights file from this repo's "Files and versions" tab weights = hf_hub_download("CowcatcherAI/Calvingcatcher", "<weights>.pt") model = YOLO(weights) source = 'http://images.cocodataset.org/val2017/000000039769.jpg' model.predict(source=source, save=True) - Notebooks
- Google Colab
- Kaggle
Upload README.md
Browse files123---license: lgpl-3.0---123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186---license: agpl-3.0library_name: ultralyticspipeline_tag: object-detectiontags:- yolo- ultralytics- object-detection- agriculture- livestock- cattle- calving- animal-welfare- computer-vision---# CalvingcatcherCalvingcatcher is a family of YOLO models that detect the visual signs of **calving** in cattle frombarn camera images. It is the vision core of the CalvingCatcher system β an extra pair of eyes on thematernity pen that watches 24/7, so a farmer does not have to walk out to the barn every hour throughthe night.The models are trained by farmers on real barn footage. Rather than predicting a single "calving"label, they detect the individual indicators a farmer would look for β the water bag, protruding legs,a head, a raised tail β which lets the surrounding system reason about *how far along* a cow is insteadof only whether something is happening.**Latest and best model: `CalvingcatcherV9.pt`.**More about the full system: [jacobsfarm.github.io/website/projects/calvingcatcher](https://jacobsfarm.github.io/website/projects/calvingcatcher/)---## Detected classesAll models are 6-class Ultralytics YOLO detection models:| ID | Class | What it marks ||---|---|---|| 0 | `tail_up` | Raised tail β an early behavioural sign || 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 |---## Available models| File | Base | Train imgsz / epochs | Size | Notes ||---|---|---|---|---|| **`CalvingcatcherV9.pt`** | `yolo26m` | 1024 / 150 | 44 MB | **Recommended.** Best precision and recall of the series || `calvingcatcherV8.pt` | `yolo26m` | 1024 / 150 | 44 MB | Previous main model || `CalvingcatcherV7.pt` | `yolo26m` | 960 / 150 | 44 MB | Older 960 px generation, fewer false positives than V8 |All three are Ultralytics 8.4.14 `yolo26m` detection models. Earlier versions (V5, V5.1, V6, V7.1) andthe small/large variants appear in the benchmark below for context but are not published here.---## Quick start```bashpip install ultralytics``````pythonfrom ultralytics import YOLOmodel = YOLO("CalvingcatcherV9.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())``````python# Live camera / RTSP streamfor 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 V9 and V8 at **`imgsz=1024`** and V7 at **`imgsz=960`** β these are the resolutions they weretrained at, and dropping to the 640 default costs a noticeable amount of recall on small, distantsubjects.---## BenchmarkPrecision, recall and total false positives across the model series. `M`/`S`/`L` are the Ultralyticssize variants, the number is the training resolution.| Version | Model | Precision % | Recall % | Total FP ||---|---|---|---|---|| **V9** | **M1024 (epoch 76)** | **85.9** | **49.6** | 237 || V8 | M1024 | 82.3 | 44.7 | 305 || V8 | S1024 | 84.4 | 38.2 | 177 || V7.1 | L640 | 74.6 | 35.1 | 412 || V7 | M960 | 84.1 | 41.4 | 208 || V6 | M960 | 80.4 | 35.0 | 220 || V5.1 | M960 | 76.3 | 26.7 | 234 || V5 | M960 | 77.7 | 17.3 | 77 |V9 is the best model on both precision and recall. Recall has roughly tripled since V5 (17.3% β 49.6%)while precision has climbed as well.### Reading these numbersThe recall figures look low next to a typical single-class detector, and that is expected here. This isa hard six-class problem: the targets are small, often partly occluded by the cow herself, and severalof 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 practice the system does not need to catch every object in every frame. The camera analyses the pencontinuously, and one confident detection is enough to start collecting footage. A calving lasts longenough that ~50% per-frame recall still means the event itself is caught reliably; what matters far morefor daily use is precision, so the farmer is not woken by false alarms.If you use these weights standalone, treat the confidence threshold as your main dial: raise it to cutfalse positives, lower it to catch earlier and weaker signs.---## How the full system uses these modelsThe published system around these weights works roughly as follows:1. An IP camera streams the maternity pen over RTSP.2. The model analyses a frame every few seconds.3. On a reliable detection, the system starts collecting frames and records several seconds of footage,so it has enough material to pick good imagery from.4. The clearest images are pushed to the farmer's phone through **Telegram** or **Home Assistant**,together with the confidence score, so the farmer can judge the situation before walking out.Everything runs locally on the farm β no footage leaves the premises.### Hardware- 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 for sending the alerts---## Limitations- **The AI can raise a false alarm.** Precision is high but not perfect; expect the occasionalunnecessary notification.- **It does not read ear tags.** The system tells you *something is happening in the pen*, not whichanimal it is.- **Physical checks remain essential.** This is a monitoring aid, not a replacement for a stockman'sjudgement. Human expertise stays indispensable.- Detection quality depends on camera placement, lighting and how much of the cow is visible; heavyocclusion, unusual angles and very distant views are the hard cases.- The machine running it must stay powered and online for alerts to arrive.- The models were trained on the maintainers' own barn footage and contain no imagery from other farms,which is good for privacy but means barns that look very different may need additional data.---## License**AGPL-3.0.**These weights are trained with [Ultralytics](https://github.com/ultralytics/ultralytics), which islicensed under AGPL-3.0. Every checkpoint in this repository carries the Ultralytics AGPL-3.0 notice inits metadata, so the derived weights inherit that license.In practice this means that if you use these models in a network-accessible service, AGPL-3.0 requiresyou to make the corresponding source of that service available to its users. If that does not work foryour deployment, Ultralytics sells a commercial Enterprise License that removes the copyleft obligation βsee [ultralytics.com/license](https://www.ultralytics.com/license).---See also: [**Cowcatcher**](https://huggingface.co/CowcatcherAI/Cowcatcher) β the sibling model family thatdetects mounting behaviour for heat detection.
README.md+184-1