TurtleDetector detects sea turtles, their heads, and their flippers. For flippers, it distinguishes front/hind and left/right flippers, enabling precise matching for re-identification of individual turtles. It is able to detect sea turtles both under and above water.
Evaluation
Photos with turtles
The model was evaluated on the test sets, which are disjoint from the training and evaluation data. We used SeaTurtleID2022 with underwater photos, TurtlesOfSMSRC with photos from rescue centres and TurtlewatchEgypt 2016 (private) with underwater photos, including photos without any turtle.
All numbers are computed for the confidence threshold 0.7, so only predictions with confidence of at least 0.7 are kept. Precision is the fraction of detections which are correct, while recall is the fraction of annotated body parts which were detected.
| Class | SeaTurtleID2022 precision | SeaTurtleID2022 recall | TurtlesOfSMSRC precision | TurtlesOfSMSRC recall | TurtlewatchEgypt 2016 precision | TurtlewatchEgypt 2016 recall |
|---|---|---|---|---|---|---|
| turtle | 0.994 | 0.996 | 1.000 | 1.000 | 0.995 | 0.980 |
| head | 0.998 | 0.938 | 0.965 | 0.982 | 0.997 | 0.890 |
| flipper_fl | 0.975 | 0.897 | 0.978 | 0.978 | 0.945 | 0.907 |
| flipper_fr | 0.957 | 0.915 | 1.000 | 1.000 | 0.975 | 0.880 |
| flipper_hl | 0.930 | 0.848 | 0.889 | 0.941 | 0.960 | 0.768 |
| flipper_hr | 0.936 | 0.836 | 0.933 | 0.824 | 0.914 | 0.763 |
Photos without turtles
The false positive rate is the fraction of photos without turtles in which the model detected at least one turtle or body part. SeaTurtleID2022 (private) is a small set of difficult underwater photos from the same location as SeaTurtleID2022. TurtlewatchEgypt 2016 (private) contains the test photos of TurtlewatchEgypt 2016 without any turtle.
| Dataset | False positive rate |
|---|---|
| UIEB | 0.008 |
| SUIM | 0.002 |
| SeaTurtleID2022 (private) | 0.020 |
| TurtlewatchEgypt 2016 (private) | 0.007 |
Observations
- The detections are very reliable: precision is at least 0.89 for all classes and datasets, so false detections are rare both on photos with and without turtles.
- The whole turtle is almost always found. Most errors are missed body parts, mainly hind flippers, which are smaller and often partially hidden.
- Lowering the confidence threshold to 0.5 increases the recall of heads to about 0.98 with almost no decrease in precision.
Usage
The model can be used as any ultralytics model. First, download and load the model.
from huggingface_hub import hf_hub_download
from ultralytics import YOLO
path_model = hf_hub_download(
repo_id="BVRA/TurtleDetector",
filename="turtle_detector.pt",
)
model = YOLO(path_model)
Then download an image (or use yours) and run the prediction.
import requests
from io import BytesIO
from PIL import Image
def load_image(url):
r = requests.get(url, timeout=30)
r.raise_for_status()
return Image.open(BytesIO(r.content)).convert("RGB")
img_url = "https://huggingface.co/BVRA/TurtleDetector/resolve/main/images/321595639_581630651.jpg"
img = load_image(img_url)
result = model.predict(img, verbose=False, save=False, show=False)[0]
img_annotated = result.plot()[:, :, ::-1]
Image.fromarray(img_annotated)
Training
The model is a fine-tuned yolo26s-seg. The following sources were used for training:
- SeaTurtleID2022: A large database of 438 individual loggerhead turtles spanning 13 years. All photos are underwater.
- TurtlesOfSMSRC: Emerging database of mostly juvenile green turtles of both underwater photos and photos from rescue centres. Only the latter were chosen to complement the SeaTurtleID2022 database.
- TurtlewatchEgypt 2016: A private database of underwater photos from the Red Sea. The masks were predicted by the previous version of TurtleDetector and manually verified.
- UIEB and SUIM: Underwater images without turtles used as negatives to reduce false positives.
During training, images are randomly cropped around the head with probability 0.15 so that the model also works on close-up photos. The masks of the turtle class cover the whole turtle including the head and flippers.
The training scripts are in the training folder:
preparation: downloading (download_data.py) and preparing (prepare_data.py) the data, creating the masks for TurtlesOfSMSRC and TurtlewatchEgypt.train: training the model (segmentation_train.py).evaluation: evaluating the model on the test sets (evaluate.py) and comparing the evaluations of multiple models.
The scripts are run as modules from the training folder, for example:
cd training
python -m preparation.download_data
python -m preparation.prepare_data
python -m train.segmentation_train --crop_prob 0.15 --name crop15_640_noov