kirale2003
commited on
Commit
•
5884c5e
1
Parent(s):
bb9e25f
Upload folder using huggingface_hub
Browse files- .ipynb_checkpoints/README-checkpoint.md +396 -0
- .ipynb_checkpoints/Upload_Huggingface-checkpoint.ipynb +127 -0
- README.md +396 -3
- Upload_Huggingface.ipynb +127 -0
- erax-anti-nsfw-yolo11m-v1.1.pt +3 -0
- erax-anti-nsfw-yolo11n-v1.1.pt +3 -0
- erax-anti-nsfw-yolo11s-v1.1.pt +3 -0
- examples/img_1.jpg +0 -0
- examples/img_2.jpg +0 -0
- examples/img_2_make_love.jpg +0 -0
- examples/img_3.jpg +0 -0
- examples/img_4.jpg +0 -0
- examples/img_4_make_love.jpg +0 -0
- examples/img_4make_love.jpg +0 -0
- examples/img_5.jpg +0 -0
- examples/img_5_make_love.jpg +0 -0
- examples/img_6.jpg +0 -0
- test_images/img_1.jpg +0 -0
- test_images/img_2.jpg +0 -0
- train_result/erax-anti-nsfw-yolo11m-v1.1/F1_curve.png +0 -0
- train_result/erax-anti-nsfw-yolo11m-v1.1/PR_curve.png +0 -0
- train_result/erax-anti-nsfw-yolo11m-v1.1/P_curve.png +0 -0
- train_result/erax-anti-nsfw-yolo11m-v1.1/R_curve.png +0 -0
- train_result/erax-anti-nsfw-yolo11m-v1.1/confusion_matrix_normalized.png +0 -0
- train_result/erax-anti-nsfw-yolo11m-v1.1/labels.jpg +0 -0
- train_result/erax-anti-nsfw-yolo11m-v1.1/results.png +0 -0
- train_result/erax-anti-nsfw-yolo11n-v1.1/.ipynb_checkpoints/F1_curve-checkpoint.png +0 -0
- train_result/erax-anti-nsfw-yolo11n-v1.1/.ipynb_checkpoints/confusion_matrix_normalized-checkpoint.png +0 -0
- train_result/erax-anti-nsfw-yolo11n-v1.1/.ipynb_checkpoints/labels-checkpoint.jpg +0 -0
- train_result/erax-anti-nsfw-yolo11n-v1.1/.ipynb_checkpoints/results-checkpoint.png +0 -0
- train_result/erax-anti-nsfw-yolo11n-v1.1/F1_curve.png +0 -0
- train_result/erax-anti-nsfw-yolo11n-v1.1/PR_curve.png +0 -0
- train_result/erax-anti-nsfw-yolo11n-v1.1/P_curve.png +0 -0
- train_result/erax-anti-nsfw-yolo11n-v1.1/R_curve.png +0 -0
- train_result/erax-anti-nsfw-yolo11n-v1.1/confusion_matrix_normalized.png +0 -0
- train_result/erax-anti-nsfw-yolo11n-v1.1/labels.jpg +0 -0
- train_result/erax-anti-nsfw-yolo11n-v1.1/results.png +0 -0
- train_result/erax-anti-nsfw-yolo11s-v1.1/.ipynb_checkpoints/labels-checkpoint.jpg +0 -0
- train_result/erax-anti-nsfw-yolo11s-v1.1/F1_curve.png +0 -0
- train_result/erax-anti-nsfw-yolo11s-v1.1/PR_curve.png +0 -0
- train_result/erax-anti-nsfw-yolo11s-v1.1/P_curve.png +0 -0
- train_result/erax-anti-nsfw-yolo11s-v1.1/R_curve.png +0 -0
- train_result/erax-anti-nsfw-yolo11s-v1.1/confusion_matrix_normalized.png +0 -0
- train_result/erax-anti-nsfw-yolo11s-v1.1/labels.jpg +0 -0
- train_result/erax-anti-nsfw-yolo11s-v1.1/results.png +0 -0
.ipynb_checkpoints/README-checkpoint.md
ADDED
@@ -0,0 +1,396 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
language:
|
4 |
+
- en
|
5 |
+
base_model:
|
6 |
+
- Ultralytics/YOLO11
|
7 |
+
tags:
|
8 |
+
- yolo
|
9 |
+
- yolo11
|
10 |
+
- nsfw
|
11 |
+
pipeline_tag: object-detection
|
12 |
+
---
|
13 |
+
|
14 |
+
<p align="center">
|
15 |
+
<img src="https://cdn-uploads.huggingface.co/production/uploads/63d8d8879dfcfa941d4d7cd9/myOju5oXm0Xq_EgVpYsvo.png" alt="Logo">
|
16 |
+
</p>
|
17 |
+
|
18 |
+
<h1 style="color:red" style="text-align:center;">
|
19 |
+
🔞 WARNING: SENSITIVE CONTENT 🔞
|
20 |
+
</h1>
|
21 |
+
|
22 |
+
<h2>
|
23 |
+
THIS MEDIA CONTAINS SENSITIVE CONTENT (I.E. NUDITY, VIOLENCE, PROFANITY, PORN) THAT SOME PEOPLE MAY FIND OFFENSIVE. YOU MUST BE 18 OR OLDER TO VIEW THIS CONTENT.
|
24 |
+
</h2>
|
25 |
+
|
26 |
+
----------
|
27 |
+
# EraX-NSFW-V1.0
|
28 |
+
A Highly Efficient Model for NSFW Detection. Very effective for **pre-publication image and video control**, or for **limiting children's access to harmful publications**.
|
29 |
+
You can either just predict the classes and their boundingboxes or even mask the predicted harmful object(s) or mask the entire image.
|
30 |
+
Please see the deployment codes below.
|
31 |
+
|
32 |
+
- **Developed by**:
|
33 |
+
- Phạm Đình Thục (thuc.pd@erax.ai)
|
34 |
+
- Mr. Nguyễn Anh Nguyên (nguyen@erax.ai)
|
35 |
+
- **Model version**: v1.0
|
36 |
+
- **License**: Apache 2.0
|
37 |
+
|
38 |
+
<!-- ## Examples
|
39 |
+
![Example 01](./examples/img_1.jpg) -->
|
40 |
+
|
41 |
+
## Model Details / Overview
|
42 |
+
|
43 |
+
- **Model Architecture**: YOLO11 (nano, small, medium)
|
44 |
+
- **Task**: Object Detection (NSFW Detection)
|
45 |
+
- **Dataset**: Private datasets (from Internet).
|
46 |
+
- **Training set**: 31890 images.
|
47 |
+
- **Validation set**: 11538 images.
|
48 |
+
- **Classes**: anus, make_love, nipple, penis, vagina.
|
49 |
+
|
50 |
+
### Labels
|
51 |
+
![Labels](./train/labels.jpeg)
|
52 |
+
|
53 |
+
## Training Configuration
|
54 |
+
- **Model Weights Files**:
|
55 |
+
- Nano: [`erax_nsfw_yolo11n.pt`](./erax_nsfw_yolo11n.pt)
|
56 |
+
- Small: [`erax_nsfw_yolo11s.pt`](./erax_nsfw_yolo11s.pt)
|
57 |
+
- Medium: [`erax_nsfw_yolo11m.pt`](./erax_nsfw_yolo11m.pt)
|
58 |
+
- **Number of Epochs**: 100
|
59 |
+
- **Learning Rate**: 0.01
|
60 |
+
- **Batch Size**: 208
|
61 |
+
- **Image Size**: 640x640
|
62 |
+
- **Training server**: 8 x NVIDIA RTX A4000 (16GB GDDR6)
|
63 |
+
- **Training time**: ~10 hours
|
64 |
+
|
65 |
+
|
66 |
+
## Evaluation Metrics
|
67 |
+
Below are the key metrics from the model evaluation on the validation set:
|
68 |
+
comming soon
|
69 |
+
<!--
|
70 |
+
- **Precision**: 0.726
|
71 |
+
- **Recall**: 0.68
|
72 |
+
- **mAP50**: 0.724
|
73 |
+
- **mAP50-95**: 0.434 -->
|
74 |
+
|
75 |
+
<!-- | Format | Status | Size (MB) | metrics/mAP50-95(B) | Inference time (ms/im) | FPS |
|
76 |
+
|:-----------------------|:-------|:-----------|:----------------------|:------------------------|:--------|
|
77 |
+
| PyTorch | ✅ | 38.6 | 0.4332 | 16.97 | 58.91 |
|
78 |
+
|TorchScript | ✅ | 77 | 0.4153 | 12.09 | 82.69 |
|
79 |
+
| ONNX | ✅ | 76.7 | 0.4153 | 103.94 | 9.62 |
|
80 |
+
| OpenVINO | ❌ | - | - | - | - |
|
81 |
+
| TensorRT | ✅ | 89.6 | 0.4155 | 7 | 142.92 |
|
82 |
+
| CoreML | ❌ | - | - | - | - |
|
83 |
+
| TensorFlow SavedModel | ✅ | 192.3 | 0.4153 | 40.19 | 24.88 |
|
84 |
+
| TensorFlow GraphDef | ✅ | 76.8 | 0.4153 | 36.71 | 27.24 |
|
85 |
+
| TensorFlow Lite | ❌ | - | - | - | - |
|
86 |
+
| TensorFlow Edge TPU | ❌ | - | - | - | - |
|
87 |
+
| TensorFlow.js | ❌ | - | - | - | - |
|
88 |
+
| PaddlePaddle | ✅ | 153.3 | 0.4153 | 1024.24 | 0.98 |
|
89 |
+
| NCNN | ✅ | 76.6 | 0.4153 | 187.36 | 5.34 | -->
|
90 |
+
|
91 |
+
|
92 |
+
|
93 |
+
<!-- <table>
|
94 |
+
<thead>
|
95 |
+
<tr>
|
96 |
+
<th>Format</th>
|
97 |
+
<th width="200">Model</th>
|
98 |
+
<th width="100">Size (MB)</th>
|
99 |
+
<th>metrics/mAP50-95(B)</th>
|
100 |
+
<th>Inference time (ms/im)</th>
|
101 |
+
<th width="100">FPS</th>
|
102 |
+
</tr>
|
103 |
+
</thead>
|
104 |
+
<tbody>
|
105 |
+
<tr>
|
106 |
+
<th rowspan=3>PyTorch</th>
|
107 |
+
<th>erax_nsfw_yolo11n.pt</th>
|
108 |
+
<th>5.20</th>
|
109 |
+
<th>0.3563</th>
|
110 |
+
<th>160.17</th>
|
111 |
+
<th>6</th>
|
112 |
+
</tr>
|
113 |
+
<tr>
|
114 |
+
<th>erax_nsfw_yolo11s.pt</th>
|
115 |
+
<th>18.30</th>
|
116 |
+
<th>0.4083</th>
|
117 |
+
<th>10.12</th>
|
118 |
+
<th>99</th>
|
119 |
+
</tr>
|
120 |
+
<tr>
|
121 |
+
<th>erax_nsfw_yolo11m.pt</th>
|
122 |
+
<th>38.60</th>
|
123 |
+
<th>0.4332</th>
|
124 |
+
<th>12.04</th>
|
125 |
+
<th>83</th>
|
126 |
+
</tr>
|
127 |
+
<tr>
|
128 |
+
<th rowspan=3>TorchScript</th>
|
129 |
+
<th>erax_nsfw_yolo11n.pt</th>
|
130 |
+
<th>10.40</th>
|
131 |
+
<th>0.3427</th>
|
132 |
+
<th>75.11</th>
|
133 |
+
<th>13</th>
|
134 |
+
</tr>
|
135 |
+
<tr>
|
136 |
+
<th>erax_nsfw_yolo11s.pt</th>
|
137 |
+
<th>36.40</th>
|
138 |
+
<th>0.3918</th>
|
139 |
+
<th>4.40</th>
|
140 |
+
<th>227</th>
|
141 |
+
</tr>
|
142 |
+
<tr>
|
143 |
+
<th>erax_nsfw_yolo11m.pt</th>
|
144 |
+
<th>77.00</th>
|
145 |
+
<th>0.4153</th>
|
146 |
+
<th>6.32</th>
|
147 |
+
<th>158</th>
|
148 |
+
</tr>
|
149 |
+
<tr>
|
150 |
+
<th rowspan=3>ONNX</th>
|
151 |
+
<th>erax_nsfw_yolo11n.pt</th>
|
152 |
+
<th>10.10</th>
|
153 |
+
<th>0.3427</th>
|
154 |
+
<th>154.94</th>
|
155 |
+
<th>6</th>
|
156 |
+
</tr>
|
157 |
+
<tr>
|
158 |
+
<th>erax_nsfw_yolo11s.pt</th>
|
159 |
+
<th>36.20</th>
|
160 |
+
<th>0.3918</th>
|
161 |
+
<th>9.82</th>
|
162 |
+
<th>102</th>
|
163 |
+
</tr>
|
164 |
+
<tr>
|
165 |
+
<th>erax_nsfw_yolo11m.pt</th>
|
166 |
+
<th>76.70</th>
|
167 |
+
<th>0.4153</th>
|
168 |
+
<th>16.38</th>
|
169 |
+
<th>61</th>
|
170 |
+
</tr>
|
171 |
+
<tr>
|
172 |
+
<th rowspan=3>TensorRT</th>
|
173 |
+
<th>erax_nsfw_yolo11n.pt</th>
|
174 |
+
<th>15.60</th>
|
175 |
+
<th>0.3426</th>
|
176 |
+
<th>6.25</th>
|
177 |
+
<th>160</th>
|
178 |
+
</tr>
|
179 |
+
<tr>
|
180 |
+
<th>erax_nsfw_yolo11s.pt</th>
|
181 |
+
<th>47.30</th>
|
182 |
+
<th>0.3918</th>
|
183 |
+
<th>2.62</th>
|
184 |
+
<th>381</th>
|
185 |
+
</tr>
|
186 |
+
<tr>
|
187 |
+
<th>erax_nsfw_yolo11m.pt</th>
|
188 |
+
<th>92.70</th>
|
189 |
+
<th>0.4154</th>
|
190 |
+
<th>4.94</th>
|
191 |
+
<th>202</th>
|
192 |
+
</tr>
|
193 |
+
<tr>
|
194 |
+
<th rowspan=3>TensorFlow SavedModel</th>
|
195 |
+
<th>erax_nsfw_yolo11n.pt</th>
|
196 |
+
<th>25.90</th>
|
197 |
+
<th>0.3427</th>
|
198 |
+
<th>27.35</th>
|
199 |
+
<th>37</th>
|
200 |
+
</tr>
|
201 |
+
<tr>
|
202 |
+
<th>erax_nsfw_yolo11s.pt</th>
|
203 |
+
<th>93.30</th>
|
204 |
+
<th>0.3918</th>
|
205 |
+
<th>33.82</th>
|
206 |
+
<th>30</th>
|
207 |
+
</tr>
|
208 |
+
<tr>
|
209 |
+
<th>erax_nsfw_yolo11m.pt</th>
|
210 |
+
<th>193.40</th>
|
211 |
+
<th>0.4153</th>
|
212 |
+
<th>34.29</th>
|
213 |
+
<th>29</th>
|
214 |
+
</tr>
|
215 |
+
<tr>
|
216 |
+
<th rowspan=3>TensorFlow GraphDef</th>
|
217 |
+
<th>erax_nsfw_yolo11n.pt</th>
|
218 |
+
<th>10.20</th>
|
219 |
+
<th>0.3427</th>
|
220 |
+
<th>26.58</th>
|
221 |
+
<th>38</th>
|
222 |
+
</tr>
|
223 |
+
<tr>
|
224 |
+
<th>erax_nsfw_yolo11s.pt</th>
|
225 |
+
<th>36.30</th>
|
226 |
+
<th>0.3918</th>
|
227 |
+
<th>31.84</th>
|
228 |
+
<th>31</th>
|
229 |
+
</tr>
|
230 |
+
<tr>
|
231 |
+
<th>erax_nsfw_yolo11m.pt</th>
|
232 |
+
<th>76.80</th>
|
233 |
+
<th>0.4153</th>
|
234 |
+
<th>31.83</th>
|
235 |
+
<th>31</th>
|
236 |
+
</tr>
|
237 |
+
<tr>
|
238 |
+
<th rowspan=3>PaddlePaddle</th>
|
239 |
+
<th>erax_nsfw_yolo11n.pt</th>
|
240 |
+
<th>20.10</th>
|
241 |
+
<th>0.3427</th>
|
242 |
+
<th>264.66</th>
|
243 |
+
<th>4</th>
|
244 |
+
</tr>
|
245 |
+
<tr>
|
246 |
+
<th>erax_nsfw_yolo11s.pt</th>
|
247 |
+
<th>72.30</th>
|
248 |
+
<th>0.3918</th>
|
249 |
+
<th>453.69</th>
|
250 |
+
<th>2</th>
|
251 |
+
</tr>
|
252 |
+
<tr>
|
253 |
+
<th>erax_nsfw_yolo11m.pt</th>
|
254 |
+
<th>153.30</th>
|
255 |
+
<th>0.4153</th>
|
256 |
+
<th>2519.82</th>
|
257 |
+
<th>0</th>
|
258 |
+
</tr>
|
259 |
+
</tbody>
|
260 |
+
<tr>
|
261 |
+
<th rowspan=3>NCNN</th>
|
262 |
+
<th>erax_nsfw_yolo11n.pt</th>
|
263 |
+
<th>10.00</th>
|
264 |
+
<th>0.3427</th>
|
265 |
+
<th>893.43</th>
|
266 |
+
<th>1</th>
|
267 |
+
</tr>
|
268 |
+
<tr>
|
269 |
+
<th>erax_nsfw_yolo11s.pt</th>
|
270 |
+
<th>36.10</th>
|
271 |
+
<th>0.3918</th>
|
272 |
+
<th>1418.91</th>
|
273 |
+
<th>1</th>
|
274 |
+
</tr>
|
275 |
+
<tr>
|
276 |
+
<th>erax_nsfw_yolo11m.pt</th>
|
277 |
+
<th>76.60</th>
|
278 |
+
<th>0.4153</th>
|
279 |
+
<th>2647.62</th>
|
280 |
+
<th>0</th>
|
281 |
+
</tr>
|
282 |
+
</table>
|
283 |
+
-->
|
284 |
+
|
285 |
+
## Training Validation Results
|
286 |
+
### Training and Validation Losses
|
287 |
+
![Training and Validation Losses](./train/results.png)
|
288 |
+
|
289 |
+
### Confusion Matrix
|
290 |
+
![Confusion Matrix](./train/confusion_matrix_normalized.png)
|
291 |
+
|
292 |
+
|
293 |
+
## Inference
|
294 |
+
|
295 |
+
To use the trained model, follow these steps:
|
296 |
+
|
297 |
+
1. **Install the necessary packages**:
|
298 |
+
```curl
|
299 |
+
pip install ultralytics supervision huggingface-hub
|
300 |
+
```
|
301 |
+
|
302 |
+
2. **Download Pretrained model**:
|
303 |
+
```python
|
304 |
+
from huggingface_hub import snapshot_download
|
305 |
+
snapshot_download(repo_id="erax-ai/EraX-NSFW-V1.0", local_dir="./", force_download=True)
|
306 |
+
```
|
307 |
+
|
308 |
+
3. **Simple Use Case**:
|
309 |
+
```python
|
310 |
+
from ultralytics import YOLO
|
311 |
+
from PIL import Image
|
312 |
+
import supervision as sv
|
313 |
+
import numpy as np
|
314 |
+
|
315 |
+
IOU_THRESHOLD = 0.3
|
316 |
+
CONFIDENCE_THRESHOLD = 0.2
|
317 |
+
|
318 |
+
# pretrained_path = "erax_nsfw_yolo11n.pt"
|
319 |
+
# pretrained_path = "erax_nsfw_yolo11s.pt"
|
320 |
+
pretrained_path = "erax_nsfw_yolo11m.pt"
|
321 |
+
|
322 |
+
image_path_list = ["test_images/img_1.jpg", "test_images/img_2.jpg"]
|
323 |
+
|
324 |
+
model = YOLO(pretrained_path)
|
325 |
+
results = model(image_path_list,
|
326 |
+
conf=CONFIDENCE_THRESHOLD,
|
327 |
+
iou=IOU_THRESHOLD
|
328 |
+
)
|
329 |
+
|
330 |
+
|
331 |
+
for result in results:
|
332 |
+
annotated_image = result.orig_img.copy()
|
333 |
+
h, w = annotated_image.shape[:2]
|
334 |
+
anchor = h if h > w else w
|
335 |
+
|
336 |
+
detections = sv.Detections.from_ultralytics(result)
|
337 |
+
label_annotator = sv.LabelAnnotator(text_color=sv.Color.BLACK,
|
338 |
+
text_position=sv.Position.CENTER,
|
339 |
+
text_scale=anchor/1700)
|
340 |
+
|
341 |
+
pixelate_annotator = sv.PixelateAnnotator(pixel_size=anchor/50)
|
342 |
+
|
343 |
+
annotated_image = pixelate_annotator.annotate(
|
344 |
+
scene=annotated_image.copy(),
|
345 |
+
detections=detections
|
346 |
+
)
|
347 |
+
|
348 |
+
|
349 |
+
annotated_image = label_annotator.annotate(
|
350 |
+
annotated_image,
|
351 |
+
detections=detections
|
352 |
+
)
|
353 |
+
|
354 |
+
|
355 |
+
sv.plot_image(annotated_image, size=(10, 10))
|
356 |
+
```
|
357 |
+
|
358 |
+
## Training
|
359 |
+
Scripts for training: https://github.com/EraX-JS-Company/EraX-NSFW-V1.0
|
360 |
+
|
361 |
+
## More examples
|
362 |
+
|
363 |
+
1. **Example 01**:
|
364 |
+
![Example 03](./examples/img_3.jpg)
|
365 |
+
|
366 |
+
|
367 |
+
2. **Example 02**:
|
368 |
+
![Example 06](./examples/img_6.jpg)
|
369 |
+
|
370 |
+
|
371 |
+
3. **Example 03**: SAFEEST for using make_love class as it will cover entire context.
|
372 |
+
Without make_love class | With make_love class
|
373 |
+
:-------------------------:|:-------------------------:
|
374 |
+
![](./examples/img_2.jpg) | ![](./examples/img_2_make_love.jpg)
|
375 |
+
![](./examples/img_4.jpg) | ![](./examples/img_4_make_love.jpg)
|
376 |
+
![](./examples/img_5.jpg) | ![](./examples/img_5_make_love.jpg)
|
377 |
+
|
378 |
+
|
379 |
+
|
380 |
+
## Citation
|
381 |
+
If you find our project useful, we would appreciate it if you could star our repository and cite our work as follows:
|
382 |
+
```bibtex
|
383 |
+
@article{EraX-NSFW-V1.0,
|
384 |
+
author = {Phạm Đình Thục and
|
385 |
+
Mr. Nguyễn Anh Nguyên and
|
386 |
+
Đoàn Thành Khang and
|
387 |
+
Mr. Trần Hải Khương and
|
388 |
+
Mr. Trương Công Đức and
|
389 |
+
Phan Nguyễn Tuấn Kha and
|
390 |
+
Phạm Huỳnh Nhật},
|
391 |
+
title = {EraX-NSFW-V1.0: A Highly Efficient Model for NSFW Detection},
|
392 |
+
organization={EraX JS Company},
|
393 |
+
year={2024},
|
394 |
+
url={https://huggingface.co/erax-ai/EraX-NSFW-V1.0}
|
395 |
+
}
|
396 |
+
```
|
.ipynb_checkpoints/Upload_Huggingface-checkpoint.ipynb
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 11,
|
6 |
+
"id": "9a35dbb2-4482-4155-86ca-c12a0a56ba7d",
|
7 |
+
"metadata": {
|
8 |
+
"scrolled": true
|
9 |
+
},
|
10 |
+
"outputs": [
|
11 |
+
{
|
12 |
+
"data": {
|
13 |
+
"text/plain": [
|
14 |
+
"CommitInfo(commit_url='https://huggingface.co/erax-ai/EraX-NSFW-V1.1/commit/2006614e6e27495bf5e48181a63ab8c666850cc4', commit_message='Upload README.md with huggingface_hub', commit_description='', oid='2006614e6e27495bf5e48181a63ab8c666850cc4', pr_url=None, repo_url=RepoUrl('https://huggingface.co/erax-ai/EraX-NSFW-V1.1', endpoint='https://huggingface.co', repo_type='model', repo_id='erax-ai/EraX-NSFW-V1.1'), pr_revision=None, pr_num=None)"
|
15 |
+
]
|
16 |
+
},
|
17 |
+
"execution_count": 11,
|
18 |
+
"metadata": {},
|
19 |
+
"output_type": "execute_result"
|
20 |
+
}
|
21 |
+
],
|
22 |
+
"source": [
|
23 |
+
"from huggingface_hub import HfApi\n",
|
24 |
+
"api = HfApi()\n",
|
25 |
+
"api.upload_file(\n",
|
26 |
+
" path_or_fileobj=\"/home/workspace/lechitai/Anti-NSFW/EraX-Anti-NSFW-V1.1/README.md\",\n",
|
27 |
+
" path_in_repo=\"README.md\",\n",
|
28 |
+
" repo_id=\"erax-ai/EraX-NSFW-V1.1\",\n",
|
29 |
+
" repo_type=\"model\",\n",
|
30 |
+
" token=\"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\",\n",
|
31 |
+
")"
|
32 |
+
]
|
33 |
+
},
|
34 |
+
{
|
35 |
+
"cell_type": "code",
|
36 |
+
"execution_count": 14,
|
37 |
+
"id": "cbbcd852-16ca-432c-a299-624f0921f51e",
|
38 |
+
"metadata": {},
|
39 |
+
"outputs": [
|
40 |
+
{
|
41 |
+
"ename": "BadRequestError",
|
42 |
+
"evalue": "(Request ID: Root=1-67655840-0814ae860340e8820ada95d5;e670748b-fb79-4a7c-838e-f5f39b39c133)\n\nBad request for commit endpoint:\nIt appears that one or more of your files contain valid Hugging Face secrets, such as tokens or API keys. It is important to keep your secrets private and not expose them in code that is publicly accessible. Read more: https://huggingface.co/docs/hub/spaces-overview#managing-secrets Offending files: - .ipynb_checkpoints/Upload_Huggingface-checkpoint.ipynb (ref: refs/heads/main, token: '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') - .ipynb_checkpoints/Upload_Huggingface-checkpoint.ipynb (ref: refs/heads/main, token: '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')\nIt appears that one or more of your files contain valid Hugging Face secrets, such as tokens or API keys. It is important to keep your secrets private and not expose them in code that is publicly accessible. Read more: https://huggingface.co/docs/hub/spaces-overview#managing-secrets Offending files: - .ipynb_checkpoints/Upload_Huggingface-checkpoint.ipynb (ref: refs/heads/main, token: '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') - .ipynb_checkpoints/Upload_Huggingface-checkpoint.ipynb (ref: refs/heads/main, token: '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')",
|
43 |
+
"output_type": "error",
|
44 |
+
"traceback": [
|
45 |
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
46 |
+
"\u001b[0;31mHTTPError\u001b[0m Traceback (most recent call last)",
|
47 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_http.py:406\u001b[0m, in \u001b[0;36mhf_raise_for_status\u001b[0;34m(response, endpoint_name)\u001b[0m\n\u001b[1;32m 405\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 406\u001b[0m \u001b[43mresponse\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 407\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m HTTPError \u001b[38;5;28;01mas\u001b[39;00m e:\n",
|
48 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/requests/models.py:1024\u001b[0m, in \u001b[0;36mResponse.raise_for_status\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 1023\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[0;32m-> 1024\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m)\n",
|
49 |
+
"\u001b[0;31mHTTPError\u001b[0m: 400 Client Error: Bad Request for url: https://huggingface.co/api/models/erax-ai/EraX-NSFW-V1.1/commit/main",
|
50 |
+
"\nThe above exception was the direct cause of the following exception:\n",
|
51 |
+
"\u001b[0;31mBadRequestError\u001b[0m Traceback (most recent call last)",
|
52 |
+
"Cell \u001b[0;32mIn[14], line 4\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mhuggingface_hub\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m HfApi\n\u001b[1;32m 2\u001b[0m api \u001b[38;5;241m=\u001b[39m HfApi()\n\u001b[0;32m----> 4\u001b[0m \u001b[43mapi\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mupload_folder\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 5\u001b[0m \u001b[43m \u001b[49m\u001b[43mfolder_path\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m/home/workspace/lechitai/Anti-NSFW/EraX-Anti-NSFW-V1.1\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 6\u001b[0m \u001b[43m \u001b[49m\u001b[43mrepo_id\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43merax-ai/EraX-NSFW-V1.1\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 7\u001b[0m \u001b[43m \u001b[49m\u001b[43mrepo_type\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmodel\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 8\u001b[0m \u001b[43m \u001b[49m\u001b[43mtoken\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhf_UvzfLMvFhPizsWmSPrYqIsAPFLYHDpGbZn\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 9\u001b[0m \u001b[43m)\u001b[49m\n",
|
53 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_validators.py:114\u001b[0m, in \u001b[0;36mvalidate_hf_hub_args.<locals>._inner_fn\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 111\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m check_use_auth_token:\n\u001b[1;32m 112\u001b[0m kwargs \u001b[38;5;241m=\u001b[39m smoothly_deprecate_use_auth_token(fn_name\u001b[38;5;241m=\u001b[39mfn\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m, has_token\u001b[38;5;241m=\u001b[39mhas_token, kwargs\u001b[38;5;241m=\u001b[39mkwargs)\n\u001b[0;32m--> 114\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
|
54 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/huggingface_hub/hf_api.py:1559\u001b[0m, in \u001b[0;36mfuture_compatible.<locals>._inner\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1556\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mrun_as_future(fn, \u001b[38;5;28mself\u001b[39m, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m 1558\u001b[0m \u001b[38;5;66;03m# Otherwise, call the function normally\u001b[39;00m\n\u001b[0;32m-> 1559\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
|
55 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/huggingface_hub/hf_api.py:5105\u001b[0m, in \u001b[0;36mHfApi.upload_folder\u001b[0;34m(self, repo_id, folder_path, path_in_repo, commit_message, commit_description, token, repo_type, revision, create_pr, parent_commit, allow_patterns, ignore_patterns, delete_patterns, multi_commits, multi_commits_verbose, run_as_future)\u001b[0m\n\u001b[1;32m 5101\u001b[0m \u001b[38;5;66;03m# Defining a CommitInfo object is not really relevant in this case\u001b[39;00m\n\u001b[1;32m 5102\u001b[0m \u001b[38;5;66;03m# Let's return early with pr_url only (as string).\u001b[39;00m\n\u001b[1;32m 5103\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m pr_url\n\u001b[0;32m-> 5105\u001b[0m commit_info \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcreate_commit\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 5106\u001b[0m \u001b[43m \u001b[49m\u001b[43mrepo_type\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrepo_type\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 5107\u001b[0m \u001b[43m \u001b[49m\u001b[43mrepo_id\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrepo_id\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 5108\u001b[0m \u001b[43m \u001b[49m\u001b[43moperations\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcommit_operations\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 5109\u001b[0m \u001b[43m \u001b[49m\u001b[43mcommit_message\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcommit_message\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 5110\u001b[0m \u001b[43m \u001b[49m\u001b[43mcommit_description\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcommit_description\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 5111\u001b[0m \u001b[43m \u001b[49m\u001b[43mtoken\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtoken\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 5112\u001b[0m \u001b[43m \u001b[49m\u001b[43mrevision\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrevision\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 5113\u001b[0m \u001b[43m \u001b[49m\u001b[43mcreate_pr\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcreate_pr\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 5114\u001b[0m \u001b[43m \u001b[49m\u001b[43mparent_commit\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mparent_commit\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 5115\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 5117\u001b[0m \u001b[38;5;66;03m# Create url to uploaded folder (for legacy return value)\u001b[39;00m\n\u001b[1;32m 5118\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m create_pr \u001b[38;5;129;01mand\u001b[39;00m commit_info\u001b[38;5;241m.\u001b[39mpr_url \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n",
|
56 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_validators.py:114\u001b[0m, in \u001b[0;36mvalidate_hf_hub_args.<locals>._inner_fn\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 111\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m check_use_auth_token:\n\u001b[1;32m 112\u001b[0m kwargs \u001b[38;5;241m=\u001b[39m smoothly_deprecate_use_auth_token(fn_name\u001b[38;5;241m=\u001b[39mfn\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m, has_token\u001b[38;5;241m=\u001b[39mhas_token, kwargs\u001b[38;5;241m=\u001b[39mkwargs)\n\u001b[0;32m--> 114\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
|
57 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/huggingface_hub/hf_api.py:1559\u001b[0m, in \u001b[0;36mfuture_compatible.<locals>._inner\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1556\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mrun_as_future(fn, \u001b[38;5;28mself\u001b[39m, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m 1558\u001b[0m \u001b[38;5;66;03m# Otherwise, call the function normally\u001b[39;00m\n\u001b[0;32m-> 1559\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
|
58 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/huggingface_hub/hf_api.py:4093\u001b[0m, in \u001b[0;36mHfApi.create_commit\u001b[0;34m(self, repo_id, operations, commit_message, commit_description, token, repo_type, revision, create_pr, num_threads, parent_commit, run_as_future)\u001b[0m\n\u001b[1;32m 4091\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 4092\u001b[0m commit_resp \u001b[38;5;241m=\u001b[39m get_session()\u001b[38;5;241m.\u001b[39mpost(url\u001b[38;5;241m=\u001b[39mcommit_url, headers\u001b[38;5;241m=\u001b[39mheaders, data\u001b[38;5;241m=\u001b[39mdata, params\u001b[38;5;241m=\u001b[39mparams)\n\u001b[0;32m-> 4093\u001b[0m \u001b[43mhf_raise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcommit_resp\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mendpoint_name\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mcommit\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 4094\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m RepositoryNotFoundError \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m 4095\u001b[0m e\u001b[38;5;241m.\u001b[39mappend_to_message(_CREATE_COMMIT_NO_REPO_ERROR_MESSAGE)\n",
|
59 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_http.py:460\u001b[0m, in \u001b[0;36mhf_raise_for_status\u001b[0;34m(response, endpoint_name)\u001b[0m\n\u001b[1;32m 456\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m response\u001b[38;5;241m.\u001b[39mstatus_code \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m400\u001b[39m:\n\u001b[1;32m 457\u001b[0m message \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m 458\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124mBad request for \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mendpoint_name\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m endpoint:\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m endpoint_name \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124mBad request:\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 459\u001b[0m )\n\u001b[0;32m--> 460\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m _format(BadRequestError, message, response) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01me\u001b[39;00m\n\u001b[1;32m 462\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m response\u001b[38;5;241m.\u001b[39mstatus_code \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m403\u001b[39m:\n\u001b[1;32m 463\u001b[0m message \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m 464\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;132;01m{\u001b[39;00mresponse\u001b[38;5;241m.\u001b[39mstatus_code\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m Forbidden: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00merror_message\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 465\u001b[0m \u001b[38;5;241m+\u001b[39m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124mCannot access content at: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse\u001b[38;5;241m.\u001b[39murl\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 466\u001b[0m \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124mMake sure your token has the correct permissions.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 467\u001b[0m )\n",
|
60 |
+
"\u001b[0;31mBadRequestError\u001b[0m: (Request ID: Root=1-67655840-0814ae860340e8820ada95d5;e670748b-fb79-4a7c-838e-f5f39b39c133)\n\nBad request for commit endpoint:\nIt appears that one or more of your files contain valid Hugging Face secrets, such as tokens or API keys. It is important to keep your secrets private and not expose them in code that is publicly accessible. Read more: https://huggingface.co/docs/hub/spaces-overview#managing-secrets Offending files: - .ipynb_checkpoints/Upload_Huggingface-checkpoint.ipynb (ref: refs/heads/main, token: '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') - .ipynb_checkpoints/Upload_Huggingface-checkpoint.ipynb (ref: refs/heads/main, token: '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')\nIt appears that one or more of your files contain valid Hugging Face secrets, such as tokens or API keys. It is important to keep your secrets private and not expose them in code that is publicly accessible. Read more: https://huggingface.co/docs/hub/spaces-overview#managing-secrets Offending files: - .ipynb_checkpoints/Upload_Huggingface-checkpoint.ipynb (ref: refs/heads/main, token: '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') - .ipynb_checkpoints/Upload_Huggingface-checkpoint.ipynb (ref: refs/heads/main, token: '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')"
|
61 |
+
]
|
62 |
+
}
|
63 |
+
],
|
64 |
+
"source": [
|
65 |
+
"from huggingface_hub import HfApi\n",
|
66 |
+
"api = HfApi()\n",
|
67 |
+
"\n",
|
68 |
+
"api.upload_folder(\n",
|
69 |
+
" folder_path=\"/home/workspace/lechitai/Anti-NSFW/EraX-Anti-NSFW-V1.1\",\n",
|
70 |
+
" repo_id=\"erax-ai/EraX-NSFW-V1.1\",\n",
|
71 |
+
" repo_type=\"model\",\n",
|
72 |
+
" token=\"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\",\n",
|
73 |
+
")"
|
74 |
+
]
|
75 |
+
},
|
76 |
+
{
|
77 |
+
"cell_type": "code",
|
78 |
+
"execution_count": 3,
|
79 |
+
"id": "1aefb2bf-4f5e-4a4f-867e-3401483fd976",
|
80 |
+
"metadata": {},
|
81 |
+
"outputs": [
|
82 |
+
{
|
83 |
+
"data": {
|
84 |
+
"text/plain": [
|
85 |
+
"'/home/workspace/lechitai/Anti-NSFW'"
|
86 |
+
]
|
87 |
+
},
|
88 |
+
"execution_count": 3,
|
89 |
+
"metadata": {},
|
90 |
+
"output_type": "execute_result"
|
91 |
+
}
|
92 |
+
],
|
93 |
+
"source": [
|
94 |
+
"pwd"
|
95 |
+
]
|
96 |
+
},
|
97 |
+
{
|
98 |
+
"cell_type": "code",
|
99 |
+
"execution_count": null,
|
100 |
+
"id": "bf9486c5-3d8b-4420-bf20-454e427570fd",
|
101 |
+
"metadata": {},
|
102 |
+
"outputs": [],
|
103 |
+
"source": []
|
104 |
+
}
|
105 |
+
],
|
106 |
+
"metadata": {
|
107 |
+
"kernelspec": {
|
108 |
+
"display_name": "Python 3 (ipykernel)",
|
109 |
+
"language": "python",
|
110 |
+
"name": "python3"
|
111 |
+
},
|
112 |
+
"language_info": {
|
113 |
+
"codemirror_mode": {
|
114 |
+
"name": "ipython",
|
115 |
+
"version": 3
|
116 |
+
},
|
117 |
+
"file_extension": ".py",
|
118 |
+
"mimetype": "text/x-python",
|
119 |
+
"name": "python",
|
120 |
+
"nbconvert_exporter": "python",
|
121 |
+
"pygments_lexer": "ipython3",
|
122 |
+
"version": "3.10.15"
|
123 |
+
}
|
124 |
+
},
|
125 |
+
"nbformat": 4,
|
126 |
+
"nbformat_minor": 5
|
127 |
+
}
|
README.md
CHANGED
@@ -1,3 +1,396 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
language:
|
4 |
+
- en
|
5 |
+
base_model:
|
6 |
+
- Ultralytics/YOLO11
|
7 |
+
tags:
|
8 |
+
- yolo
|
9 |
+
- yolo11
|
10 |
+
- nsfw
|
11 |
+
pipeline_tag: object-detection
|
12 |
+
---
|
13 |
+
|
14 |
+
<p align="center">
|
15 |
+
<img src="https://cdn-uploads.huggingface.co/production/uploads/63d8d8879dfcfa941d4d7cd9/myOju5oXm0Xq_EgVpYsvo.png" alt="Logo">
|
16 |
+
</p>
|
17 |
+
|
18 |
+
<h1 style="color:red" style="text-align:center;">
|
19 |
+
🔞 WARNING: SENSITIVE CONTENT 🔞
|
20 |
+
</h1>
|
21 |
+
|
22 |
+
<h2>
|
23 |
+
THIS MEDIA CONTAINS SENSITIVE CONTENT (I.E. NUDITY, VIOLENCE, PROFANITY, PORN) THAT SOME PEOPLE MAY FIND OFFENSIVE. YOU MUST BE 18 OR OLDER TO VIEW THIS CONTENT.
|
24 |
+
</h2>
|
25 |
+
|
26 |
+
----------
|
27 |
+
# EraX-NSFW-V1.0
|
28 |
+
A Highly Efficient Model for NSFW Detection. Very effective for **pre-publication image and video control**, or for **limiting children's access to harmful publications**.
|
29 |
+
You can either just predict the classes and their boundingboxes or even mask the predicted harmful object(s) or mask the entire image.
|
30 |
+
Please see the deployment codes below.
|
31 |
+
|
32 |
+
- **Developed by**:
|
33 |
+
- Phạm Đình Thục (thuc.pd@erax.ai)
|
34 |
+
- Mr. Nguyễn Anh Nguyên (nguyen@erax.ai)
|
35 |
+
- **Model version**: v1.0
|
36 |
+
- **License**: Apache 2.0
|
37 |
+
|
38 |
+
<!-- ## Examples
|
39 |
+
![Example 01](./examples/img_1.jpg) -->
|
40 |
+
|
41 |
+
## Model Details / Overview
|
42 |
+
|
43 |
+
- **Model Architecture**: YOLO11 (nano, small, medium)
|
44 |
+
- **Task**: Object Detection (NSFW Detection)
|
45 |
+
- **Dataset**: Private datasets (from Internet).
|
46 |
+
- **Training set**: 31890 images.
|
47 |
+
- **Validation set**: 11538 images.
|
48 |
+
- **Classes**: anus, make_love, nipple, penis, vagina.
|
49 |
+
|
50 |
+
### Labels
|
51 |
+
![Labels](./train/labels.jpeg)
|
52 |
+
|
53 |
+
## Training Configuration
|
54 |
+
- **Model Weights Files**:
|
55 |
+
- Nano: [`erax_nsfw_yolo11n.pt`](./erax_nsfw_yolo11n.pt)
|
56 |
+
- Small: [`erax_nsfw_yolo11s.pt`](./erax_nsfw_yolo11s.pt)
|
57 |
+
- Medium: [`erax_nsfw_yolo11m.pt`](./erax_nsfw_yolo11m.pt)
|
58 |
+
- **Number of Epochs**: 100
|
59 |
+
- **Learning Rate**: 0.01
|
60 |
+
- **Batch Size**: 208
|
61 |
+
- **Image Size**: 640x640
|
62 |
+
- **Training server**: 8 x NVIDIA RTX A4000 (16GB GDDR6)
|
63 |
+
- **Training time**: ~10 hours
|
64 |
+
|
65 |
+
|
66 |
+
## Evaluation Metrics
|
67 |
+
Below are the key metrics from the model evaluation on the validation set:
|
68 |
+
comming soon
|
69 |
+
<!--
|
70 |
+
- **Precision**: 0.726
|
71 |
+
- **Recall**: 0.68
|
72 |
+
- **mAP50**: 0.724
|
73 |
+
- **mAP50-95**: 0.434 -->
|
74 |
+
|
75 |
+
<!-- | Format | Status | Size (MB) | metrics/mAP50-95(B) | Inference time (ms/im) | FPS |
|
76 |
+
|:-----------------------|:-------|:-----------|:----------------------|:------------------------|:--------|
|
77 |
+
| PyTorch | ✅ | 38.6 | 0.4332 | 16.97 | 58.91 |
|
78 |
+
|TorchScript | ✅ | 77 | 0.4153 | 12.09 | 82.69 |
|
79 |
+
| ONNX | ✅ | 76.7 | 0.4153 | 103.94 | 9.62 |
|
80 |
+
| OpenVINO | ❌ | - | - | - | - |
|
81 |
+
| TensorRT | ✅ | 89.6 | 0.4155 | 7 | 142.92 |
|
82 |
+
| CoreML | ❌ | - | - | - | - |
|
83 |
+
| TensorFlow SavedModel | ✅ | 192.3 | 0.4153 | 40.19 | 24.88 |
|
84 |
+
| TensorFlow GraphDef | ✅ | 76.8 | 0.4153 | 36.71 | 27.24 |
|
85 |
+
| TensorFlow Lite | ❌ | - | - | - | - |
|
86 |
+
| TensorFlow Edge TPU | ❌ | - | - | - | - |
|
87 |
+
| TensorFlow.js | ❌ | - | - | - | - |
|
88 |
+
| PaddlePaddle | ✅ | 153.3 | 0.4153 | 1024.24 | 0.98 |
|
89 |
+
| NCNN | ✅ | 76.6 | 0.4153 | 187.36 | 5.34 | -->
|
90 |
+
|
91 |
+
|
92 |
+
|
93 |
+
<!-- <table>
|
94 |
+
<thead>
|
95 |
+
<tr>
|
96 |
+
<th>Format</th>
|
97 |
+
<th width="200">Model</th>
|
98 |
+
<th width="100">Size (MB)</th>
|
99 |
+
<th>metrics/mAP50-95(B)</th>
|
100 |
+
<th>Inference time (ms/im)</th>
|
101 |
+
<th width="100">FPS</th>
|
102 |
+
</tr>
|
103 |
+
</thead>
|
104 |
+
<tbody>
|
105 |
+
<tr>
|
106 |
+
<th rowspan=3>PyTorch</th>
|
107 |
+
<th>erax_nsfw_yolo11n.pt</th>
|
108 |
+
<th>5.20</th>
|
109 |
+
<th>0.3563</th>
|
110 |
+
<th>160.17</th>
|
111 |
+
<th>6</th>
|
112 |
+
</tr>
|
113 |
+
<tr>
|
114 |
+
<th>erax_nsfw_yolo11s.pt</th>
|
115 |
+
<th>18.30</th>
|
116 |
+
<th>0.4083</th>
|
117 |
+
<th>10.12</th>
|
118 |
+
<th>99</th>
|
119 |
+
</tr>
|
120 |
+
<tr>
|
121 |
+
<th>erax_nsfw_yolo11m.pt</th>
|
122 |
+
<th>38.60</th>
|
123 |
+
<th>0.4332</th>
|
124 |
+
<th>12.04</th>
|
125 |
+
<th>83</th>
|
126 |
+
</tr>
|
127 |
+
<tr>
|
128 |
+
<th rowspan=3>TorchScript</th>
|
129 |
+
<th>erax_nsfw_yolo11n.pt</th>
|
130 |
+
<th>10.40</th>
|
131 |
+
<th>0.3427</th>
|
132 |
+
<th>75.11</th>
|
133 |
+
<th>13</th>
|
134 |
+
</tr>
|
135 |
+
<tr>
|
136 |
+
<th>erax_nsfw_yolo11s.pt</th>
|
137 |
+
<th>36.40</th>
|
138 |
+
<th>0.3918</th>
|
139 |
+
<th>4.40</th>
|
140 |
+
<th>227</th>
|
141 |
+
</tr>
|
142 |
+
<tr>
|
143 |
+
<th>erax_nsfw_yolo11m.pt</th>
|
144 |
+
<th>77.00</th>
|
145 |
+
<th>0.4153</th>
|
146 |
+
<th>6.32</th>
|
147 |
+
<th>158</th>
|
148 |
+
</tr>
|
149 |
+
<tr>
|
150 |
+
<th rowspan=3>ONNX</th>
|
151 |
+
<th>erax_nsfw_yolo11n.pt</th>
|
152 |
+
<th>10.10</th>
|
153 |
+
<th>0.3427</th>
|
154 |
+
<th>154.94</th>
|
155 |
+
<th>6</th>
|
156 |
+
</tr>
|
157 |
+
<tr>
|
158 |
+
<th>erax_nsfw_yolo11s.pt</th>
|
159 |
+
<th>36.20</th>
|
160 |
+
<th>0.3918</th>
|
161 |
+
<th>9.82</th>
|
162 |
+
<th>102</th>
|
163 |
+
</tr>
|
164 |
+
<tr>
|
165 |
+
<th>erax_nsfw_yolo11m.pt</th>
|
166 |
+
<th>76.70</th>
|
167 |
+
<th>0.4153</th>
|
168 |
+
<th>16.38</th>
|
169 |
+
<th>61</th>
|
170 |
+
</tr>
|
171 |
+
<tr>
|
172 |
+
<th rowspan=3>TensorRT</th>
|
173 |
+
<th>erax_nsfw_yolo11n.pt</th>
|
174 |
+
<th>15.60</th>
|
175 |
+
<th>0.3426</th>
|
176 |
+
<th>6.25</th>
|
177 |
+
<th>160</th>
|
178 |
+
</tr>
|
179 |
+
<tr>
|
180 |
+
<th>erax_nsfw_yolo11s.pt</th>
|
181 |
+
<th>47.30</th>
|
182 |
+
<th>0.3918</th>
|
183 |
+
<th>2.62</th>
|
184 |
+
<th>381</th>
|
185 |
+
</tr>
|
186 |
+
<tr>
|
187 |
+
<th>erax_nsfw_yolo11m.pt</th>
|
188 |
+
<th>92.70</th>
|
189 |
+
<th>0.4154</th>
|
190 |
+
<th>4.94</th>
|
191 |
+
<th>202</th>
|
192 |
+
</tr>
|
193 |
+
<tr>
|
194 |
+
<th rowspan=3>TensorFlow SavedModel</th>
|
195 |
+
<th>erax_nsfw_yolo11n.pt</th>
|
196 |
+
<th>25.90</th>
|
197 |
+
<th>0.3427</th>
|
198 |
+
<th>27.35</th>
|
199 |
+
<th>37</th>
|
200 |
+
</tr>
|
201 |
+
<tr>
|
202 |
+
<th>erax_nsfw_yolo11s.pt</th>
|
203 |
+
<th>93.30</th>
|
204 |
+
<th>0.3918</th>
|
205 |
+
<th>33.82</th>
|
206 |
+
<th>30</th>
|
207 |
+
</tr>
|
208 |
+
<tr>
|
209 |
+
<th>erax_nsfw_yolo11m.pt</th>
|
210 |
+
<th>193.40</th>
|
211 |
+
<th>0.4153</th>
|
212 |
+
<th>34.29</th>
|
213 |
+
<th>29</th>
|
214 |
+
</tr>
|
215 |
+
<tr>
|
216 |
+
<th rowspan=3>TensorFlow GraphDef</th>
|
217 |
+
<th>erax_nsfw_yolo11n.pt</th>
|
218 |
+
<th>10.20</th>
|
219 |
+
<th>0.3427</th>
|
220 |
+
<th>26.58</th>
|
221 |
+
<th>38</th>
|
222 |
+
</tr>
|
223 |
+
<tr>
|
224 |
+
<th>erax_nsfw_yolo11s.pt</th>
|
225 |
+
<th>36.30</th>
|
226 |
+
<th>0.3918</th>
|
227 |
+
<th>31.84</th>
|
228 |
+
<th>31</th>
|
229 |
+
</tr>
|
230 |
+
<tr>
|
231 |
+
<th>erax_nsfw_yolo11m.pt</th>
|
232 |
+
<th>76.80</th>
|
233 |
+
<th>0.4153</th>
|
234 |
+
<th>31.83</th>
|
235 |
+
<th>31</th>
|
236 |
+
</tr>
|
237 |
+
<tr>
|
238 |
+
<th rowspan=3>PaddlePaddle</th>
|
239 |
+
<th>erax_nsfw_yolo11n.pt</th>
|
240 |
+
<th>20.10</th>
|
241 |
+
<th>0.3427</th>
|
242 |
+
<th>264.66</th>
|
243 |
+
<th>4</th>
|
244 |
+
</tr>
|
245 |
+
<tr>
|
246 |
+
<th>erax_nsfw_yolo11s.pt</th>
|
247 |
+
<th>72.30</th>
|
248 |
+
<th>0.3918</th>
|
249 |
+
<th>453.69</th>
|
250 |
+
<th>2</th>
|
251 |
+
</tr>
|
252 |
+
<tr>
|
253 |
+
<th>erax_nsfw_yolo11m.pt</th>
|
254 |
+
<th>153.30</th>
|
255 |
+
<th>0.4153</th>
|
256 |
+
<th>2519.82</th>
|
257 |
+
<th>0</th>
|
258 |
+
</tr>
|
259 |
+
</tbody>
|
260 |
+
<tr>
|
261 |
+
<th rowspan=3>NCNN</th>
|
262 |
+
<th>erax_nsfw_yolo11n.pt</th>
|
263 |
+
<th>10.00</th>
|
264 |
+
<th>0.3427</th>
|
265 |
+
<th>893.43</th>
|
266 |
+
<th>1</th>
|
267 |
+
</tr>
|
268 |
+
<tr>
|
269 |
+
<th>erax_nsfw_yolo11s.pt</th>
|
270 |
+
<th>36.10</th>
|
271 |
+
<th>0.3918</th>
|
272 |
+
<th>1418.91</th>
|
273 |
+
<th>1</th>
|
274 |
+
</tr>
|
275 |
+
<tr>
|
276 |
+
<th>erax_nsfw_yolo11m.pt</th>
|
277 |
+
<th>76.60</th>
|
278 |
+
<th>0.4153</th>
|
279 |
+
<th>2647.62</th>
|
280 |
+
<th>0</th>
|
281 |
+
</tr>
|
282 |
+
</table>
|
283 |
+
-->
|
284 |
+
|
285 |
+
## Training Validation Results
|
286 |
+
### Training and Validation Losses
|
287 |
+
![Training and Validation Losses](./train/results.png)
|
288 |
+
|
289 |
+
### Confusion Matrix
|
290 |
+
![Confusion Matrix](./train/confusion_matrix_normalized.png)
|
291 |
+
|
292 |
+
|
293 |
+
## Inference
|
294 |
+
|
295 |
+
To use the trained model, follow these steps:
|
296 |
+
|
297 |
+
1. **Install the necessary packages**:
|
298 |
+
```curl
|
299 |
+
pip install ultralytics supervision huggingface-hub
|
300 |
+
```
|
301 |
+
|
302 |
+
2. **Download Pretrained model**:
|
303 |
+
```python
|
304 |
+
from huggingface_hub import snapshot_download
|
305 |
+
snapshot_download(repo_id="erax-ai/EraX-NSFW-V1.0", local_dir="./", force_download=True)
|
306 |
+
```
|
307 |
+
|
308 |
+
3. **Simple Use Case**:
|
309 |
+
```python
|
310 |
+
from ultralytics import YOLO
|
311 |
+
from PIL import Image
|
312 |
+
import supervision as sv
|
313 |
+
import numpy as np
|
314 |
+
|
315 |
+
IOU_THRESHOLD = 0.3
|
316 |
+
CONFIDENCE_THRESHOLD = 0.2
|
317 |
+
|
318 |
+
# pretrained_path = "erax_nsfw_yolo11n.pt"
|
319 |
+
# pretrained_path = "erax_nsfw_yolo11s.pt"
|
320 |
+
pretrained_path = "erax_nsfw_yolo11m.pt"
|
321 |
+
|
322 |
+
image_path_list = ["test_images/img_1.jpg", "test_images/img_2.jpg"]
|
323 |
+
|
324 |
+
model = YOLO(pretrained_path)
|
325 |
+
results = model(image_path_list,
|
326 |
+
conf=CONFIDENCE_THRESHOLD,
|
327 |
+
iou=IOU_THRESHOLD
|
328 |
+
)
|
329 |
+
|
330 |
+
|
331 |
+
for result in results:
|
332 |
+
annotated_image = result.orig_img.copy()
|
333 |
+
h, w = annotated_image.shape[:2]
|
334 |
+
anchor = h if h > w else w
|
335 |
+
|
336 |
+
detections = sv.Detections.from_ultralytics(result)
|
337 |
+
label_annotator = sv.LabelAnnotator(text_color=sv.Color.BLACK,
|
338 |
+
text_position=sv.Position.CENTER,
|
339 |
+
text_scale=anchor/1700)
|
340 |
+
|
341 |
+
pixelate_annotator = sv.PixelateAnnotator(pixel_size=anchor/50)
|
342 |
+
|
343 |
+
annotated_image = pixelate_annotator.annotate(
|
344 |
+
scene=annotated_image.copy(),
|
345 |
+
detections=detections
|
346 |
+
)
|
347 |
+
|
348 |
+
|
349 |
+
annotated_image = label_annotator.annotate(
|
350 |
+
annotated_image,
|
351 |
+
detections=detections
|
352 |
+
)
|
353 |
+
|
354 |
+
|
355 |
+
sv.plot_image(annotated_image, size=(10, 10))
|
356 |
+
```
|
357 |
+
|
358 |
+
## Training
|
359 |
+
Scripts for training: https://github.com/EraX-JS-Company/EraX-NSFW-V1.0
|
360 |
+
|
361 |
+
## More examples
|
362 |
+
|
363 |
+
1. **Example 01**:
|
364 |
+
![Example 03](./examples/img_3.jpg)
|
365 |
+
|
366 |
+
|
367 |
+
2. **Example 02**:
|
368 |
+
![Example 06](./examples/img_6.jpg)
|
369 |
+
|
370 |
+
|
371 |
+
3. **Example 03**: SAFEEST for using make_love class as it will cover entire context.
|
372 |
+
Without make_love class | With make_love class
|
373 |
+
:-------------------------:|:-------------------------:
|
374 |
+
![](./examples/img_2.jpg) | ![](./examples/img_2_make_love.jpg)
|
375 |
+
![](./examples/img_4.jpg) | ![](./examples/img_4_make_love.jpg)
|
376 |
+
![](./examples/img_5.jpg) | ![](./examples/img_5_make_love.jpg)
|
377 |
+
|
378 |
+
|
379 |
+
|
380 |
+
## Citation
|
381 |
+
If you find our project useful, we would appreciate it if you could star our repository and cite our work as follows:
|
382 |
+
```bibtex
|
383 |
+
@article{EraX-NSFW-V1.0,
|
384 |
+
author = {Phạm Đình Thục and
|
385 |
+
Mr. Nguyễn Anh Nguyên and
|
386 |
+
Đoàn Thành Khang and
|
387 |
+
Mr. Trần Hải Khương and
|
388 |
+
Mr. Trương Công Đức and
|
389 |
+
Phan Nguyễn Tuấn Kha and
|
390 |
+
Phạm Huỳnh Nhật},
|
391 |
+
title = {EraX-NSFW-V1.0: A Highly Efficient Model for NSFW Detection},
|
392 |
+
organization={EraX JS Company},
|
393 |
+
year={2024},
|
394 |
+
url={https://huggingface.co/erax-ai/EraX-NSFW-V1.0}
|
395 |
+
}
|
396 |
+
```
|
Upload_Huggingface.ipynb
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 11,
|
6 |
+
"id": "9a35dbb2-4482-4155-86ca-c12a0a56ba7d",
|
7 |
+
"metadata": {
|
8 |
+
"scrolled": true
|
9 |
+
},
|
10 |
+
"outputs": [
|
11 |
+
{
|
12 |
+
"data": {
|
13 |
+
"text/plain": [
|
14 |
+
"CommitInfo(commit_url='https://huggingface.co/erax-ai/EraX-NSFW-V1.1/commit/2006614e6e27495bf5e48181a63ab8c666850cc4', commit_message='Upload README.md with huggingface_hub', commit_description='', oid='2006614e6e27495bf5e48181a63ab8c666850cc4', pr_url=None, repo_url=RepoUrl('https://huggingface.co/erax-ai/EraX-NSFW-V1.1', endpoint='https://huggingface.co', repo_type='model', repo_id='erax-ai/EraX-NSFW-V1.1'), pr_revision=None, pr_num=None)"
|
15 |
+
]
|
16 |
+
},
|
17 |
+
"execution_count": 11,
|
18 |
+
"metadata": {},
|
19 |
+
"output_type": "execute_result"
|
20 |
+
}
|
21 |
+
],
|
22 |
+
"source": [
|
23 |
+
"from huggingface_hub import HfApi\n",
|
24 |
+
"api = HfApi()\n",
|
25 |
+
"api.upload_file(\n",
|
26 |
+
" path_or_fileobj=\"/home/workspace/lechitai/Anti-NSFW/EraX-Anti-NSFW-V1.1/README.md\",\n",
|
27 |
+
" path_in_repo=\"README.md\",\n",
|
28 |
+
" repo_id=\"erax-ai/EraX-NSFW-V1.1\",\n",
|
29 |
+
" repo_type=\"model\",\n",
|
30 |
+
" token=\"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\",\n",
|
31 |
+
")"
|
32 |
+
]
|
33 |
+
},
|
34 |
+
{
|
35 |
+
"cell_type": "code",
|
36 |
+
"execution_count": 14,
|
37 |
+
"id": "cbbcd852-16ca-432c-a299-624f0921f51e",
|
38 |
+
"metadata": {},
|
39 |
+
"outputs": [
|
40 |
+
{
|
41 |
+
"ename": "BadRequestError",
|
42 |
+
"evalue": "(Request ID: Root=1-67655840-0814ae860340e8820ada95d5;e670748b-fb79-4a7c-838e-f5f39b39c133)\n\nBad request for commit endpoint:\nIt appears that one or more of your files contain valid Hugging Face secrets, such as tokens or API keys. It is important to keep your secrets private and not expose them in code that is publicly accessible. Read more: https://huggingface.co/docs/hub/spaces-overview#managing-secrets Offending files: - .ipynb_checkpoints/Upload_Huggingface-checkpoint.ipynb (ref: refs/heads/main, token: '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') - .ipynb_checkpoints/Upload_Huggingface-checkpoint.ipynb (ref: refs/heads/main, token: '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')\nIt appears that one or more of your files contain valid Hugging Face secrets, such as tokens or API keys. It is important to keep your secrets private and not expose them in code that is publicly accessible. Read more: https://huggingface.co/docs/hub/spaces-overview#managing-secrets Offending files: - .ipynb_checkpoints/Upload_Huggingface-checkpoint.ipynb (ref: refs/heads/main, token: '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') - .ipynb_checkpoints/Upload_Huggingface-checkpoint.ipynb (ref: refs/heads/main, token: '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')",
|
43 |
+
"output_type": "error",
|
44 |
+
"traceback": [
|
45 |
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
46 |
+
"\u001b[0;31mHTTPError\u001b[0m Traceback (most recent call last)",
|
47 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_http.py:406\u001b[0m, in \u001b[0;36mhf_raise_for_status\u001b[0;34m(response, endpoint_name)\u001b[0m\n\u001b[1;32m 405\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 406\u001b[0m \u001b[43mresponse\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 407\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m HTTPError \u001b[38;5;28;01mas\u001b[39;00m e:\n",
|
48 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/requests/models.py:1024\u001b[0m, in \u001b[0;36mResponse.raise_for_status\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 1023\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[0;32m-> 1024\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m)\n",
|
49 |
+
"\u001b[0;31mHTTPError\u001b[0m: 400 Client Error: Bad Request for url: https://huggingface.co/api/models/erax-ai/EraX-NSFW-V1.1/commit/main",
|
50 |
+
"\nThe above exception was the direct cause of the following exception:\n",
|
51 |
+
"\u001b[0;31mBadRequestError\u001b[0m Traceback (most recent call last)",
|
52 |
+
"Cell \u001b[0;32mIn[14], line 4\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mhuggingface_hub\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m HfApi\n\u001b[1;32m 2\u001b[0m api \u001b[38;5;241m=\u001b[39m HfApi()\n\u001b[0;32m----> 4\u001b[0m \u001b[43mapi\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mupload_folder\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 5\u001b[0m \u001b[43m \u001b[49m\u001b[43mfolder_path\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m/home/workspace/lechitai/Anti-NSFW/EraX-Anti-NSFW-V1.1\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 6\u001b[0m \u001b[43m \u001b[49m\u001b[43mrepo_id\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43merax-ai/EraX-NSFW-V1.1\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 7\u001b[0m \u001b[43m \u001b[49m\u001b[43mrepo_type\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmodel\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 8\u001b[0m \u001b[43m \u001b[49m\u001b[43mtoken\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhf_UvzfLMvFhPizsWmSPrYqIsAPFLYHDpGbZn\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 9\u001b[0m \u001b[43m)\u001b[49m\n",
|
53 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_validators.py:114\u001b[0m, in \u001b[0;36mvalidate_hf_hub_args.<locals>._inner_fn\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 111\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m check_use_auth_token:\n\u001b[1;32m 112\u001b[0m kwargs \u001b[38;5;241m=\u001b[39m smoothly_deprecate_use_auth_token(fn_name\u001b[38;5;241m=\u001b[39mfn\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m, has_token\u001b[38;5;241m=\u001b[39mhas_token, kwargs\u001b[38;5;241m=\u001b[39mkwargs)\n\u001b[0;32m--> 114\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
|
54 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/huggingface_hub/hf_api.py:1559\u001b[0m, in \u001b[0;36mfuture_compatible.<locals>._inner\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1556\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mrun_as_future(fn, \u001b[38;5;28mself\u001b[39m, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m 1558\u001b[0m \u001b[38;5;66;03m# Otherwise, call the function normally\u001b[39;00m\n\u001b[0;32m-> 1559\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
|
55 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/huggingface_hub/hf_api.py:5105\u001b[0m, in \u001b[0;36mHfApi.upload_folder\u001b[0;34m(self, repo_id, folder_path, path_in_repo, commit_message, commit_description, token, repo_type, revision, create_pr, parent_commit, allow_patterns, ignore_patterns, delete_patterns, multi_commits, multi_commits_verbose, run_as_future)\u001b[0m\n\u001b[1;32m 5101\u001b[0m \u001b[38;5;66;03m# Defining a CommitInfo object is not really relevant in this case\u001b[39;00m\n\u001b[1;32m 5102\u001b[0m \u001b[38;5;66;03m# Let's return early with pr_url only (as string).\u001b[39;00m\n\u001b[1;32m 5103\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m pr_url\n\u001b[0;32m-> 5105\u001b[0m commit_info \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcreate_commit\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 5106\u001b[0m \u001b[43m \u001b[49m\u001b[43mrepo_type\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrepo_type\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 5107\u001b[0m \u001b[43m \u001b[49m\u001b[43mrepo_id\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrepo_id\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 5108\u001b[0m \u001b[43m \u001b[49m\u001b[43moperations\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcommit_operations\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 5109\u001b[0m \u001b[43m \u001b[49m\u001b[43mcommit_message\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcommit_message\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 5110\u001b[0m \u001b[43m \u001b[49m\u001b[43mcommit_description\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcommit_description\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 5111\u001b[0m \u001b[43m \u001b[49m\u001b[43mtoken\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtoken\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 5112\u001b[0m \u001b[43m \u001b[49m\u001b[43mrevision\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrevision\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 5113\u001b[0m \u001b[43m \u001b[49m\u001b[43mcreate_pr\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcreate_pr\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 5114\u001b[0m \u001b[43m \u001b[49m\u001b[43mparent_commit\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mparent_commit\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 5115\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 5117\u001b[0m \u001b[38;5;66;03m# Create url to uploaded folder (for legacy return value)\u001b[39;00m\n\u001b[1;32m 5118\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m create_pr \u001b[38;5;129;01mand\u001b[39;00m commit_info\u001b[38;5;241m.\u001b[39mpr_url \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n",
|
56 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_validators.py:114\u001b[0m, in \u001b[0;36mvalidate_hf_hub_args.<locals>._inner_fn\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 111\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m check_use_auth_token:\n\u001b[1;32m 112\u001b[0m kwargs \u001b[38;5;241m=\u001b[39m smoothly_deprecate_use_auth_token(fn_name\u001b[38;5;241m=\u001b[39mfn\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m, has_token\u001b[38;5;241m=\u001b[39mhas_token, kwargs\u001b[38;5;241m=\u001b[39mkwargs)\n\u001b[0;32m--> 114\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
|
57 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/huggingface_hub/hf_api.py:1559\u001b[0m, in \u001b[0;36mfuture_compatible.<locals>._inner\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1556\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mrun_as_future(fn, \u001b[38;5;28mself\u001b[39m, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m 1558\u001b[0m \u001b[38;5;66;03m# Otherwise, call the function normally\u001b[39;00m\n\u001b[0;32m-> 1559\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
|
58 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/huggingface_hub/hf_api.py:4093\u001b[0m, in \u001b[0;36mHfApi.create_commit\u001b[0;34m(self, repo_id, operations, commit_message, commit_description, token, repo_type, revision, create_pr, num_threads, parent_commit, run_as_future)\u001b[0m\n\u001b[1;32m 4091\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 4092\u001b[0m commit_resp \u001b[38;5;241m=\u001b[39m get_session()\u001b[38;5;241m.\u001b[39mpost(url\u001b[38;5;241m=\u001b[39mcommit_url, headers\u001b[38;5;241m=\u001b[39mheaders, data\u001b[38;5;241m=\u001b[39mdata, params\u001b[38;5;241m=\u001b[39mparams)\n\u001b[0;32m-> 4093\u001b[0m \u001b[43mhf_raise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcommit_resp\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mendpoint_name\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mcommit\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 4094\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m RepositoryNotFoundError \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m 4095\u001b[0m e\u001b[38;5;241m.\u001b[39mappend_to_message(_CREATE_COMMIT_NO_REPO_ERROR_MESSAGE)\n",
|
59 |
+
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_http.py:460\u001b[0m, in \u001b[0;36mhf_raise_for_status\u001b[0;34m(response, endpoint_name)\u001b[0m\n\u001b[1;32m 456\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m response\u001b[38;5;241m.\u001b[39mstatus_code \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m400\u001b[39m:\n\u001b[1;32m 457\u001b[0m message \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m 458\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124mBad request for \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mendpoint_name\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m endpoint:\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m endpoint_name \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124mBad request:\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 459\u001b[0m )\n\u001b[0;32m--> 460\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m _format(BadRequestError, message, response) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01me\u001b[39;00m\n\u001b[1;32m 462\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m response\u001b[38;5;241m.\u001b[39mstatus_code \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m403\u001b[39m:\n\u001b[1;32m 463\u001b[0m message \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m 464\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;132;01m{\u001b[39;00mresponse\u001b[38;5;241m.\u001b[39mstatus_code\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m Forbidden: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00merror_message\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 465\u001b[0m \u001b[38;5;241m+\u001b[39m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124mCannot access content at: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mresponse\u001b[38;5;241m.\u001b[39murl\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 466\u001b[0m \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124mMake sure your token has the correct permissions.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 467\u001b[0m )\n",
|
60 |
+
"\u001b[0;31mBadRequestError\u001b[0m: (Request ID: Root=1-67655840-0814ae860340e8820ada95d5;e670748b-fb79-4a7c-838e-f5f39b39c133)\n\nBad request for commit endpoint:\nIt appears that one or more of your files contain valid Hugging Face secrets, such as tokens or API keys. It is important to keep your secrets private and not expose them in code that is publicly accessible. Read more: https://huggingface.co/docs/hub/spaces-overview#managing-secrets Offending files: - .ipynb_checkpoints/Upload_Huggingface-checkpoint.ipynb (ref: refs/heads/main, token: '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') - .ipynb_checkpoints/Upload_Huggingface-checkpoint.ipynb (ref: refs/heads/main, token: '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')\nIt appears that one or more of your files contain valid Hugging Face secrets, such as tokens or API keys. It is important to keep your secrets private and not expose them in code that is publicly accessible. Read more: https://huggingface.co/docs/hub/spaces-overview#managing-secrets Offending files: - .ipynb_checkpoints/Upload_Huggingface-checkpoint.ipynb (ref: refs/heads/main, token: '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') - .ipynb_checkpoints/Upload_Huggingface-checkpoint.ipynb (ref: refs/heads/main, token: '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')"
|
61 |
+
]
|
62 |
+
}
|
63 |
+
],
|
64 |
+
"source": [
|
65 |
+
"from huggingface_hub import HfApi\n",
|
66 |
+
"api = HfApi()\n",
|
67 |
+
"\n",
|
68 |
+
"api.upload_folder(\n",
|
69 |
+
" folder_path=\"/home/workspace/lechitai/Anti-NSFW/EraX-Anti-NSFW-V1.1\",\n",
|
70 |
+
" repo_id=\"erax-ai/EraX-NSFW-V1.1\",\n",
|
71 |
+
" repo_type=\"model\",\n",
|
72 |
+
" token=\"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\",\n",
|
73 |
+
")"
|
74 |
+
]
|
75 |
+
},
|
76 |
+
{
|
77 |
+
"cell_type": "code",
|
78 |
+
"execution_count": 3,
|
79 |
+
"id": "1aefb2bf-4f5e-4a4f-867e-3401483fd976",
|
80 |
+
"metadata": {},
|
81 |
+
"outputs": [
|
82 |
+
{
|
83 |
+
"data": {
|
84 |
+
"text/plain": [
|
85 |
+
"'/home/workspace/lechitai/Anti-NSFW'"
|
86 |
+
]
|
87 |
+
},
|
88 |
+
"execution_count": 3,
|
89 |
+
"metadata": {},
|
90 |
+
"output_type": "execute_result"
|
91 |
+
}
|
92 |
+
],
|
93 |
+
"source": [
|
94 |
+
"pwd"
|
95 |
+
]
|
96 |
+
},
|
97 |
+
{
|
98 |
+
"cell_type": "code",
|
99 |
+
"execution_count": null,
|
100 |
+
"id": "bf9486c5-3d8b-4420-bf20-454e427570fd",
|
101 |
+
"metadata": {},
|
102 |
+
"outputs": [],
|
103 |
+
"source": []
|
104 |
+
}
|
105 |
+
],
|
106 |
+
"metadata": {
|
107 |
+
"kernelspec": {
|
108 |
+
"display_name": "Python 3 (ipykernel)",
|
109 |
+
"language": "python",
|
110 |
+
"name": "python3"
|
111 |
+
},
|
112 |
+
"language_info": {
|
113 |
+
"codemirror_mode": {
|
114 |
+
"name": "ipython",
|
115 |
+
"version": 3
|
116 |
+
},
|
117 |
+
"file_extension": ".py",
|
118 |
+
"mimetype": "text/x-python",
|
119 |
+
"name": "python",
|
120 |
+
"nbconvert_exporter": "python",
|
121 |
+
"pygments_lexer": "ipython3",
|
122 |
+
"version": "3.10.15"
|
123 |
+
}
|
124 |
+
},
|
125 |
+
"nbformat": 4,
|
126 |
+
"nbformat_minor": 5
|
127 |
+
}
|
erax-anti-nsfw-yolo11m-v1.1.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5ec24336b34c2bc8ba7fab6731a260dce55de26e5db87da2b80fd1fea09b1ec8
|
3 |
+
size 40495802
|
erax-anti-nsfw-yolo11n-v1.1.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2df45339e529097f2aaca26fb5a56a0e8f01bafa0ded4cec6cc48ff3aba84eb2
|
3 |
+
size 5451432
|
erax-anti-nsfw-yolo11s-v1.1.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6169d17d11b384f09f47502b71f0c772bb93588df098e8d14ad5d6440e038bfc
|
3 |
+
size 19155432
|
examples/img_1.jpg
ADDED
examples/img_2.jpg
ADDED
examples/img_2_make_love.jpg
ADDED
examples/img_3.jpg
ADDED
examples/img_4.jpg
ADDED
examples/img_4_make_love.jpg
ADDED
examples/img_4make_love.jpg
ADDED
examples/img_5.jpg
ADDED
examples/img_5_make_love.jpg
ADDED
examples/img_6.jpg
ADDED
test_images/img_1.jpg
ADDED
test_images/img_2.jpg
ADDED
train_result/erax-anti-nsfw-yolo11m-v1.1/F1_curve.png
ADDED
train_result/erax-anti-nsfw-yolo11m-v1.1/PR_curve.png
ADDED
train_result/erax-anti-nsfw-yolo11m-v1.1/P_curve.png
ADDED
train_result/erax-anti-nsfw-yolo11m-v1.1/R_curve.png
ADDED
train_result/erax-anti-nsfw-yolo11m-v1.1/confusion_matrix_normalized.png
ADDED
train_result/erax-anti-nsfw-yolo11m-v1.1/labels.jpg
ADDED
train_result/erax-anti-nsfw-yolo11m-v1.1/results.png
ADDED
train_result/erax-anti-nsfw-yolo11n-v1.1/.ipynb_checkpoints/F1_curve-checkpoint.png
ADDED
train_result/erax-anti-nsfw-yolo11n-v1.1/.ipynb_checkpoints/confusion_matrix_normalized-checkpoint.png
ADDED
train_result/erax-anti-nsfw-yolo11n-v1.1/.ipynb_checkpoints/labels-checkpoint.jpg
ADDED
train_result/erax-anti-nsfw-yolo11n-v1.1/.ipynb_checkpoints/results-checkpoint.png
ADDED
train_result/erax-anti-nsfw-yolo11n-v1.1/F1_curve.png
ADDED
train_result/erax-anti-nsfw-yolo11n-v1.1/PR_curve.png
ADDED
train_result/erax-anti-nsfw-yolo11n-v1.1/P_curve.png
ADDED
train_result/erax-anti-nsfw-yolo11n-v1.1/R_curve.png
ADDED
train_result/erax-anti-nsfw-yolo11n-v1.1/confusion_matrix_normalized.png
ADDED
train_result/erax-anti-nsfw-yolo11n-v1.1/labels.jpg
ADDED
train_result/erax-anti-nsfw-yolo11n-v1.1/results.png
ADDED
train_result/erax-anti-nsfw-yolo11s-v1.1/.ipynb_checkpoints/labels-checkpoint.jpg
ADDED
train_result/erax-anti-nsfw-yolo11s-v1.1/F1_curve.png
ADDED
train_result/erax-anti-nsfw-yolo11s-v1.1/PR_curve.png
ADDED
train_result/erax-anti-nsfw-yolo11s-v1.1/P_curve.png
ADDED
train_result/erax-anti-nsfw-yolo11s-v1.1/R_curve.png
ADDED
train_result/erax-anti-nsfw-yolo11s-v1.1/confusion_matrix_normalized.png
ADDED
train_result/erax-anti-nsfw-yolo11s-v1.1/labels.jpg
ADDED
train_result/erax-anti-nsfw-yolo11s-v1.1/results.png
ADDED