Object Detection
ultralytics
yolo
agriculture
livestock
cattle
calving
animal-welfare
computer-vision
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
|
Download README.md from CowcatcherAI/Calvingcatcher: direct link, hf CLI and curl.
- Browser
- Download file 8.18 kB
-
https://huggingface.co/CowcatcherAI/Calvingcatcher/resolve/main/README.md
- Command line
-
hf download hf://CowcatcherAI/Calvingcatcher/README.md
-
curl -L -o README.md https://huggingface.co/CowcatcherAI/Calvingcatcher/resolve/main/README.md
8.18 kB
| license: agpl-3.0 | |
| library_name: ultralytics | |
| pipeline_tag: object-detection | |
| tags: | |
| - yolo | |
| - ultralytics | |
| - object-detection | |
| - agriculture | |
| - livestock | |
| - cattle | |
| - calving | |
| - animal-welfare | |
| - computer-vision | |
| # Calvingcatcher | |
| <p align="left"> | |
| <a href="https://jacobsfarm.github.io/website/"><img src="https://img.shields.io/badge/Website-cowcatcherai.com-blue?logo=googlechrome&logoColor=white" alt="Website"></a> | |
| <a href="https://huggingface.co/spaces/CowcatcherAI/CowCatcherAI"><img src="https://img.shields.io/badge/🤗%20Hugging%20Face-Spaces-yellow" alt="Hugging Face"></a> | |
| <a href="https://t.me/+SphG4deaWVNkYTQ8"><img src="https://img.shields.io/badge/Telegram-Join%20Chat-2CA5E0?logo=telegram&logoColor=white" alt="Telegram"></a> | |
| <a href="https://github.com/eschouten/ai-detector"><img src="https://img.shields.io/badge/GitHub-AI--Detector-181717?logo=github&logoColor=white" alt="AI-Detector Repo"></a> | |
| <a href="https://github.com/CowCatcherAI/CowCatcherAI"><img src="https://img.shields.io/badge/GitHub-CowCatcherAI-181717?logo=github&logoColor=white" alt="CowCatcherAI Repo"></a> | |
| <a href="https://github.com/CowCatcherAI/CalvingCatcherAI"><img src="https://img.shields.io/badge/GitHub-CalvingCatcherAI-181717?logo=github&logoColor=white" alt="CalvingCatcherAI Repo"></a> | |
| </p> | |
| ### | |
| Check out the website for all the information: [cowcatcherai.com](https://jacobsfarm.github.io/website/) | |
| **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](https://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 | |
| ```bash | |
| pip install ultralytics | |
| ``` | |
| ```python | |
| 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()) | |
| ``` | |
| ```python | |
| # 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](https://github.com/ultralytics/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](https://www.ultralytics.com/license). | |
| --- | |
| See also: [**Cowcatcher**](https://huggingface.co/CowcatcherAI/Cowcatcher) — our sibling model family | |
| that detects mounting behaviour for heat detection. | |