mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-07-07 13:32:09 -07:00
nothing interesting
This commit is contained in:
parent
0e088f6415
commit
f89200d236
2 changed files with 38 additions and 26 deletions
|
@ -76,7 +76,7 @@ class PoseEstimator(object):
|
||||||
|
|
||||||
CAInitializerMP ( gather_Conv2D_layers( [self.encoder, self.decoder] ) )
|
CAInitializerMP ( gather_Conv2D_layers( [self.encoder, self.decoder] ) )
|
||||||
|
|
||||||
idx_tensor = K.constant( np.array([idx for idx in range(self.class_nums[0])], dtype=K.floatx() ) )
|
idx_tensor = self.idx_tensor = K.constant( np.array([idx for idx in range(self.class_nums[0])], dtype=K.floatx() ) )
|
||||||
pitch_t, yaw_t, roll_t = K.sum ( bins_t[0] * idx_tensor, 1), K.sum (bins_t[1] * idx_tensor, 1), K.sum ( bins_t[2] * idx_tensor, 1)
|
pitch_t, yaw_t, roll_t = K.sum ( bins_t[0] * idx_tensor, 1), K.sum (bins_t[1] * idx_tensor, 1), K.sum ( bins_t[2] * idx_tensor, 1)
|
||||||
|
|
||||||
if training:
|
if training:
|
||||||
|
@ -110,11 +110,17 @@ class PoseEstimator(object):
|
||||||
[bgr_loss], Adam(lr=2e-4, beta_1=0.5, beta_2=0.999).get_updates( bgr_loss, self.encoder.trainable_weights+self.decoder.trainable_weights ) )
|
[bgr_loss], Adam(lr=2e-4, beta_1=0.5, beta_2=0.999).get_updates( bgr_loss, self.encoder.trainable_weights+self.decoder.trainable_weights ) )
|
||||||
|
|
||||||
self.train_l = K.function ([inp_t, inp_pitch_t, inp_yaw_t, inp_roll_t] + inp_bins_t,
|
self.train_l = K.function ([inp_t, inp_pitch_t, inp_yaw_t, inp_roll_t] + inp_bins_t,
|
||||||
[K.mean(pitch_loss),K.mean(yaw_loss),K.mean(roll_loss)], Adam(lr=0.000001).get_updates( [pitch_loss,yaw_loss,roll_loss], self.model_l.trainable_weights) )
|
[K.mean(pitch_loss),K.mean(yaw_loss),K.mean(roll_loss)], Adam(lr=0.0001).get_updates( [pitch_loss,yaw_loss,roll_loss], self.model_l.trainable_weights) )
|
||||||
|
|
||||||
|
|
||||||
self.view = K.function ([inp_t], [pitch_t, yaw_t, roll_t] )
|
self.view = K.function ([inp_t], [pitch_t, yaw_t, roll_t] )
|
||||||
|
|
||||||
|
def flow(self, x):
|
||||||
|
bins_t = self.model(x)
|
||||||
|
return bins_t[0], bins_t[1], bins_t[2]
|
||||||
|
pitch_t, yaw_t, roll_t = K.sum ( bins_t[0] * self.idx_tensor, 1), K.sum (bins_t[1] * self.idx_tensor, 1), K.sum ( bins_t[2] * self.idx_tensor, 1)
|
||||||
|
return pitch_t, yaw_t, roll_t
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
|
@ -55,27 +55,28 @@ class SampleProcessor(object):
|
||||||
IMG_TRANSFORMED = 4
|
IMG_TRANSFORMED = 4
|
||||||
IMG_LANDMARKS_ARRAY = 5 #currently unused
|
IMG_LANDMARKS_ARRAY = 5 #currently unused
|
||||||
IMG_PITCH_YAW_ROLL = 6
|
IMG_PITCH_YAW_ROLL = 6
|
||||||
IMG_TYPE_END = 6
|
IMG_PITCH_YAW_ROLL_SIGMOID = 7
|
||||||
|
IMG_TYPE_END = 10
|
||||||
|
|
||||||
FACE_TYPE_BEGIN = 7
|
FACE_TYPE_BEGIN = 10
|
||||||
FACE_TYPE_HALF = 7
|
FACE_TYPE_HALF = 10
|
||||||
FACE_TYPE_FULL = 8
|
FACE_TYPE_FULL = 11
|
||||||
FACE_TYPE_HEAD = 9 #currently unused
|
FACE_TYPE_HEAD = 12 #currently unused
|
||||||
FACE_TYPE_AVATAR = 10 #currently unused
|
FACE_TYPE_AVATAR = 13 #currently unused
|
||||||
FACE_TYPE_END = 10
|
FACE_TYPE_END = 20
|
||||||
|
|
||||||
FACE_MASK_BEGIN = 10
|
FACE_MASK_BEGIN = 20
|
||||||
FACE_MASK_FULL = 11
|
FACE_MASK_FULL = 20
|
||||||
FACE_MASK_EYES = 12 #currently unused
|
FACE_MASK_EYES = 21 #currently unused
|
||||||
FACE_MASK_END = 12
|
FACE_MASK_END = 30
|
||||||
|
|
||||||
MODE_BEGIN = 13
|
MODE_BEGIN = 40
|
||||||
MODE_BGR = 13 #BGR
|
MODE_BGR = 40 #BGR
|
||||||
MODE_G = 14 #Grayscale
|
MODE_G = 41 #Grayscale
|
||||||
MODE_GGG = 15 #3xGrayscale
|
MODE_GGG = 42 #3xGrayscale
|
||||||
MODE_M = 16 #mask only
|
MODE_M = 43 #mask only
|
||||||
MODE_BGR_SHUFFLE = 17 #BGR shuffle
|
MODE_BGR_SHUFFLE = 44 #BGR shuffle
|
||||||
MODE_END = 17
|
MODE_END = 50
|
||||||
|
|
||||||
class Options(object):
|
class Options(object):
|
||||||
|
|
||||||
|
@ -126,13 +127,13 @@ class SampleProcessor(object):
|
||||||
face_mask_type = SPTF.NONE
|
face_mask_type = SPTF.NONE
|
||||||
mode_type = SPTF.NONE
|
mode_type = SPTF.NONE
|
||||||
for t in types:
|
for t in types:
|
||||||
if t >= SPTF.IMG_TYPE_BEGIN and t <= SPTF.IMG_TYPE_END:
|
if t >= SPTF.IMG_TYPE_BEGIN and t < SPTF.IMG_TYPE_END:
|
||||||
img_type = t
|
img_type = t
|
||||||
elif t >= SPTF.FACE_TYPE_BEGIN and t <= SPTF.FACE_TYPE_END:
|
elif t >= SPTF.FACE_TYPE_BEGIN and t < SPTF.FACE_TYPE_END:
|
||||||
target_face_type = t
|
target_face_type = t
|
||||||
elif t >= SPTF.FACE_MASK_BEGIN and t <= SPTF.FACE_MASK_END:
|
elif t >= SPTF.FACE_MASK_BEGIN and t < SPTF.FACE_MASK_END:
|
||||||
face_mask_type = t
|
face_mask_type = t
|
||||||
elif t >= SPTF.MODE_BEGIN and t <= SPTF.MODE_END:
|
elif t >= SPTF.MODE_BEGIN and t < SPTF.MODE_END:
|
||||||
mode_type = t
|
mode_type = t
|
||||||
|
|
||||||
if img_type == SPTF.NONE:
|
if img_type == SPTF.NONE:
|
||||||
|
@ -143,7 +144,7 @@ class SampleProcessor(object):
|
||||||
l = np.concatenate ( [ np.expand_dims(l[:,0] / w,-1), np.expand_dims(l[:,1] / h,-1) ], -1 )
|
l = np.concatenate ( [ np.expand_dims(l[:,0] / w,-1), np.expand_dims(l[:,1] / h,-1) ], -1 )
|
||||||
l = np.clip(l, 0.0, 1.0)
|
l = np.clip(l, 0.0, 1.0)
|
||||||
img = l
|
img = l
|
||||||
elif img_type == SPTF.IMG_PITCH_YAW_ROLL:
|
elif img_type == SPTF.IMG_PITCH_YAW_ROLL or img_type == SPTF.IMG_PITCH_YAW_ROLL_SIGMOID:
|
||||||
pitch_yaw_roll = sample.pitch_yaw_roll
|
pitch_yaw_roll = sample.pitch_yaw_roll
|
||||||
if pitch_yaw_roll is not None:
|
if pitch_yaw_roll is not None:
|
||||||
pitch, yaw, roll = pitch_yaw_roll
|
pitch, yaw, roll = pitch_yaw_roll
|
||||||
|
@ -152,6 +153,11 @@ class SampleProcessor(object):
|
||||||
if params['flip']:
|
if params['flip']:
|
||||||
yaw = -yaw
|
yaw = -yaw
|
||||||
|
|
||||||
|
if img_type == SPTF.IMG_PITCH_YAW_ROLL_SIGMOID:
|
||||||
|
pitch = (pitch+1.0) / 2.0
|
||||||
|
yaw = (yaw+1.0) / 2.0
|
||||||
|
roll = (roll+1.0) / 2.0
|
||||||
|
|
||||||
img = (pitch, yaw, roll)
|
img = (pitch, yaw, roll)
|
||||||
else:
|
else:
|
||||||
if mode_type == SPTF.NONE:
|
if mode_type == SPTF.NONE:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue