File size: 3,199 Bytes
eda6d10
 
 
 
b1506a2
 
 
 
 
 
 
 
 
 
 
c12e5ca
 
b1506a2
 
 
 
 
 
c12e5ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b1506a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
---
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
---

![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