DFL now works with JPG files by default. Old PNG files also supported. Added util convertor PNG to JPG.

This commit is contained in:
iperov 2019-02-04 19:47:24 +04:00
parent f0a5f97995
commit 6d95dd4a99
9 changed files with 400 additions and 92 deletions

View file

@ -6,6 +6,7 @@ from pathlib import Path
from utils import Path_utils
from utils.DFLPNG import DFLPNG
from utils.DFLJPG import DFLJPG
from .Sample import Sample
from .Sample import SampleType
@ -54,21 +55,22 @@ class SampleLoader:
sample_list = []
for s in tqdm( samples, desc="Loading", ascii=True ):
s_filename_path = Path(s.filename)
if s_filename_path.suffix != '.png':
print ("%s is not a png file required for training" % (s_filename_path.name) )
continue
dflpng = DFLPNG.load ( str(s_filename_path), print_on_no_embedded_data=True )
if dflpng is None:
if s_filename_path.suffix == '.png':
dflimg = DFLPNG.load ( str(s_filename_path), print_on_no_embedded_data=True )
if dflimg is None: continue
elif s_filename_path.suffix == '.jpg':
dflimg = DFLJPG.load ( str(s_filename_path), print_on_no_embedded_data=True )
if dflimg is None: continue
else:
print ("%s is not a dfl image file required for training" % (s_filename_path.name) )
continue
sample_list.append( s.copy_and_set(sample_type=SampleType.FACE,
face_type=FaceType.fromString (dflpng.get_face_type()),
shape=dflpng.get_shape(),
landmarks=dflpng.get_landmarks(),
yaw=dflpng.get_yaw_value()) )
face_type=FaceType.fromString (dflimg.get_face_type()),
shape=dflimg.get_shape(),
landmarks=dflimg.get_landmarks(),
yaw=dflimg.get_yaw_value()) )
return sample_list