feral-ai / README.md
Firebleu's picture
Update README.md
78a2305 verified
---
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
> **F**or **E**veryone, **R**ecognizing **A**nimal **L**ife
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](https://www.kaggle.com/datasets/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](confusion_matrix.png)
## Confidence Distribution
![Confidence Distribution](confidence_distribution.png)
---
## Live Demo
πŸ‘‰ [Try FERAL.AI on Spaces](https://huggingface.co/spaces/Firebleu/feral-ai)
## Source Code
πŸ‘‰ [codeberg.org/Firebleudark/feral-ai](https://codeberg.org/Firebleudark/feral-ai)
---
## Usage
```python
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](https://codeberg.org/Firebleudark/feral-ai/src/branch/main/LICENSE)