34data/animal-10
Viewer • Updated • 26.2k • 67
How to use jramduran/animals10-vit-base with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-classification", model="jramduran/animals10-vit-base")
pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoImageProcessor, AutoModelForImageClassification
processor = AutoImageProcessor.from_pretrained("jramduran/animals10-vit-base")
model = AutoModelForImageClassification.from_pretrained("jramduran/animals10-vit-base", device_map="auto")Classifies a photo into one of 10 animals: butterfly, cat, chicken, cow, dog, elephant, horse, sheep, spider, squirrel.
google/vit-base-patch16-224 (Vision Transformer pre-trained on ImageNet-21k and fine-tuned on ImageNet-1k) fully fine-tuned with a new 10-class head.
| Metric (held-out test, n=2618) | Value |
|---|---|
| Accuracy | 0.992 |
| F1 macro | 0.992 |
| Precision (macro) | 0.993 |
| Recall (macro) | 0.991 |
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, 3 epochs, on NVIDIA GeForce RTX 5060 Laptop GPU (7.0 min).
Code: https://github.com/JTiiz/CNN-project (training/).
from transformers import pipeline
clf = pipeline("image-classification", model="jramduran/animals10-vit-base")
clf("cat.jpg")