uoft-cs/cifar10
Viewer • Updated • 60k • 121k • 105
How to use clr4takeoff/convnext-small-cifar10 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-classification", model="clr4takeoff/convnext-small-cifar10")
pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png") # Load model directly
from transformers import AutoImageProcessor, AutoModelForImageClassification
processor = AutoImageProcessor.from_pretrained("clr4takeoff/convnext-small-cifar10")
model = AutoModelForImageClassification.from_pretrained("clr4takeoff/convnext-small-cifar10")This model is a fine-tuned version of facebook/convnext-small-224 on the CIFAR-10 dataset, achieving 97.9% test accuracy.
ConvNeXt is a pure convolutional model that modernizes the standard ResNet architecture by incorporating design choices from Vision Transformers. This Small variant has been fine-tuned on CIFAR-10 for image classification tasks.
| Metric | Value |
|---|---|
| Test Accuracy | 97.90% |
| Final Training Accuracy | 95.60% |
| Final Validation Accuracy | 89.72% |
from transformers import AutoImageProcessor, AutoModelForImageClassification
from PIL import Image
import torch
# Load model and processor
processor = AutoImageProcessor.from_pretrained("clr4takeoff/convnext-small-cifar10")
model = AutoModelForImageClassification.from_pretrained("clr4takeoff/convnext-small-cifar10")
# Load and process image
image = Image.open("path/to/your/image.jpg")
inputs = processor(images=image, return_tensors="pt")
# Inference
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
predicted_class = logits.argmax(-1).item()
print(f"Predicted class: {predicted_class}")
class_labels = [
"airplane", "automobile", "bird", "cat", "deer",
"dog", "frog", "horse", "ship", "truck"
]
predicted_label = class_labels[predicted_class]
print(f"Predicted label: {predicted_label}")
from torch.utils.data import DataLoader
from torchvision import datasets, transforms
# Prepare dataset
transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
])
dataset = datasets.CIFAR10(root='./data', train=False, download=True, transform=transform)
dataloader = DataLoader(dataset, batch_size=32)
# Inference loop
model.eval()
correct = 0
total = 0
with torch.no_grad():
for images, labels in dataloader:
inputs = processor(images=images, return_tensors="pt")
outputs = model(**inputs)
predictions = outputs.logits.argmax(-1)
correct += (predictions == labels).sum().item()
total += labels.size(0)
accuracy = correct / total
print(f"Accuracy: {accuracy:.2%}")
If you use this model, please cite:
@misc{convnext-small-cifar10,
author = {clr4takeoff},
title = {ConvNeXt-Small Fine-tuned on CIFAR-10},
year = {2026},
publisher = {HuggingFace},
url = {https://huggingface.co/clr4takeoff/convnext-small-cifar10}
}
@article{liu2022convnet,
title={A ConvNet for the 2020s},
author={Liu, Zhuang and Mao, Hanzi and Wu, Chao-Yuan and Feichtenhofer, Christoph and Darrell, Trevor and Xie, Saining},
journal={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
year={2022}
}
Base model
facebook/convnext-small-224