Downloads · 30 days
8
9% of all-time downloads
sanjeevan7/emnist-letters-eng-resnet18-v2
emnist-letters-eng-resnet18-v2 is a text classification model from sanjeevan7. Use it when you need a label for a piece of text.
Downloads · 30 days
8
9% of all-time downloads
All-time downloads
86
Public
Repo size
89.6 MB
Likes
1
Public
Click a slice to open those files.
.bin44.8 MB · 100%
From the Hugging Face model README
This repository contains a ResNet-18 model fine-tuned on the EMNIST Letters dataset for handwritten character recognition (a-z).
Architecture: ResNet-18 (pretrained on ImageNet)
Dataset: EMNIST Letters (https://www.nist.gov/itl/products-and-services/emnist-dataset)
Input Size: 224x224 (grayscale, converted to 3 channels)
Classes: 26 lowercase letters (a to z)
Transformations:
pip install torch torchvision huggingface_hub
import torch
from torchvision import models
from huggingface_hub import hf_hub_download
# Download model weights
model_path = hf_hub_download("sanjeevan7/emnist-letters-eng-resnet18-v2", filename="pytorch_model.bin")
# Load model architecture
model = models.resnet18()
model.fc = torch.nn.Linear(model.fc.in_features, 26) # 26 letters
# Load weights
model.load_state_dict(torch.load(model_path, map_location=torch.device('cpu')))
model.eval()
import torchvision.transforms as transforms
import torchvision.transforms.functional as TF
transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.Grayscale(3),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])
from PIL import Image
# Load and preprocess image
image = Image.open("your_image.png").convert('L') # Grayscale
input_tensor = transform(image).unsqueeze(0)
# Predict
with torch.no_grad():
outputs = model(input_tensor)
_, predicted = torch.max(outputs, 1)
predicted_class = predicted.item()
predicted_char = chr(predicted_class + 97) # 0->a, 1->b, ...
print(f"Predicted Character: {predicted_char}")
Accuracy: ~94% on EMNIST Letters test set
Known Limitations:
| File | Description |
|---|---|
pytorch_model.bin | Model weights |
config.json | Model metadata (architecture info) |
For any questions, please contact Sanjeevan.