Views
No views yet

DOZE-GUARD-RLDD [Real-Time Distracted Driver Detection] is a vision-language encoder model fine-tuned from google/siglip2-base-patch16-224 for binary image classification. It is trained to detect whether a person in the image is drowsy or non-drowsy using the SiglipForImageClassification architecture.
[!note] DOZE GUARD RLDD detection works best with crisp and high-quality images. Noisy images are not recommended for validation.
[!note] SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features https://arxiv.org/pdf/2502.14786
[!note] Detection and Prediction of Driver Drowsiness for the Prevention of Road Accidents Using Deep Neural Networks Techniques https://www.researchgate.net/publication/353397807_Detection_and_Prediction_of_Driver_Drowsiness_for_the_Prevention_of_Road_Accidents_Using_Deep_Neural_Networks_Techniques
1Classification Report:
2 precision recall f1-score support
3
4 Drowsy 0.9818 0.9952 0.9885 17868
5 Non Drowsy 0.9945 0.9788 0.9866 15566
6
7 accuracy 0.9876 33434
8 macro avg 0.9881 0.9870 0.9875 33434
9weighted avg 0.9877 0.9876 0.9876 33434
Class 0: Drowsy
Class 1: Non Drowsypip install -q transformers torch pillow gradio hf_xet1import gradio as gr
2from transformers import AutoImageProcessor, SiglipForImageClassification
3from PIL import Image
4import torch
5
6# Load model and processor
7model_name = "prithivMLmods/DOZE-GUARD-RLDD" # Replace with your model path
8model = SiglipForImageClassification.from_pretrained(model_name)
9processor = AutoImageProcessor.from_pretrained(model_name)
10
11# Label mapping
12id2label = {
13 "0": "Drowsy",
14 "1": "Non Drowsy"
15}
16
17def classify_drowsiness(image):
18 image = Image.fromarray(image).convert("RGB")
19 inputs = processor(images=image, return_tensors="pt")
20
21 with torch.no_grad():
22 outputs = model(**inputs)
23 logits = outputs.logits
24 probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
25
26 prediction = {
27 id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
28 }
29
30 return prediction
31
32# Gradio Interface
33iface = gr.Interface(
34 fn=classify_drowsiness,
35 inputs=gr.Image(type="numpy"),
36 outputs=gr.Label(num_top_classes=2, label="Drowsiness Detection"),
37 title="DOZE-GUARD-RLDD",
38 description="Upload an image to classify whether the person is drowsy or non-drowsy."
39)
40
41if __name__ == "__main__":
42 iface.launch()

