prithivMLmods commited on
Commit
c54ad82
·
verified ·
1 Parent(s): 62c923d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +92 -1
README.md CHANGED
@@ -2,8 +2,25 @@
2
  license: apache-2.0
3
  datasets:
4
  - alecsharpie/nailbiting_classification
 
 
 
 
 
 
 
 
 
 
 
5
  ---
6
 
 
 
 
 
 
 
7
  ```py
8
  Classification Report:
9
  precision recall f1-score support
@@ -16,4 +33,78 @@ Classification Report:
16
  weighted avg 0.8905 0.8876 0.8881 6629
17
  ```
18
 
19
- ![download.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/SW6xjZzA7eViFsAmrmxdR.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: apache-2.0
3
  datasets:
4
  - alecsharpie/nailbiting_classification
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
+ - Nailbiting
13
+ - Human
14
+ - Behaviour
15
+ - siglip2
16
  ---
17
 
18
+ ![NB.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/rziUroDd0QVnPpXbys6zv.png)
19
+
20
+ # **NailbitingNet**
21
+
22
+ > **NailbitingNet** is a binary image classification model based on `google/siglip2-base-patch16-224`, designed to detect **nail-biting behavior** in images. Leveraging the **SiglipForImageClassification** architecture, this model is ideal for behavior monitoring, wellness applications, and human activity recognition.
23
+
24
  ```py
25
  Classification Report:
26
  precision recall f1-score support
 
33
  weighted avg 0.8905 0.8876 0.8881 6629
34
  ```
35
 
36
+ ![download.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/SW6xjZzA7eViFsAmrmxdR.png)
37
+
38
+ ---
39
+
40
+ ## **Label Classes**
41
+
42
+ The model distinguishes between:
43
+
44
+ ```
45
+ Class 0: "biting" → The person appears to be biting their nails
46
+ Class 1: "no biting" → No nail-biting behavior detected
47
+ ```
48
+
49
+ ---
50
+
51
+ ## **Installation**
52
+
53
+ ```bash
54
+ pip install transformers torch pillow gradio
55
+ ```
56
+
57
+ ---
58
+
59
+ ## **Example Inference Code**
60
+
61
+ ```python
62
+ import gradio as gr
63
+ from transformers import AutoImageProcessor, SiglipForImageClassification
64
+ from PIL import Image
65
+ import torch
66
+
67
+ # Load model and processor
68
+ model_name = "prithivMLmods/NailbitingNet"
69
+ model = SiglipForImageClassification.from_pretrained(model_name)
70
+ processor = AutoImageProcessor.from_pretrained(model_name)
71
+
72
+ # ID to label mapping
73
+ id2label = {
74
+ "0": "biting",
75
+ "1": "no biting"
76
+ }
77
+
78
+ def detect_nailbiting(image):
79
+ image = Image.fromarray(image).convert("RGB")
80
+ inputs = processor(images=image, return_tensors="pt")
81
+
82
+ with torch.no_grad():
83
+ outputs = model(**inputs)
84
+ logits = outputs.logits
85
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
86
+
87
+ prediction = {id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))}
88
+ return prediction
89
+
90
+ # Gradio Interface
91
+ iface = gr.Interface(
92
+ fn=detect_nailbiting,
93
+ inputs=gr.Image(type="numpy"),
94
+ outputs=gr.Label(num_top_classes=2, label="Nail-Biting Detection"),
95
+ title="NailbitingNet",
96
+ description="Upload an image to classify whether the person is biting their nails or not."
97
+ )
98
+
99
+ if __name__ == "__main__":
100
+ iface.launch()
101
+ ```
102
+
103
+ ---
104
+
105
+ ## **Use Cases**
106
+
107
+ * **Wellness & Habit Monitoring**
108
+ * **Behavioral AI Applications**
109
+ * **Mental Health Tools**
110
+ * **Dataset Filtering for Behavior Recognition**