Views
No views yet

Alphabet-Sign-Language-Detection 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 images into sign language alphabet categories using the SiglipForImageClassification architecture.
1Classification Report:
2 precision recall f1-score support
3
4 A 0.9995 1.0000 0.9998 4384
5 B 1.0000 1.0000 1.0000 4441
6 C 1.0000 1.0000 1.0000 3993
7 D 1.0000 0.9998 0.9999 4940
8 E 1.0000 1.0000 1.0000 4658
9 F 1.0000 1.0000 1.0000 5750
10 G 0.9992 0.9996 0.9994 4978
11 H 1.0000 0.9979 0.9990 4807
12 I 0.9992 1.0000 0.9996 4856
13 J 1.0000 0.9996 0.9998 5227
14 K 0.9972 1.0000 0.9986 5426
15 L 1.0000 0.9998 0.9999 5089
16 M 1.0000 0.9964 0.9982 3328
17 N 0.9955 1.0000 0.9977 2635
18 O 0.9998 1.0000 0.9999 4564
19 P 1.0000 0.9993 0.9996 4100
20 Q 1.0000 1.0000 1.0000 4187
21 R 0.9998 0.9984 0.9991 5122
22 S 0.9998 0.9998 0.9998 5147
23 T 1.0000 1.0000 1.0000 4722
24 U 0.9984 0.9998 0.9991 5041
25 V 1.0000 0.9984 0.9992 5116
26 W 0.9998 1.0000 0.9999 4926
27 X 1.0000 0.9995 0.9998 4387
28 Y 1.0000 1.0000 1.0000 5185
29 Z 0.9996 1.0000 0.9998 4760
30
31 accuracy 0.9996 121769
32 macro avg 0.9995 0.9996 0.9995 121769
33weighted avg 0.9996 0.9996 0.9996 121769
!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/Alphabet-Sign-Language-Detection"
10model = SiglipForImageClassification.from_pretrained(model_name)
11processor = AutoImageProcessor.from_pretrained(model_name)
12
13def sign_language_classification(image):
14 """Predicts sign language alphabet category 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": "A", "1": "B", "2": "C", "3": "D", "4": "E", "5": "F", "6": "G", "7": "H", "8": "I", "9": "J",
25 "10": "K", "11": "L", "12": "M", "13": "N", "14": "O", "15": "P", "16": "Q", "17": "R", "18": "S", "19": "T",
26 "20": "U", "21": "V", "22": "W", "23": "X", "24": "Y", "25": "Z"
27 }
28 predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
29
30 return predictions
31
32# Create Gradio interface
33iface = gr.Interface(
34 fn=sign_language_classification,
35 inputs=gr.Image(type="numpy"),
36 outputs=gr.Label(label="Prediction Scores"),
37 title="Alphabet Sign Language Detection",
38 description="Upload an image to classify it into one of the 26 sign language alphabet categories."
39)
40
41# Launch the app
42if __name__ == "__main__":
43 iface.launch()