From b9457f17fe2561b387258ae4c092cf02ac7b73e9 Mon Sep 17 00:00:00 2001 From: Piv <18462828+Piv200@users.noreply.github.com> Date: Tue, 13 Jul 2021 19:20:24 +0930 Subject: [PATCH] Add pixel loss functions, move warp --- unsupervised/train.py | 19 ------------------- unsupervised/warp.py | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 19 deletions(-) create mode 100644 unsupervised/warp.py diff --git a/unsupervised/train.py b/unsupervised/train.py index e2162ee..01f028a 100644 --- a/unsupervised/train.py +++ b/unsupervised/train.py @@ -4,7 +4,6 @@ Trainer to learn depth information on unlabeled data (raw images/videos) Allows pluggable depth networks for differing performance (including fast-depth) """ -import tensorflow as tf import tensorflow.keras as keras @@ -17,23 +16,5 @@ class SFMLearner(keras.Model): pass -def projective_inverse_warp(depth, pose, t_img, s_imgs, intrinsics): - ''' - SFM Learner inverse warp step - ps ~ K.T(t->s).Dt(pt).K^-1.pt - - projected source pixel - ''' - pass - - -def bilinear_sample(projected_coords, s_img): - ''' - Sample the 4 closest pixels in the source image via the projected coordinates - to get the source image warped to the target image - ''' - pass - - def make_sfm_learner_pose_net(input_shape=(224, 224, 3)): pass diff --git a/unsupervised/warp.py b/unsupervised/warp.py new file mode 100644 index 0000000..22eb535 --- /dev/null +++ b/unsupervised/warp.py @@ -0,0 +1,15 @@ +def projective_inverse_warp(target_img, source_img, depth, pose, intrinsics): + """ + Calculate the reprojected image from the source to the target, based on the given depth, pose and intrinsics + + SFM Learner inverse warp step + ps ~ K.T(t->s).Dt(pt).K^-1.pt + + :param target_img: Tensor (batch, height, width, 3) + :param source_img: Tensor, same shape as target_img + :param depth: Tensor, (batch, height, width, 1) + :param pose: (batch, 3, 3) + :param intrinsics: (batch, 3, 3) + :return: The source image reprojected to the target + """ + pass