zhangxuan1918 / InverseRendering3DMMCnn

face fusion project
0 stars 0 forks source link

use data argument to avoid overfitting #33

Closed zhangxuan1918 closed 4 years ago

zhangxuan1918 commented 4 years ago

we notice over-fitting during training, to improve, we randomly argument input data

tx = random(0, 32)
ty = random(0, 32)
render_image_size = 224

image_resized = tf.image.resize(image, (256, 256))
image_shift = tf.image.crop_to_bounding_box(image_resized, tx, ty, render_image_size, render_image_size)

# update landmark gt

lm = mat_data['pt2d']
lm_shift = np.copy(lm)
lm_shift *= 256. / 450.
lm_shift[0], lm_shift[1] = lm_shift[0] - ty, lm_shift[1] - tx
lm *= 224. / 450

# update pose params
pp = mat_data['Pose_Para']
pp[0, 3:5] = pp[0, 3:5] * 256 / 450
pp[0, 6] = pp[0, 6] * 256 / 450
pp[0, 3], pp[0, 4] = pp[0, 3] - ty, pp[0, 4] - (32 - tx)