Sports Ball Classifier - ConvNeXt Base

This model is a fine-tuned ConvNeXt-Base architecture trained to classify 15 different types of sports balls. The model can accurately distinguish between various sports equipment including footballs, basketballs, tennis balls, and more specialized items like hockey pucks and shuttlecocks.

The model was trained using transfer learning from a ConvNeXt-Base model pre-trained on ImageNet, with the classification head modified for 15-class sports ball classification. It achieves strong performance across all sports ball categories and is optimized for real-world deployment scenarios.

Key features:

  • High accuracy across 15 sports ball categories
  • Robust to different lighting conditions and backgrounds
  • Optimized for 224x224 input images
  • Fast inference suitable for real-time applications

Model Details

  • Model Architecture: ConvNeXt
  • Framework: PyTorch
  • Library: timm
  • Task: Image Classification
  • Classes: 15 classes
  • Input Size: 224x224 RGB images

Classes

The model can classify the following categories:

  • american_football
  • baseball
  • basketball
  • billiard_ball
  • bowling_ball
  • cricket_ball
  • football
  • golf_ball
  • hockey_ball
  • hockey_puck
  • rugby_ball
  • shuttlecock
  • table_tennis_ball
  • tennis_ball
  • volleyball

Usage

import torch
import timm
from torchvision import transforms
from PIL import Image

# Load model
model = timm.create_model('convnext_base', pretrained=False)
model.head = torch.nn.Sequential(
    torch.nn.AdaptiveAvgPool2d(1),
    torch.nn.Flatten(),
    torch.nn.Linear(model.head.in_features, 15)
)

# Load weights
model.load_state_dict(torch.load('model.pth', map_location='cpu'))
model.eval()

# Preprocessing
transform = transforms.Compose([
    transforms.Resize((224, 224)),
    transforms.ToTensor(),
    transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])

# Inference
image = Image.open('your_image.jpg')
input_tensor = transform(image).unsqueeze(0)

with torch.no_grad():
    outputs = model(input_tensor)
    probabilities = torch.nn.functional.softmax(outputs[0], dim=0)
    predicted_class = torch.argmax(probabilities).item()

Model Performance

  • Training accuracy: 87.5%
  • Validation accuracy: 85.03%
  • Test accuracy: 83.5%

Training Details

  • Base model: convnext_base (pretrained on ImageNet)
  • Fine-tuning approach: Fine-tuning with frozen backbone
  • Dataset:
  • Epochs: 10
  • Optimizer: AdamW
  • Learning Rate: 0.001
  • Batch Size: 32

Additional Information

The model uses standard ImageNet preprocessing with mean=[0.485, 0.456, 0.406] and std=[0.229, 0.224, 0.225].

For best results:

  • Use clear, well-lit images
  • Ensure the sports ball occupies a significant portion of the image
  • Images should be in RGB format
  • Model performs best on images similar to the training distribution

The training dataset consisted of carefully curated sports ball images with balanced representation across all 15 categories. Data augmentation techniques including rotation, scaling, and color jittering were applied during training to improve generalization.

Limitations

  • Performance may vary on heavily occluded or poorly lit images
  • Model is specifically trained for the 15 sports ball categories listed above
  • May not generalize well to sports balls not in the training set
  • Best results with single-object images where the sports ball is the primary subject
  • Performance may decrease with unusual camera angles or extreme close-ups

Citation

If you use this model, please cite:

@misc{sports_ball_convnext_classifier_2024,
  title={Sports Ball Classifier - ConvNeXt Base},
  author={Alamgirapi},
  year={2025},
  howpublished={\url{https://huggingface.co/Alamgirapi/sports-ball-convnext-classifier}}
}

Contact

For questions or issues, please contact: [email protected]

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Space using Alamgirapi/sports-ball-convnext-classifier 1