Update README.md
Browse files
README.md
CHANGED
@@ -1,9 +1,23 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
4 |
-
|
5 |

|
6 |
|
|
|
|
|
|
|
|
|
|
|
7 |
Classification Report:
|
8 |
precision recall f1-score support
|
9 |
|
@@ -37,5 +51,90 @@ license: apache-2.0
|
|
37 |
|
38 |

|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
|
|
41 |
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
+
language:
|
4 |
+
- en
|
5 |
+
base_model:
|
6 |
+
- google/siglip2-base-patch16-224
|
7 |
+
pipeline_tag: image-classification
|
8 |
+
library_name: transformers
|
9 |
+
tags:
|
10 |
+
- gym
|
11 |
+
- workout
|
12 |
+
- classifier
|
13 |
---
|
|
|
14 |

|
15 |
|
16 |
+
# **Gym-Workout-Classifier-SigLIP2**
|
17 |
+
|
18 |
+
> **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.
|
19 |
+
|
20 |
+
|
21 |
Classification Report:
|
22 |
precision recall f1-score support
|
23 |
|
|
|
51 |
|
52 |

|
53 |
|
54 |
+
The model categorizes images into 22 workout classes:
|
55 |
+
- **Class 0:** "barbell biceps curl"
|
56 |
+
- **Class 1:** "bench press"
|
57 |
+
- **Class 2:** "chest fly machine"
|
58 |
+
- **Class 3:** "deadlift"
|
59 |
+
- **Class 4:** "decline bench press"
|
60 |
+
- **Class 5:** "hammer curl"
|
61 |
+
- **Class 6:** "hip thrust"
|
62 |
+
- **Class 7:** "incline bench press"
|
63 |
+
- **Class 8:** "lat pulldown"
|
64 |
+
- **Class 9:** "lateral raises"
|
65 |
+
- **Class 10:** "leg extension"
|
66 |
+
- **Class 11:** "leg raises"
|
67 |
+
- **Class 12:** "plank"
|
68 |
+
- **Class 13:** "pull up"
|
69 |
+
- **Class 14:** "push up"
|
70 |
+
- **Class 15:** "romanian deadlift"
|
71 |
+
- **Class 16:** "russian twist"
|
72 |
+
- **Class 17:** "shoulder press"
|
73 |
+
- **Class 18:** "squat"
|
74 |
+
- **Class 19:** "t bar row"
|
75 |
+
- **Class 20:** "tricep dips"
|
76 |
+
- **Class 21:** "tricep pushdown"
|
77 |
+
|
78 |
+
# **Run with Transformers🤗**
|
79 |
+
|
80 |
+
```python
|
81 |
+
!pip install -q transformers torch pillow gradio
|
82 |
+
```
|
83 |
+
|
84 |
+
```python
|
85 |
+
import gradio as gr
|
86 |
+
from transformers import AutoImageProcessor
|
87 |
+
from transformers import SiglipForImageClassification
|
88 |
+
from transformers.image_utils import load_image
|
89 |
+
from PIL import Image
|
90 |
+
import torch
|
91 |
+
|
92 |
+
# Load model and processor
|
93 |
+
model_name = "prithivMLmods/Gym-Workout-Classifier-SigLIP2"
|
94 |
+
model = SiglipForImageClassification.from_pretrained(model_name)
|
95 |
+
processor = AutoImageProcessor.from_pretrained(model_name)
|
96 |
+
|
97 |
+
def workout_classification(image):
|
98 |
+
"""Predicts workout exercise classification for an image."""
|
99 |
+
image = Image.fromarray(image).convert("RGB")
|
100 |
+
inputs = processor(images=image, return_tensors="pt")
|
101 |
+
|
102 |
+
with torch.no_grad():
|
103 |
+
outputs = model(**inputs)
|
104 |
+
logits = outputs.logits
|
105 |
+
probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
|
106 |
+
|
107 |
+
labels = {
|
108 |
+
"0": "barbell biceps curl", "1": "bench press", "2": "chest fly machine", "3": "deadlift",
|
109 |
+
"4": "decline bench press", "5": "hammer curl", "6": "hip thrust", "7": "incline bench press",
|
110 |
+
"8": "lat pulldown", "9": "lateral raises", "10": "leg extension", "11": "leg raises",
|
111 |
+
"12": "plank", "13": "pull up", "14": "push up", "15": "romanian deadlift",
|
112 |
+
"16": "russian twist", "17": "shoulder press", "18": "squat", "19": "t bar row",
|
113 |
+
"20": "tricep dips", "21": "tricep pushdown"
|
114 |
+
}
|
115 |
+
predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
|
116 |
+
|
117 |
+
return predictions
|
118 |
+
|
119 |
+
# Create Gradio interface
|
120 |
+
iface = gr.Interface(
|
121 |
+
fn=workout_classification,
|
122 |
+
inputs=gr.Image(type="numpy"),
|
123 |
+
outputs=gr.Label(label="Prediction Scores"),
|
124 |
+
title="Gym Workout Classification",
|
125 |
+
description="Upload an image to classify the workout exercise."
|
126 |
+
)
|
127 |
+
|
128 |
+
# Launch the app
|
129 |
+
if __name__ == "__main__":
|
130 |
+
iface.launch()
|
131 |
+
```
|
132 |
+
|
133 |
+
# **Intended Use:**
|
134 |
|
135 |
+
The **Gym-Workout-Classifier-SigLIP2** model is designed to classify different gym exercises based on images. Potential use cases include:
|
136 |
|
137 |
+
- **Workout Tracking:** Identifying exercises performed during a workout session.
|
138 |
+
- **Personal Training Assistance:** Helping trainers analyze and correct exercise form.
|
139 |
+
- **Gym Activity Monitoring:** Automating exercise logging and analysis in fitness apps.
|
140 |
+
- **AI-Powered Fitness Coaching:** Supporting AI-based fitness programs with real-time workout recognition.
|