Views
No views yet

Gym-Workout-Classifier-SigLIP2 is an image classification vision-language encoder model fine-tuned from google/siglip2-base-patch16-224 for a single-label classification task. It is designed to classify gym workout exercises using the SiglipForImageClassification architecture.
1 Classification Report:
2 precision recall f1-score support
3
4 barbell biceps curl 0.9613 0.9574 0.9593 493
5 bench press 0.9402 0.9359 0.9381 437
6 chest fly machine 0.9694 0.9484 0.9588 368
7 deadlift 0.9833 0.9542 0.9685 371
8 decline bench press 0.9884 0.9499 0.9688 359
9 hammer curl 0.9917 0.9398 0.9651 382
10 hip thrust 0.9692 0.9717 0.9705 389
11 incline bench press 0.9297 0.9588 0.9440 510
12 lat pulldown 0.9607 0.9735 0.9670 452
13 lateral raises 0.9539 0.9814 0.9674 590
14 leg extension 0.9573 0.9854 0.9712 410
15 leg raises 0.9939 0.9109 0.9506 359
16 plank 0.9828 0.9856 0.9842 695
17 pull up 0.9882 0.9744 0.9813 430
18 push up 0.9382 0.9762 0.9568 420
19 romanian deadlift 0.9617 0.9716 0.9667 388
20 russian twist 0.8702 0.9918 0.9270 365
21 shoulder press 0.9499 0.9525 0.9512 358
22 squat 0.9761 0.9441 0.9598 519
23 t bar row 0.9806 0.9743 0.9774 467
24 tricep dips 0.9834 0.9713 0.9773 488
25 tricep pushdown 0.9837 0.9657 0.9746 437
26
27 accuracy 0.9638 9687
28 macro avg 0.9643 0.9625 0.9630 9687
29 weighted avg 0.9647 0.9638 0.9639 9687
1from datasets import load_dataset
2
3# Load the dataset
4dataset = load_dataset("YOUR-DATASET-HERE")
5
6# Extract unique labels
7labels = dataset["train"].features["label"].names
8
9# Create id2label mapping
10id2label = {str(i): label for i, label in enumerate(labels)}
11
12# Print the mapping
13print(id2label)!pip install -q transformers torch pillow gradio1import gradio as gr
2from transformers import AutoImageProcessor
3from transformers import SiglipForImageClassification
4from transformers.image_utils import load_image
5from PIL import Image
6import torch
7
8# Load model and processor
9model_name = "prithivMLmods/Gym-Workout-Classifier-SigLIP2"
10model = SiglipForImageClassification.from_pretrained(model_name)
11processor = AutoImageProcessor.from_pretrained(model_name)
12
13def workout_classification(image):
14 """Predicts workout exercise classification for an image."""
15 image = Image.fromarray(image).convert("RGB")
16 inputs = processor(images=image, return_tensors="pt")
17
18 with torch.no_grad():
19 outputs = model(**inputs)
20 logits = outputs.logits
21 probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
22
23 labels = {
24 "0": "barbell biceps curl", "1": "bench press", "2": "chest fly machine", "3": "deadlift",
25 "4": "decline bench press", "5": "hammer curl", "6": "hip thrust", "7": "incline bench press",
26 "8": "lat pulldown", "9": "lateral raises", "10": "leg extension", "11": "leg raises",
27 "12": "plank", "13": "pull up", "14": "push up", "15": "romanian deadlift",
28 "16": "russian twist", "17": "shoulder press", "18": "squat", "19": "t bar row",
29 "20": "tricep dips", "21": "tricep pushdown"
30 }
31 predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
32
33 return predictions
34
35# Create Gradio interface
36iface = gr.Interface(
37 fn=workout_classification,
38 inputs=gr.Image(type="numpy"),
39 outputs=gr.Label(label="Prediction Scores"),
40 title="Gym Workout Classification",
41 description="Upload an image to classify the workout exercise."
42)
43
44# Launch the app
45if __name__ == "__main__":
46 iface.launch()