Update README.md
Browse files
README.md
CHANGED
|
@@ -1,6 +1,21 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
```py
|
| 6 |
Classification Report:
|
|
@@ -39,4 +54,116 @@ Classification Report:
|
|
| 39 |
accuracy 0.9425 16177
|
| 40 |
macro avg 0.9433 0.9426 0.9413 16177
|
| 41 |
weighted avg 0.9457 0.9425 0.9425 16177
|
| 42 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
datasets:
|
| 4 |
+
- Vedant3907/Hindi-Sign-Language-Dataset
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
base_model:
|
| 8 |
+
- google/siglip2-base-patch16-224
|
| 9 |
+
pipeline_tag: image-classification
|
| 10 |
+
library_name: transformers
|
| 11 |
+
tags:
|
| 12 |
+
- Hindi-Sign-Language-Detection
|
| 13 |
+
- SigLIP2
|
| 14 |
+
- 93M
|
| 15 |
---
|
| 16 |
+
# Hindi-Sign-Language-Detection
|
| 17 |
+
|
| 18 |
+
> Hindi-Sign-Language-Detection is a vision-language model fine-tuned from google/siglip2-base-patch16-224 for multi-class image classification. It is trained to detect and classify Hindi sign language hand gestures into corresponding Devanagari characters using the SiglipForImageClassification architecture.
|
| 19 |
|
| 20 |
```py
|
| 21 |
Classification Report:
|
|
|
|
| 54 |
accuracy 0.9425 16177
|
| 55 |
macro avg 0.9433 0.9426 0.9413 16177
|
| 56 |
weighted avg 0.9457 0.9425 0.9425 16177
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
---
|
| 60 |
+
|
| 61 |
+
## Label Space: 29 Classes
|
| 62 |
+
|
| 63 |
+
The model classifies a hand sign into one of the following 29 Hindi characters:
|
| 64 |
+
|
| 65 |
+
```json
|
| 66 |
+
"id2label": {
|
| 67 |
+
"0": "ऋ",
|
| 68 |
+
"1": "क",
|
| 69 |
+
"2": "ख",
|
| 70 |
+
"3": "ग",
|
| 71 |
+
"4": "घ",
|
| 72 |
+
"5": "ङ",
|
| 73 |
+
"6": "च",
|
| 74 |
+
"7": "छ",
|
| 75 |
+
"8": "ज",
|
| 76 |
+
"9": "झ",
|
| 77 |
+
"10": "ट",
|
| 78 |
+
"11": "ठ",
|
| 79 |
+
"12": "ड",
|
| 80 |
+
"13": "ण",
|
| 81 |
+
"14": "त",
|
| 82 |
+
"15": "थ",
|
| 83 |
+
"16": "द",
|
| 84 |
+
"17": "न",
|
| 85 |
+
"18": "प",
|
| 86 |
+
"19": "फ",
|
| 87 |
+
"20": "ब",
|
| 88 |
+
"21": "भ",
|
| 89 |
+
"22": "म",
|
| 90 |
+
"23": "य",
|
| 91 |
+
"24": "र",
|
| 92 |
+
"25": "ल",
|
| 93 |
+
"26": "व",
|
| 94 |
+
"27": "स",
|
| 95 |
+
"28": "ह"
|
| 96 |
+
}
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
---
|
| 100 |
+
|
| 101 |
+
## Install Dependencies
|
| 102 |
+
|
| 103 |
+
```bash
|
| 104 |
+
pip install -q transformers torch pillow gradio
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
---
|
| 108 |
+
|
| 109 |
+
## Inference Code
|
| 110 |
+
|
| 111 |
+
```python
|
| 112 |
+
import gradio as gr
|
| 113 |
+
from transformers import AutoImageProcessor, SiglipForImageClassification
|
| 114 |
+
from PIL import Image
|
| 115 |
+
import torch
|
| 116 |
+
|
| 117 |
+
# Load model and processor
|
| 118 |
+
model_name = "prithivMLmods/Hindi-Sign-Language-Detection" # Replace with actual path
|
| 119 |
+
model = SiglipForImageClassification.from_pretrained(model_name)
|
| 120 |
+
processor = AutoImageProcessor.from_pretrained(model_name)
|
| 121 |
+
|
| 122 |
+
# Hindi label mapping
|
| 123 |
+
id2label = {
|
| 124 |
+
"0": "ऋ", "1": "क", "2": "ख", "3": "ग", "4": "घ",
|
| 125 |
+
"5": "ङ", "6": "च", "7": "छ", "8": "ज", "9": "झ",
|
| 126 |
+
"10": "ट", "11": "ठ", "12": "ड", "13": "ण", "14": "त",
|
| 127 |
+
"15": "थ", "16": "द", "17": "न", "18": "प", "19": "फ",
|
| 128 |
+
"20": "ब", "21": "भ", "22": "म", "23": "य", "24": "र",
|
| 129 |
+
"25": "ल", "26": "व", "27": "स", "28": "ह"
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
def classify_hindi_sign(image):
|
| 133 |
+
image = Image.fromarray(image).convert("RGB")
|
| 134 |
+
inputs = processor(images=image, return_tensors="pt")
|
| 135 |
+
|
| 136 |
+
with torch.no_grad():
|
| 137 |
+
outputs = model(**inputs)
|
| 138 |
+
logits = outputs.logits
|
| 139 |
+
probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
|
| 140 |
+
|
| 141 |
+
prediction = {
|
| 142 |
+
id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
return prediction
|
| 146 |
+
|
| 147 |
+
# Gradio Interface
|
| 148 |
+
iface = gr.Interface(
|
| 149 |
+
fn=classify_hindi_sign,
|
| 150 |
+
inputs=gr.Image(type="numpy"),
|
| 151 |
+
outputs=gr.Label(num_top_classes=3, label="Hindi Sign Classification"),
|
| 152 |
+
title="Hindi-Sign-Language-Detection",
|
| 153 |
+
description="Upload an image of a Hindi sign language hand gesture to identify the corresponding character."
|
| 154 |
+
)
|
| 155 |
+
|
| 156 |
+
if __name__ == "__main__":
|
| 157 |
+
iface.launch()
|
| 158 |
+
```
|
| 159 |
+
|
| 160 |
+
---
|
| 161 |
+
|
| 162 |
+
## Intended Use
|
| 163 |
+
|
| 164 |
+
Hindi-Sign-Language-Detection can be used in:
|
| 165 |
+
|
| 166 |
+
* Educational tools for learning Indian sign language.
|
| 167 |
+
* Assistive technology for hearing and speech-impaired individuals.
|
| 168 |
+
* Real-time sign-to-text translation applications.
|
| 169 |
+
* Human-computer interaction for Hindi users.
|