VinayHajare commited on
Commit
84be6a6
·
verified ·
1 Parent(s): 75a6148

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +63 -1
README.md CHANGED
@@ -85,7 +85,69 @@ Classification Report:
85
  macro avg 0.9997 0.9997 0.9997 20040
86
  weighted avg 0.9997 0.9997 0.9997 20040
87
  ```
88
- ![result.png]()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  ## Training procedure
90
 
91
  ### Training hyperparameters
 
85
  macro avg 0.9997 0.9997 0.9997 20040
86
  weighted avg 0.9997 0.9997 0.9997 20040
87
  ```
88
+ ---
89
+
90
+ ## Install Dependencies
91
+
92
+ ```bash
93
+ pip install -q transformers torch pillow gradio
94
+ ```
95
+
96
+ ---
97
+
98
+ ## Inference Code
99
+
100
+ ```python
101
+ import gradio as gr
102
+ from transformers import AutoImageProcessor, SiglipForImageClassification
103
+ from PIL import Image
104
+ import torch
105
+
106
+ # Load model and processor
107
+ model_name = "VinayHajare/siglip2-finetuned-marathi-sign-language"
108
+ model = SiglipForImageClassification.from_pretrained(model_name)
109
+ processor = AutoImageProcessor.from_pretrained(model_name)
110
+
111
+ # Marathi label mapping
112
+ id2label = {
113
+ "0": "अ", "1": "आ", "2": "इ", "3": "ई", "4": "उ", "5": "ऊ",
114
+ "6": "ए", "7": "ऐ", "8": "ओ", "9": "औ", "10": "क", "11": "क्ष",
115
+ "12": "ख", "13": "ग", "14": "घ", "15": "च", "16": "छ", "17": "ज",
116
+ "18": "ज्ञ", "19": "झ", "20": "ट", "21": "ठ", "22": "ड", "23": "ढ",
117
+ "24": "ण", "25": "त", "26": "थ", "27": "द", "28": "ध", "29": "न",
118
+ "30": "प", "31": "फ", "32": "ब", "33": "भ", "34": "म", "35": "य",
119
+ "36": "र", "37": "ल", "38": "ळ", "39": "व", "40": "श", "41": "स", "42": "ह"
120
+ }
121
+
122
+ def classify_marathi_sign(image):
123
+ image = Image.fromarray(image).convert("RGB")
124
+ inputs = processor(images=image, return_tensors="pt")
125
+
126
+ with torch.no_grad():
127
+ outputs = model(**inputs)
128
+ logits = outputs.logits
129
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
130
+
131
+ prediction = {
132
+ id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
133
+ }
134
+
135
+ return prediction
136
+
137
+ # Gradio Interface
138
+ iface = gr.Interface(
139
+ fn=classify_marathi_sign,
140
+ inputs=gr.Image(type="numpy"),
141
+ outputs=gr.Label(num_top_classes=5, label="Marathi Sign Classification"),
142
+ title="Marathi-Sign-Language-Detection",
143
+ description="Upload an image of a Marathi sign language hand gesture to identify the corresponding character."
144
+ )
145
+
146
+ if __name__ == "__main__":
147
+ iface.launch()
148
+ ```
149
+
150
+ ---
151
  ## Training procedure
152
 
153
  ### Training hyperparameters