SigLIP2 Content Filters 052025 Patch 1
Collection
Moderation, Balance, Classifiers
•
7 items
•
Updated
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.
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
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
pip install transformers torch pillow gradio
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()
Base model
google/siglip2-base-patch16-224