feral-ai / README.md
Firebleu's picture
Update README.md
78a2305 verified
metadata
license: gpl-3.0
tags:
  - image-classification
  - pytorch
  - mobilenetv2
  - computer-vision
pipeline_tag: image-classification
base_model: google/mobilenet_v2_1.0_224

âš¡ 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