Downloads · 30 days
7
25% of all-time downloads
Ssiro3/resnet18-imagenet100-from-scratch
resnet18-imagenet100-from-scratch is a feature extraction model from Ssiro3. Use it when you need embeddings to search or compare text. It is set up for pytorch.
A ResNet-18 implementation built in PyTorch and trained from scratch on ImageNet-100.
Downloads · 30 days
7
25% of all-time downloads
All-time downloads
28
Public
Repo size
45 MB
Likes
0
Public
Click a slice to open those files.
.pth45 MB · 100%
From the Hugging Face model README
A ResNet-18 implementation built in PyTorch and trained from scratch on ImageNet-100.
This project was created as part of my effort to understand computer vision architectures from first principles rather than relying on pretrained torchvision models.
The model is intended both for ImageNet-100 classification and as a pretrained visual backbone for transfer-learning experiments.
The architecture was implemented manually in PyTorch.
The model was trained for 100 epochs using:
Training preprocessing:
v2.Compose([
v2.RandomResizedCrop(224),
v2.RandomHorizontalFlip(),
v2.ToImage(),
v2.ToDtype(scale=True, dtype=torch.float32),
v2.Normalize(
mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225]
)
])
Validation preprocessing:
v2.Compose([
v2.Resize(224),
v2.CenterCrop(224),
v2.ToImage(),
v2.ToDtype(dtype=torch.float32, scale=True),
v2.Normalize(
mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225]
)
])
Best ImageNet-100 validation accuracy:
78.72%
This was reached at epoch 81.
The uploaded checkpoint corresponds to the best validation model.
import torch
from model import ResNet18
model = ResNet18(num_classes=100)
state_dict = torch.load(
"model.pth",
map_location="cpu",
weights_only=True
)
model.load_state_dict(state_dict)
model.eval()
The classification layer can be removed to use the network as a 512-dimensional visual feature extractor:
model.fc = torch.nn.Identity()
An input batch with shape:
[B, 3, 224, 224]
will then produce:
[B, 512]
representations.
The purpose of this project is not only image classification.
The model was pretrained to investigate transfer learning: whether visual representations learned from natural images can transfer to substantially different visual domains.
The next stage of the project explores transfer learning from ImageNet-100 to knee MRI data for the RSNA Knee Abnormality Detection task.
The complete training notebook and broader computer vision learning project are available on GitHub:
https://github.com/sirohi-ml/Image_Detection_from_scratch
This model was trained on ImageNet-100 rather than the complete ImageNet-1K dataset.
It should therefore not be treated as equivalent to standard ImageNet-1K pretrained ResNet-18 weights.
Performance on downstream domains has not yet been established and should be evaluated for each transfer-learning task.