Animals-10 · ConvNeXt-Tiny

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

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

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

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 (5.7 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-convnext-tiny")
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-convnext-tiny