
![FGI.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/4x5S3wqAgJiNuFtoqZzq9.png)

# **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
```

![download.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/rrUjAtRXEZWIOySA_7n1r.png)

---

## **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
badminton cricket football karate swimming tennis wrestling