Animals-10 · EfficientNetV2-S

Classifies a photo into one of 10 animals: butterfly, cat, chicken, cow, dog, elephant, horse, sheep, spider, squirrel.

Transfer learning from EfficientNetV2-S pre-trained on ImageNet: the classification head is trained first with the backbone frozen, then the last 60 layers are fine-tuned at a low learning rate.

Metric (held-out test, n=2618) Value
Accuracy 0.983
F1 macro 0.980
Precision (macro) 0.980
Recall (macro) 0.980

Confusion matrix

Data: Animals-10, 26,177 photos, stratified split 80/10/10 (train / validation for early stopping / untouched test). The four models of the project share exactly the same split, so their scores are directly comparable.

Training: input 224x224, 8 epochs, on NVIDIA GeForce RTX 5060 Laptop GPU (16.5 min). Code: https://github.com/JTiiz/CNN-project (training/).

Usage

import os
os.environ["KERAS_BACKEND"] = "torch"  # the backend the model was trained and tested with

import json, keras, numpy as np
from huggingface_hub import snapshot_download
from PIL import Image

path = snapshot_download("jramduran/animals10-efficientnetv2s")
info = json.load(open(f"{path}/model_info.json"))
model = keras.saving.load_model(f"{path}/model.keras")

size = info["input_size"]
img = Image.open("cat.jpg").convert("RGB").resize((size, size))
x = np.asarray(img, dtype="float32")[None]          # raw pixels 0-255, no normalisation
probs = model.predict(x, verbose=0)[0]
print(info["labels"][probs.argmax()], probs.max())
Downloads last month
2
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train jramduran/animals10-efficientnetv2s