Skip to content
Permalink
Browse files

extractor: increased speed of 1st pass by DLIB for >= 4GB vram cards,

added 'h' key for hide the help in manual extractor
  • Loading branch information...
iperov committed Mar 8, 2019
1 parent bced4d3 commit 168d48b11963ba67e9d21dadf6e11c4b87eae01a
Showing with 19 additions and 6 deletions.
  1. +5 −2 joblib/SubprocessorBase.py
  2. +14 −4 mainscripts/Extractor.py
@@ -48,7 +48,7 @@ def get_data_name (self, data):
return "undefined"

def log_info(self, msg): self.c2s.put ( {'op': 'log_info', 'msg':msg } )
def log_err(self, msg): self.c2s.put ( {'op': 'log_err' , 'msg':msg } )
def log_err(self, msg): self.c2s.put ( {'op': 'log_err' , 'msg':msg } )
def progress_bar_inc(self, c): self.c2s.put ( {'op': 'progress_bar_inc' , 'c':c } )

def _subprocess_run(self, client_dict):
@@ -163,6 +163,10 @@ def run(self):
op = obj.get('op','')
if op == 'init_ok':
cli.state = 0
elif op == 'log_info':
io.log_info(obj['msg'])
elif op == 'log_err':
io.log_err(obj['msg'])
elif op == 'error':
cli.kill()
self.clis.remove(cli)
@@ -184,7 +188,6 @@ def run(self):
while not cli.c2s.empty():
obj = cli.c2s.get()
op = obj.get('op','')

if op == 'success':
#success processed data, return data and result to on_result
self.on_result (cli.host_dict, obj['data'], obj['result'])
@@ -25,6 +25,7 @@ class Cli(Subprocessor.Cli):
#override
def on_initialize(self, client_dict):
self.log_info ('Running on %s.' % (client_dict['device_name']) )

self.type = client_dict['type']
self.image_size = client_dict['image_size']
self.face_type = client_dict['face_type']
@@ -175,6 +176,7 @@ def on_clients_initialized(self):
self.cache_original_image = (None, None)
self.cache_image = (None, None)
self.cache_text_lines_img = (None, None)
self.hide_help = False

self.landmarks = None
self.x = 0
@@ -211,7 +213,7 @@ def get_devices_for_type (self, type, multi_gpu, cpu_only):
dev_name = nnlib.device.getDeviceName(idx)
dev_vram = nnlib.device.getDeviceVRAMTotalGb(idx)

if not self.manual and self.type == 'rects' and self.detector == 'mt':
if not self.manual and ( (self.type == 'rects') ):
for i in range ( int (max (1, dev_vram / 2) ) ):
yield (idx, 'GPU', '%s #%d' % (dev_name,i) , dev_vram)
else:
@@ -299,8 +301,8 @@ def get_data(self, host_dict):
'[Enter] - confirm face landmarks and continue',
'[Space] - confirm as unmarked frame and continue',
'[Mouse wheel] - change rect',
'[,] [.]- prev frame, next frame',
'[Q] - skip remaining frames'
'[,] [.]- prev frame, next frame. [Q] - skip remaining frames',
'[h] - hide this help'
], (1, 1, 1) )*255).astype(np.uint8)

self.cache_text_lines_img = (sh, self.text_lines_img)
@@ -350,6 +352,9 @@ def get_data(self, host_dict):
elif key == ord('q'):
skip_remaining = True
break
elif key == ord('h'):
self.hide_help = not self.hide_help
break

if self.x != new_x or \
self.y != new_y or \
@@ -402,7 +407,12 @@ def on_result (self, host_dict, data, result):
self.landmarks = result[1][0][1]

(h,w,c) = self.image.shape
image = cv2.addWeighted (self.image,1.0,self.text_lines_img,1.0,0)

if not self.hide_help:
image = cv2.addWeighted (self.image,1.0,self.text_lines_img,1.0,0)
else:
image = self.image.copy()

view_rect = (np.array(self.rect) * self.view_scale).astype(np.int).tolist()
view_landmarks = (np.array(self.landmarks) * self.view_scale).astype(np.int).tolist()

0 comments on commit 168d48b

Please sign in to comment.
You can’t perform that action at this time.