forked from china-testing/python-api-tesing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_face.py
executable file
·63 lines (50 loc) · 1.6 KB
/
check_face.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Author: xurongzhong#126.com 技术支持qq群:144081101
# CreateDate: 2018-1-8
# check_md5.py
import multiprocessing
from pathlib import Path
import argparse
import os
import pandas as pd
import data_common
import photos
def consumer(queue, results, lock):
while True:
filename = queue.get()
if filename is None:
break
print(filename)
if not '/photo/' in filename:
continue
photos.raw2jpg(filename)
location = photos.find_face(filename + ".jpg",rotate=90, model='cnn')
if location:
print("Error: {}".format(filename))
with lock:
results.append(filename)
if __name__ == '__main__':
process = []
queue = multiprocessing.Queue()
results = multiprocessing.Manager().list()
lock = multiprocessing.Lock()
if multiprocessing.cpu_count() < 3:
number = multiprocessing.cpu_count()
else:
number = multiprocessing.cpu_count() - 1
# Launch the consumer process
for i in range(number):
t = multiprocessing.Process(
target=consumer,args=(queue, results, lock))
t.daemon=True
process.append(t)
for i in range(number):
process[i].start()
for item in df['ir']:
queue.put(item)
for i in range(number):
queue.put(None)
for i in range(number):
process[i].join()
data_common.output_file("output.txt", results)