⚑ FERAL.AI

For Everyone, Recognizing Animal Life

Image classifier that distinguishes cats from dogs with 97.8% accuracy.
Built from scratch, open source, lightweight β€” runs on any machine.


Model Details

  • Architecture: MobileNetV2 (Transfer Learning)
  • Dataset: tongpython/cat-and-dog β€” 8,000 images
  • Accuracy: 97.8% on test set
  • F1-Score: 98%
  • Model size: ~14MB
  • Framework: PyTorch 2.12

Training β€” 2 phase strategy

Phase Layers trained Epochs LR Accuracy
πŸ₯Ά Phase 1 Last layer only (2,562 params) 5 0.001 95.8%
πŸ”₯ Phase 2 + Last 3 layers (1,208,642 params) 5 0.0001 98.2%

Evaluation Results

Metric Cat Dog Overall
Precision 97% 99% 98%
Recall 99% 97% 98%
F1-Score 98% 98% 98%
Accuracy 97.8%

Confusion Matrix

Confusion Matrix

Confidence Distribution

Confidence Distribution


Live Demo

πŸ‘‰ Try FERAL.AI on Spaces

Source Code

πŸ‘‰ codeberg.org/Firebleudark/feral-ai


Usage

from huggingface_hub import hf_hub_download
import torch
import torch.nn as nn
from torchvision import transforms, models
from PIL import Image

def build_model():
    model = models.mobilenet_v2(weights=None)
    model.classifier[1] = nn.Linear(1280, 2)
    return model

model_path = hf_hub_download("Firebleu/feral-ai", "model.pth")
model = build_model()
model.load_state_dict(torch.load(model_path, map_location="cpu"))
model.eval()

# Inference
transform = transforms.Compose([
    transforms.Resize((224, 224)),
    transforms.ToTensor(),
    transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
])

img = Image.open("your_image.jpg").convert("RGB")
output = model(transform(img).unsqueeze(0))
label = ["cat", "dog"][output.argmax().item()]
print(f"Prediction: {label}")

License

GPL-3.0-only β€” see LICENSE

Downloads last month
19
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for Firebleu/feral-ai

Finetuned
(81)
this model

Space using Firebleu/feral-ai 1