Update README.md
Browse files
README.md
CHANGED
|
@@ -16,6 +16,12 @@ tags:
|
|
| 16 |
- Vision-Encoder
|
| 17 |
---
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
```py
|
| 20 |
Classification Report:
|
| 21 |
precision recall f1-score support
|
|
@@ -46,3 +52,103 @@ two_up_inverted 0.9855 0.9871 0.9863 6967
|
|
| 46 |
```
|
| 47 |
|
| 48 |

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
- Vision-Encoder
|
| 17 |
---
|
| 18 |
|
| 19 |
+

|
| 20 |
+
|
| 21 |
+
# **Hand-Gesture-19**
|
| 22 |
+
|
| 23 |
+
> **Hand-Gesture-19** 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 hand gesture images into different categories using the **SiglipForImageClassification** architecture.
|
| 24 |
+
|
| 25 |
```py
|
| 26 |
Classification Report:
|
| 27 |
precision recall f1-score support
|
|
|
|
| 52 |
```
|
| 53 |
|
| 54 |

|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
The model categorizes images into nineteen hand gestures:
|
| 58 |
+
- **Class 0:** "call"
|
| 59 |
+
- **Class 1:** "dislike"
|
| 60 |
+
- **Class 2:** "fist"
|
| 61 |
+
- **Class 3:** "four"
|
| 62 |
+
- **Class 4:** "like"
|
| 63 |
+
- **Class 5:** "mute"
|
| 64 |
+
- **Class 6:** "no_gesture"
|
| 65 |
+
- **Class 7:** "ok"
|
| 66 |
+
- **Class 8:** "one"
|
| 67 |
+
- **Class 9:** "palm"
|
| 68 |
+
- **Class 10:** "peace"
|
| 69 |
+
- **Class 11:** "peace_inverted"
|
| 70 |
+
- **Class 12:** "rock"
|
| 71 |
+
- **Class 13:** "stop"
|
| 72 |
+
- **Class 14:** "stop_inverted"
|
| 73 |
+
- **Class 15:** "three"
|
| 74 |
+
- **Class 16:** "three2"
|
| 75 |
+
- **Class 17:** "two_up"
|
| 76 |
+
- **Class 18:** "two_up_inverted"
|
| 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/Hand-Gesture-19"
|
| 94 |
+
model = SiglipForImageClassification.from_pretrained(model_name)
|
| 95 |
+
processor = AutoImageProcessor.from_pretrained(model_name)
|
| 96 |
+
|
| 97 |
+
def hand_gesture_classification(image):
|
| 98 |
+
"""Predicts the hand gesture category from 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": "call",
|
| 109 |
+
"1": "dislike",
|
| 110 |
+
"2": "fist",
|
| 111 |
+
"3": "four",
|
| 112 |
+
"4": "like",
|
| 113 |
+
"5": "mute",
|
| 114 |
+
"6": "no_gesture",
|
| 115 |
+
"7": "ok",
|
| 116 |
+
"8": "one",
|
| 117 |
+
"9": "palm",
|
| 118 |
+
"10": "peace",
|
| 119 |
+
"11": "peace_inverted",
|
| 120 |
+
"12": "rock",
|
| 121 |
+
"13": "stop",
|
| 122 |
+
"14": "stop_inverted",
|
| 123 |
+
"15": "three",
|
| 124 |
+
"16": "three2",
|
| 125 |
+
"17": "two_up",
|
| 126 |
+
"18": "two_up_inverted"
|
| 127 |
+
}
|
| 128 |
+
predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
|
| 129 |
+
|
| 130 |
+
return predictions
|
| 131 |
+
|
| 132 |
+
# Create Gradio interface
|
| 133 |
+
iface = gr.Interface(
|
| 134 |
+
fn=hand_gesture_classification,
|
| 135 |
+
inputs=gr.Image(type="numpy"),
|
| 136 |
+
outputs=gr.Label(label="Prediction Scores"),
|
| 137 |
+
title="Hand Gesture Classification",
|
| 138 |
+
description="Upload an image to classify the hand gesture."
|
| 139 |
+
)
|
| 140 |
+
|
| 141 |
+
# Launch the app
|
| 142 |
+
if __name__ == "__main__":
|
| 143 |
+
iface.launch()
|
| 144 |
+
```
|
| 145 |
+
|
| 146 |
+
# **Intended Use:**
|
| 147 |
+
|
| 148 |
+
The **Hand-Gesture-19** model is designed to classify hand gesture images into different categories. Potential use cases include:
|
| 149 |
+
|
| 150 |
+
- **Human-Computer Interaction:** Enabling gesture-based controls for devices.
|
| 151 |
+
- **Sign Language Interpretation:** Assisting in recognizing sign language gestures.
|
| 152 |
+
- **Gaming & VR:** Enhancing immersive experiences with hand gesture recognition.
|
| 153 |
+
- **Robotics:** Facilitating gesture-based robotic control.
|
| 154 |
+
- **Security & Surveillance:** Identifying gestures for access control and safety monitoring.
|