This is a fine-tuned ResNet18 model for classifying images into 10 categories from the CIFAR-10 dataset. It was trained using transfer learning on a subset of ImageNet-pretrained weights and optimized for small image classification tasks.
1import torch
2import torchvision.models as models
3import torch.nn as nn
4
5# Load fine-tuned ResNet18 model
6model = models.resnet18(pretrained=False)
7num_ftrs = model.fc.in_features
8model.fc = nn.Linear(num_ftrs, 10)
9
10# Load saved model weights
11model.load_state_dict(torch.hub.load_state_dict_from_url(
12 'https://huggingface.co/your_username/resnet18-cifar10/resolve/main/resnet18_cifar10.pth',
13 map_location=torch.device("cpu")
14))
15model.eval()