Community Fish Detector (CFD)
July 7, 2026 · View on GitHub
This repository provides pretrained object detection models for identifying one class: “fish”.
The model was trained on the Community Fish Detection Dataset, a collaboratively built, large-scale dataset that unifies >1.9 million images and >935,000 fish bounding boxes from 17 open datasets spanning freshwater, marine, and lab environments.
Our goal is to detect any fish, anywhere. These models represent an initial training effort. They perform reasonably well across a variety of environments but can certainly be improved. If you’d like to contribute improvements or new experiments, please get in touch!
Table of Contents
Models
| Model | Architecture | Input image size | Target classes | Training data | Inference license | AP |
|---|---|---|---|---|---|---|
| cfd-2026.05.13-rf-detr-medium-1024 | RF-DETR Medium | 1024 | 1 (fish) | Community Fish Detection Dataset | Apache | .609 |
| cfd-2026.05.13-rf-detr-small-1024 | RF-DETR Small | 1024 | 1 (fish) | Community Fish Detection Dataset | Apache | .606 |
| cfd-2026.02.02-rf-detr-nano-640 | RF-DETR Nano | 640 | 1 (fish) | Community Fish Detection Dataset | Apache | .596 |
| cfd-yolov12x-1.00 | YOLOv12x | 1024 | 1 (fish) | Community Fish Detection Dataset | AGPL | .588 |
The "inference license" column describes license information for the inference code you're likely to use when you run each model: the RF-DETR Python package for RF-DETR models, and the Ultralytics package for Ultralyics models. This column does not describe the licenses associated with the training data, which is a composite of multiple datasets with a variety of licenses.
The "AP" column presents the average precision against the validation subset of the Community Fish Detection Dataset. It's not straightforward to publish the splits we use (hopefully we will eventually, but we haven't done this yet), so you should not make anything of the absolute AP values. This column is only useful to compare these models to each other and to future model releases.
Quick start
These instructions describe the process for running RF-DETR versions of the CFD.
The YOLOv12x version is deprecated, and future models will be based on RF-DETR, because the AGPL license used by YOLOv12x and related model families is prohibitive for some of the use cases we'd like to support. If you want to run the YOLOv12x version, see README-yolo.md.
Clone the repo
git clone https://github.com/filippovarini/community-fish-detector.git
cd community-fish-detector
Download the model weights
You can download weights from the Releases page, or using the links in the summary table above.
Install dependencies
pip install -r requirements.txt
Run inference
Command-line batch inference
rf_detr_batch_inference.py runs the model recursively on a folder of images and/or videos (or on a single image or video file), and writes results in MegaDetector output format.
python rf_detr_batch_inference.py "/path/to/your/model.pth" "/path/to/your/input/folder" "/path/to/your/output/file.json"
The input can be a folder (searched recursively for images and videos) or a single image or video file. Images and videos found in the same folder are written to the same output file.
For videos, the model is run on sampled frames. By default one frame per second is sampled; use --time_sample to change the sampling interval in seconds, or --frame_sample to sample every Nth frame instead.
Useful options:
--skip_images/--skip_video: process only videos, or only images--time_sample N: sample one frame every N seconds from videos (default: 1.0)--frame_sample N: sample every Nth frame from videos (mutually exclusive with--time_sample)
Run python rf_detr_batch_inference.py with no arguments to see all available options.
Programmatic inference
import supervision as sv
from rfdetr import from_checkpoint
from PIL import Image
# Load model
model = from_checkpoint("/path/to/your/model.pth")
# Run on an image
image = Image.open("/path/to/your/image.jpg")
detections = model.predict(image, threshold=0.3)
# Draw the resulting detections on the image and save the result
box_annotator = sv.BoxAnnotator()
label_annotator = sv.LabelAnnotator()
labels = [f"fish {conf:.2f}" for conf in detections.confidence]
annotated = box_annotator.annotate(image.copy(), detections)
annotated = label_annotator.annotate(annotated, detections, labels=labels)
annotated.save("/path/to/your/output.jpg")
Testing everything
You can test the whole pipeline as follows, assuming you are in a conda shell and you are in the repo root. test_community_fish_detector will download weights for one of the models (defaults to the medium model), run it on the test images in this repo, and open a preview of the results in a browser.
# Create a conda environment
conda create -n cfd-inference python=3.12 pip -y && conda activate cfd-inference
# Install dependencies
pip install -r requirements.txt --upgrade --force --no-cache-dir
# Download weights, run the model, and generate a preview of the results
python test_community_fish_detector.py
Contributors
This model was created by a collective effort of the following folks: Filippo Varini, Dan Morris, Sonny Burniston, Oceane Boulais, Kevin Barnard, Laura Chrobak, Alexander Merdian-Tarko, Devi Ayyagari, Mona Dhiflaoui, Joshua Chen, Gerard Calvo Bartra, Kalindi Fonda, Levi Veevee Cai, Giorgio De Pertis, Chris Jackett, Aditya Shirvalkar, Adrian Ibanez, and many others.
If you contributed, but you don't see your name here, please email us.
We welcome further contributions; if you have a dataset that could expand coverage, or want to contribute to improving the model, please reach out!
Citing this work
If you use this model in your research or applications, please cite the GitHub repository:
@misc{community-fish-detector,
author = {Varini, Filippo and Morris, Dan and Burniston, Sonny and Boulais, Oceane and Barnard, Kevin and others},
title = {Community Fish Detector},
year = {2026},
howpublished = {\url{https://github.com/filippovarini/community-fish-detector}},
}
Or in plain text:
Varini, F., Morris, D., Burniston, S., Boulais, O., Barnard, K., et al. (2026). Community Fish Detector. GitHub. https://github.com/filippovarini/community-fish-detector
Example Predictions
Below we provide some visual examples that overlay the ground truth with the model detections, to give you a qualitative sense of the model's training domain.
Also see
- Hugging Face Space for this model set up by the FathomNet community.
Test video credit
The test video in the test-images folder comes from @amnart-keawted-2221199 on pexels.com.