YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Salamandra head-orientation classifier
Binary classifier from the SalamandraReID preprocessing pipeline for the Near Eastern fire salamander (Salamandra infraimmaculata). After PCA aligns the body axis to the horizontal, the head can be on either side. This model decides which side; images predicted head-right are rotated 180ยฐ so that every image faces head-left.
Model: ResNet-18 (ImageNet-pretrained), with the final layer replaced by a single-logit output.
Input: a segmented image (background set to black), rotated by PCA so the body axis is horizontal, and cropped to the mask's bounding box. It is then padded to a square with black, resized to 224 ร 224, and normalized with ImageNet mean/std. The model is not intended for raw, unmasked or unaligned photos.
Output: sigmoid > 0.5 โ head left; otherwise โ head right.
Test accuracy: 99.61% (514/516). Each of the 258 test images is scored as-is (head-left) and rotated 180ยฐ (head-right).
Usage
import torch
from torchvision.models import resnet18
from huggingface_hub import hf_hub_download
model = resnet18(num_classes=1)
ckpt = torch.load(hf_hub_download("yoavram-lab/salamandra-head-orientation", "best.pt"), map_location="cpu")
model.load_state_dict(ckpt["model_state"])
model.eval()
For the full preprocessing and inference code, see image_preprocessing/pca_orient.py.