Downloads · 30 days
0
Akashpaul123/jersey-number-recognition-temporal
jersey-number-recognition-temporal is a machine learning model from Akashpaul123. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
A lightweight temporal model for recognizing jersey numbers (00-99) from image sequences using EfficientNet + LSTM architecture.
Downloads · 30 days
0
Access
Public
Updated Dec 11, 2025
Repo size
63.7 MB
Likes
0
Public
Click a slice to open those files.
.pth62.8 MB · 99%
From the Hugging Face model README
A lightweight temporal model for recognizing jersey numbers (00-99) from image sequences using EfficientNet + LSTM architecture.
This model recognizes jersey numbers on sports players by analyzing temporal sequences of images. Instead of predicting jersey numbers directly, it uses a two-digit decomposition strategy - predicting tens and units digits independently. This allows the model to generalize to any 2-digit number (00-99) even when trained on a limited set of jersey numbers.
Input: Sequence of 8 images (128x128 RGB)
↓
EfficientNet-B0 Backbone (frame-by-frame feature extraction)
↓
Feature Projection (1280 → 256 dims)
↓
Bidirectional LSTM (2 layers, 128 hidden units)
↓
Two Independent Classifiers:
├─ Tens Digit Head (10 classes: 0-9)
└─ Units Digit Head (10 classes: 0-9)
↓
Output: Jersey Number (00-99)
| Metric | Accuracy |
|---|---|
| Jersey Number | 95.94% |
| Tens Digit | 99.42% |
| Units Digit | 96.23% |
The model generalizes well across different jersey numbers, including rare classes with limited training data.
pip install torch torchvision timm huggingface_hub pillow
import torch
from huggingface_hub import hf_hub_download
from PIL import Image
import torchvision.transforms as transforms
# Download model
model_path = hf_hub_download(
repo_id="Akashpaul123/jersey-number-recognition-temporal",
filename="best_model.pth"
)
# Load model
checkpoint = torch.load(model_path, map_location='cpu')
# Note: You need to define the TemporalJerseyRecognizer class (see model architecture)
model = TemporalJerseyRecognizer(
backbone='efficientnet_b0',
feature_dim=256,
lstm_hidden=128,
lstm_layers=2,
dropout=0.3
)
model.load_state_dict(checkpoint['model_state_dict'])
model.eval()
# Prepare transform
transform = transforms.Compose([
transforms.Resize((128, 128)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])
# Load a sequence of 8 images
image_paths = ['frame1.jpg', 'frame2.jpg', ..., 'frame8.jpg']
images = []
for path in image_paths:
img = Image.open(path).convert('RGB')
img_tensor = transform(img)
images.append(img_tensor)
# Stack into sequence: (1, 8, 3, 128, 128)
sequence = torch.stack(images).unsqueeze(0)
# Predict
with torch.no_grad():
jersey_number, tens_digit, units_digit = model.predict_jersey_number(sequence)
print(f"Predicted Jersey Number: {jersey_number.item()}")
print(f"Tens Digit: {tens_digit.item()}, Units Digit: {units_digit.item()}")
This repository contains:
best_model.pth - Model checkpoint with weights and configurationmodel_architecture.py - Complete model architecture coderesults_summary.json - Detailed training results and metricstraining_history.csv - Epoch-by-epoch training metricsconfusion_matrices.png - Confusion matrices visualizationtraining_curves.png - Training and validation curvessample_predictions.png - Sample predictions on test setThe model's two-digit decomposition strategy enables it to recognize jersey numbers it has never seen during training:
Training Classes: 4, 6, 8, 9, 48, 49, 64, 66, 88, 89
Can Generalize To: Any combination of tens (0-9) and units (0-9) digits = 100 possible jersey numbers (00-99)
For example, even though the model never saw jersey #46, #69, or #94 during training, it can predict them by combining learned digit representations.
If you use this model, please cite:
@misc{jersey_number_recognition_2025,
title={Temporal Jersey Number Recognition},
author={Akash Paul},
year={2025},
publisher={Hugging Face},
url={https://huggingface.co/Akashpaul123/jersey-number-recognition-temporal}
}
Apache 2.0
For questions or feedback, please open an issue in this repository.