Update README.md
Browse files
README.md
CHANGED
@@ -3,6 +3,9 @@ license: apache-2.0
|
|
3 |
datasets:
|
4 |
- DamarJati/Face-Mask-Detection
|
5 |
---
|
|
|
|
|
|
|
6 |
|
7 |
```py
|
8 |
Classification Report:
|
@@ -17,3 +20,77 @@ Face_Mask Not_Found 0.9568 0.9667 0.9617 5909
|
|
17 |
```
|
18 |
|
19 |

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
datasets:
|
4 |
- DamarJati/Face-Mask-Detection
|
5 |
---
|
6 |
+
# **Face-Mask-Detection**
|
7 |
+
|
8 |
+
> **Face-Mask-Detection** is a binary image classification model based on `google/siglip2-base-patch16-224`, trained to detect whether a person is **wearing a face mask** or **not**. This model can be used in **public health monitoring**, **access control systems**, and **workplace compliance enforcement**.
|
9 |
|
10 |
```py
|
11 |
Classification Report:
|
|
|
20 |
```
|
21 |
|
22 |

|
23 |
+
|
24 |
+
---
|
25 |
+
|
26 |
+
## **Label Classes**
|
27 |
+
|
28 |
+
The model distinguishes between the following face mask statuses:
|
29 |
+
|
30 |
+
```
|
31 |
+
0: Face_Mask Found
|
32 |
+
1: Face_Mask Not_Found
|
33 |
+
```
|
34 |
+
|
35 |
+
---
|
36 |
+
|
37 |
+
## **Installation**
|
38 |
+
|
39 |
+
```bash
|
40 |
+
pip install transformers torch pillow gradio
|
41 |
+
```
|
42 |
+
|
43 |
+
---
|
44 |
+
|
45 |
+
## **Example Inference Code**
|
46 |
+
|
47 |
+
```python
|
48 |
+
import gradio as gr
|
49 |
+
from transformers import AutoImageProcessor, SiglipForImageClassification
|
50 |
+
from PIL import Image
|
51 |
+
import torch
|
52 |
+
|
53 |
+
# Load model and processor
|
54 |
+
model_name = "prithivMLmods/Face-Mask-Detection"
|
55 |
+
model = SiglipForImageClassification.from_pretrained(model_name)
|
56 |
+
processor = AutoImageProcessor.from_pretrained(model_name)
|
57 |
+
|
58 |
+
# ID to label mapping
|
59 |
+
id2label = {
|
60 |
+
"0": "Face_Mask Found",
|
61 |
+
"1": "Face_Mask Not_Found"
|
62 |
+
}
|
63 |
+
|
64 |
+
def detect_face_mask(image):
|
65 |
+
image = Image.fromarray(image).convert("RGB")
|
66 |
+
inputs = processor(images=image, return_tensors="pt")
|
67 |
+
|
68 |
+
with torch.no_grad():
|
69 |
+
outputs = model(**inputs)
|
70 |
+
logits = outputs.logits
|
71 |
+
probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
|
72 |
+
|
73 |
+
prediction = {id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))}
|
74 |
+
return prediction
|
75 |
+
|
76 |
+
# Gradio Interface
|
77 |
+
iface = gr.Interface(
|
78 |
+
fn=detect_face_mask,
|
79 |
+
inputs=gr.Image(type="numpy"),
|
80 |
+
outputs=gr.Label(num_top_classes=2, label="Mask Status"),
|
81 |
+
title="Face-Mask-Detection",
|
82 |
+
description="Upload an image to check if a person is wearing a face mask or not."
|
83 |
+
)
|
84 |
+
|
85 |
+
if __name__ == "__main__":
|
86 |
+
iface.launch()
|
87 |
+
```
|
88 |
+
|
89 |
+
---
|
90 |
+
|
91 |
+
## **Applications**
|
92 |
+
|
93 |
+
* **COVID-19 Compliance Monitoring**
|
94 |
+
* **Security and Access Control**
|
95 |
+
* **Automated Surveillance Systems**
|
96 |
+
* **Health Safety Enforcement in Public Spaces**
|