-
Notifications
You must be signed in to change notification settings - Fork 123
Description
Hello,
Thanks for the open-source code. I was trying the use the training code for my own dataset, and thus adapting both dataloader and RobustLoss class. For each pair of image, I have an homography matrix H between A and B, from which i can deduce dense wrap (approximative). However, I have some trouble understanding your loss implementation. To be more precise, here is your forward loss :
def forward(self, corresps, batch):
scales = list(corresps.keys())
tot_loss = 0.0
# scale_weights due to differences in scale for regression gradients and classification gradients
scale_weights = {1:1, 2:1, 4:1, 8:1, 16:1}
for scale in scales:
scale_corresps = corresps[scale]
scale_certainty, flow_pre_delta, delta_cls, offset_scale, scale_gm_cls, scale_gm_certainty, flow, scale_gm_flow = (
scale_corresps["certainty"],
scale_corresps.get("flow_pre_delta"),
scale_corresps.get("delta_cls"),
scale_corresps.get("offset_scale"),
scale_corresps.get("gm_cls"),
scale_corresps.get("gm_certainty"),
scale_corresps["flow"],
scale_corresps.get("gm_flow"),
)
if flow_pre_delta is not None:
flow_pre_delta = rearrange(flow_pre_delta, "b d h w -> b h w d")
b, h, w, d = flow_pre_delta.shape
else:
# _ = 1
b, _, h, w = scale_certainty.shape
gt_warp, gt_prob = get_gt_warp(
batch["im_A_depth"],
batch["im_B_depth"],
batch["T_1to2"],
batch["K1"],
batch["K2"],
H=h,
W=w,
)
x2 = gt_warp.float()
prob = gt_prob
etc ...
I was thinking about replacing the following lines :
gt_warp, gt_prob = get_gt_warp(
batch["im_A_depth"],
batch["im_B_depth"],
batch["T_1to2"],
batch["K1"],
batch["K2"],
H=h,
W=w,
)
x2 = gt_warp.float()
prob = gt_prob
by my own function whose prototype should be smthg like
def compute_dense_matching_from_H(self, H, imA,imgB) ==> x2,prob with x2 representing my matches scaled between -1/1 and prob a torch.ones tensor in my case by default.
However, I am not sure about how to implement it. here is my question:
- My Homography matrix is the matrix to go from im_A to im_B present in the batch. However you introduced a scale with h and w in a for loop : what does it correspond to concretly ? Whose is being rescaled exactly ? and should I adapt my matrix according to them ?
Thanks for your reply !