Instructions to use mayurgp/sports-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- fastai
How to use mayurgp/sports-classifier with fastai:
from huggingface_hub import from_pretrained_fastai learn = from_pretrained_fastai("mayurgp/sports-classifier") - Notebooks
- Google Colab
- Kaggle
Sports Classifier π
A fastai vision learner that classifies sports photos into 100 sport classes β everything from air hockey to wingsuit flying.
This is the model behind the Game State Vision Streamlit app.
- Model repo (this):
mayurgp/sports-classifier - Live app: Game State Vision (Streamlit Community Cloud)
- File:
sports_classifier.pkl(~47 MB, fastaiLearnerexport)
Model details
| Attribute | Value |
|---|---|
| Task | Image classification (single-label, 100 classes) |
| Backbone | CNN (fastai cnn_learner, Sequential head) |
| Input size | 224 Γ 224, RGB, squish-resize |
| Output | 100 probabilities (softmax) |
| Format | fastai Learner pickle export (~47 MB) |
| Framework | PyTorch / fastai 2.8.8 |
| Visualize | mayurgp/sports-classifier |
Classes (all 100)
sports_classifier predicts exactly one of these 100 sports:
air hockey, ampute football, archery, arm wrestling, axe throwing, balance beam, barell racing, baseball, basketball, baton twirling,
bike polo, billiards, bmx, bobsled, bowling, boxing, bull riding, bungee jumping, canoe slamon, cheerleading,
chuckwagon racing, cricket, croquet, curling, disc golf, fencing, field hockey, figure skating men, figure skating pairs, figure skating women,
fly fishing, football, formula 1 racing, frisbee, gaga, giant slalom, golf, hammer throw, hang gliding, harness racing,
high jump, hockey, horse jumping, horse racing, horseshoe pitching, hurdles, hydroplane racing, ice climbing, ice yachting, jai alai,
javelin, jousting, judo, lacrosse, log rolling, luge, motorcycle racing, mushing, nascar racing, olympic wrestling,
parallel bar, pole climbing, pole dancing, pole vault, polo, pommel horse, rings, rock climbing, roller derby, rollerblade racing,
rowing, rugby, sailboat racing, shot put, shuffleboard, sidecar racing, ski jumping, sky surfing, skydiving, snow boarding,
snowmobile racing, speed skating, steer wrestling, sumo wrestling, surfing, swimming, table tennis, tennis, track bicycle, trapeze,
tug of war, ultimate, uneven bars, volleyball, water cycling, water polo, weightlifting, wheelchair basketball, wheelchair racing, wingsuit flying
Usage
1. Install dependencies
pip install fastai torch huggingface_hub pillow
2. Download & load
from huggingface_hub import hf_hub_download
from fastai.vision.all import load_learner
model_path = hf_hub_download(repo_id="mayurgp/sports-classifier", filename="sports_classifier.pkl")
learner = load_learner(model_path)
3. Predict
from fastai.vision.all import PILImage
img = PILImage.create("soccer.jpg")
pred, pred_idx, probs = learner.predict(img)
print(f"Predicted: {pred}")
# top 5 with probabilities
import pandas as pd
top = sorted(range(len(probs)), key=lambda i: probs[i], reverse=True)[:5]
for i in top:
print(f"{learner.dls.vocab[i]:20s} {probs[i]:.2%}")
Note on Python version differences. This model was exported on Python 3.12. If
load_learnerfails with a plum/Resolver pickling error on a newer setup, apply the small compat shim ininfer.pybefore loading.
Try it live
Upload a sports photo and get a prediction in the deployed Streamlit app (Game State Vision).
Security / trust note
load_learner uses Python's pickle, which can execute arbitrary code. Frameworks picklescan marks a fastai Learner pickle as Unsafe (`fastai.learner.Learner imports) β this is expected for fastai exports. Only load this file from a trusted source (this public repo).
If you need a stricter, weight-only distribution, re-export the model to safetensors / model.pth + a vocab.json, and load with learn = Learner.load(...) instead.
Dataset / reproduction
- The app/repo metadata for this card: see
mayurgp/game-state-visionand thestreamlit-colab-apprepository. - Fine-tuning with fastai's
cnn_learner+Resize(224)on a 100-class sports dataset. - Export produced by
learner.export()βsports_classifier.pkl.
Model card maintained at hf-model-card/README.md.