fix ability for auto re-extract dst faces, after this update DFL torrent extractor scripts will not work.

This commit is contained in:
iperov 2019-03-18 01:12:04 +04:00
commit 1d56585f33
6 changed files with 48 additions and 49 deletions

View file

@ -1,3 +1,4 @@
import traceback
import numpy as np
import os
import cv2
@ -41,7 +42,8 @@ class LandmarksExtractor(object):
pts_img = self.get_pts_from_predict ( predicted[-1], center, scale)
pts_img = [ ( int(pt[0]), int(pt[1]) ) for pt in pts_img ]
landmarks.append ( ( (left, top, right, bottom),pts_img ) )
except:
except Exception as e:
print ("extract_from_bgr: ", traceback.format_exc() )
landmarks.append ( ( (left, top, right, bottom), [ (0,0) for _ in range(68) ] ) )
return landmarks

View file

@ -32,20 +32,16 @@ class S3FDExtractor(object):
olist = self.model.predict( np.expand_dims(input_image,0) )
detected_faces = self.refine (olist)
#filtering faces < 40pix by any side
#enlarging bottom line a bit for 2DFAN-4, because default is not enough covering a chin
new_detected_faces = []
for ltrb in detected_faces:
detected_faces = []
for ltrb in self.refine (olist):
l,t,r,b = [ x*input_scale for x in ltrb]
bt = b-t
if min(r-l,bt) < 40:
if min(r-l,bt) < 40: #filtering faces < 40pix by any side
continue
b += bt*0.1
new_detected_faces.append ( [int(x) for x in (l,t,r,b) ] )
b += bt*0.1 #enlarging bottom line a bit for 2DFAN-4, because default is not enough covering a chin
detected_faces.append ( [int(x) for x in (l,t,r,b) ] )
return new_detected_faces
return detected_faces
def refine(self, olist):
bboxlist = []