File tree 1 file changed +7
-5
lines changed
1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change 12
12
def images (root_dir ):
13
13
count = 0
14
14
for filename in glob .iglob (root_dir + '**/*.jpg' , recursive = True ):
15
- if count == 10 :
16
- return
15
+ # if count == 10:
16
+ # return
17
17
try :
18
18
img = Image .open (filename )
19
19
yield img , filename
20
20
except Exception as err :
21
21
print ("failed to open file" , err )
22
22
count += 1
23
+ print (f"scanned { count } images" )
23
24
24
25
if __name__ == '__main__' :
25
26
if len (sys .argv ) < 2 :
26
27
raise Exception (f"{ CRED } error!: please provide root image folder{ CEND } " )
27
28
root_dir = sys .argv [1 ]
28
29
print (f"root_dir { root_dir } " )
29
- threshold = 0.3
30
+ threshold = 0.6
30
31
31
32
print (f"failure threshold is set to { threshold :.4f} " )
32
33
@@ -44,12 +45,13 @@ def images(root_dir):
44
45
try :
45
46
result = classify (img )
46
47
except Exception as err :
47
- print (f"{ CYELLOW } err{ CEND } (score:n/a) { filename } { err } " )
48
+ # print(f"{CYELLOW}err{CEND} (score:n/a) {filename} {err}")
48
49
continue
49
50
50
51
nsfw_score = result [1 ]["score" ]
51
52
score_read = '%.4f' % nsfw_score
52
53
if nsfw_score > threshold :
53
54
print (f"{ CRED } failed{ CEND } (score:{ score_read } ) { filename } " )
54
55
else :
55
- print (f"{ CGREEN } passed{ CEND } (score:{ score_read } ) { filename } " )
56
+ # print(f"{CGREEN}passed{CEND} (score:{score_read}) {filename}")
57
+ pass
You can’t perform that action at this time.
0 commit comments