(prob_volume, depth_values, interval, depth_gt, mask, weight)
| 196 | return loss |
| 197 | |
| 198 | def classification_loss(prob_volume, depth_values, interval, depth_gt, mask, weight): |
| 199 | depth_gt_volume = depth_gt.unsqueeze(1).expand_as(depth_values) # (b, d, h, w) |
| 200 | |
| 201 | gt_index_volume = ( |
| 202 | ((depth_values - interval / 2) <= depth_gt_volume).float() * ((depth_values + interval / 2) > depth_gt_volume).float()) |
| 203 | |
| 204 | NEAR_0 = 1e-4 # Prevent overflow |
| 205 | prob_volume = torch.where(prob_volume <= 0.0, torch.zeros_like(prob_volume) + NEAR_0, prob_volume) |
| 206 | |
| 207 | loss = -torch.sum(gt_index_volume * torch.log(prob_volume), dim=1)[mask].mean() |
| 208 | loss = loss * weight |
| 209 | return loss |
| 210 | |
| 211 | |
| 212 | def gfocal_loss(prob_volume, depth_values, interval, depth_gt, mask, weight, gamma, alpha): |
nothing calls this directly
no outgoing calls
no test coverage detected