Charbel Malo
commited on
Commit
•
9461142
1
Parent(s):
56860b9
Update nsfw_checker/opennsfw.py
Browse files- nsfw_checker/opennsfw.py +0 -18
nsfw_checker/opennsfw.py
CHANGED
@@ -16,22 +16,4 @@ class NSFWChecker:
|
|
16 |
|
17 |
def is_nsfw(self, img_paths, threshold = 0.85):
|
18 |
skip_step = 1
|
19 |
-
total_len = len(img_paths)
|
20 |
-
if total_len < 100: skip_step = 1
|
21 |
-
if total_len > 100 and total_len < 500: skip_step = 10
|
22 |
-
if total_len > 500 and total_len < 1000: skip_step = 20
|
23 |
-
if total_len > 1000 and total_len < 10000: skip_step = 50
|
24 |
-
if total_len > 10000: skip_step = 100
|
25 |
-
|
26 |
-
for idx in tqdm(range(0, total_len, skip_step), total=int(total_len // skip_step), desc="Checking for NSFW contents"):
|
27 |
-
img = cv2.imread(img_paths[idx])
|
28 |
-
img = cv2.resize(img, (224,224)).astype('float32')
|
29 |
-
img -= np.array([104, 117, 123], dtype=np.float32)
|
30 |
-
img = np.expand_dims(img, axis=0)
|
31 |
-
|
32 |
-
score = self.session.run(None, {self.input_name:img})[0][0][1]
|
33 |
-
|
34 |
-
if score > threshold:
|
35 |
-
print(f"Detected nsfw score:{score}")
|
36 |
-
return False
|
37 |
return False
|
|
|
16 |
|
17 |
def is_nsfw(self, img_paths, threshold = 0.85):
|
18 |
skip_step = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
return False
|