Instructions to use prithivMLmods/SportsNet-7 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use prithivMLmods/SportsNet-7 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="prithivMLmods/SportsNet-7") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# Load model directly from transformers import AutoProcessor, AutoModelForImageClassification processor = AutoProcessor.from_pretrained("prithivMLmods/SportsNet-7") model = AutoModelForImageClassification.from_pretrained("prithivMLmods/SportsNet-7", device_map="auto") - Notebooks
- Google Colab
- Kaggle
| license: apache-2.0 | |
| datasets: | |
| - vieanh/sports_img_classification | |
| language: | |
| - en | |
| base_model: | |
| - google/siglip2-base-patch16-224 | |
| pipeline_tag: image-classification | |
| library_name: transformers | |
| tags: | |
| - Sports | |
| - Cricket | |
| - art | |
| - Basketball | |
|  | |
| # **SportsNet-7** | |
| > **SportsNet-7** is a SigLIP2-based image classification model fine-tuned to identify seven popular sports categories. Built upon the powerful `google/siglip2-base-patch16-224` backbone, this model enables fast and accurate sport-type recognition from images or video frames. | |
| ```py | |
| Classification Report: | |
| precision recall f1-score support | |
| badminton 0.9385 0.9760 0.9569 1125 | |
| cricket 0.9583 0.9739 0.9660 1226 | |
| football 0.9821 0.9144 0.9470 958 | |
| karate 0.9513 0.9611 0.9562 488 | |
| swimming 0.9960 0.9650 0.9802 514 | |
| tennis 0.9425 0.9530 0.9477 1169 | |
| wrestling 0.9761 0.9753 0.9757 1175 | |
| accuracy 0.9606 6655 | |
| macro avg 0.9635 0.9598 0.9614 6655 | |
| weighted avg 0.9611 0.9606 0.9606 6655 | |
| ``` | |
|  | |
| --- | |
| ## **Label Classes** | |
| The model classifies an input image into one of the following 7 sports: | |
| ``` | |
| 0: badminton | |
| 1: cricket | |
| 2: football | |
| 3: karate | |
| 4: swimming | |
| 5: tennis | |
| 6: wrestling | |
| ``` | |
| --- | |
| ## **Installation** | |
| ```bash | |
| pip install transformers torch pillow gradio | |
| ``` | |
| --- | |
| ## **Example Inference Code** | |
| ```python | |
| import gradio as gr | |
| from transformers import AutoImageProcessor, SiglipForImageClassification | |
| from PIL import Image | |
| import torch | |
| # Load model and processor | |
| model_name = "prithivMLmods/SportsNet-7" | |
| model = SiglipForImageClassification.from_pretrained(model_name) | |
| processor = AutoImageProcessor.from_pretrained(model_name) | |
| # Label mapping | |
| id2label = { | |
| "0": "badminton", | |
| "1": "cricket", | |
| "2": "football", | |
| "3": "karate", | |
| "4": "swimming", | |
| "5": "tennis", | |
| "6": "wrestling" | |
| } | |
| def predict_sport(image): | |
| image = Image.fromarray(image).convert("RGB") | |
| inputs = processor(images=image, return_tensors="pt") | |
| with torch.no_grad(): | |
| outputs = model(**inputs) | |
| logits = outputs.logits | |
| probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist() | |
| prediction = {id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))} | |
| return prediction | |
| # Gradio interface | |
| iface = gr.Interface( | |
| fn=predict_sport, | |
| inputs=gr.Image(type="numpy"), | |
| outputs=gr.Label(num_top_classes=3, label="Predicted Sport"), | |
| title="SportsNet-7", | |
| description="Upload a sports image to classify it as Badminton, Cricket, Football, Karate, Swimming, Tennis, or Wrestling." | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch() | |
| ``` | |
| --- | |
| ## **Use Cases** | |
| * Sports video tagging | |
| * Real-time sport event classification | |
| * Dataset enrichment for sports analytics | |
| * Educational or training datasets for sports AI |