Comments (5)
class MSGIL_NORM_Loss(nn.Module):
"""
Our proposed GT normalized Multi-scale Gradient Loss Fuction.
"""
def __init__(self, scale=4, valid_threshold=-1e-8, max_threshold=1e8):
super(MSGIL_NORM_Loss, self).__init__()
self.scales_num = scale
self.valid_threshold = valid_threshold
self.max_threshold = max_threshold
self.EPSILON = 1e-6
def one_scale_gradient_loss(self, pred_scale, gt, mask):
mask_float = mask.to(dtype=pred_scale.dtype, device=pred_scale.device)
d_diff = pred_scale - gt
v_mask = torch.mul(mask_float[:, :, :-2, :], mask_float[:, :, 2:, :])
v_gradient = torch.abs(d_diff[:, :, :-2, :] - d_diff[:, :, 2:, :])
v_gradient = torch.mul(v_gradient, v_mask)
h_gradient = torch.abs(d_diff[:, :, :, :-2] - d_diff[:, :, :, 2:])
h_mask = torch.mul(mask_float[:, :, :, :-2], mask_float[:, :, :, 2:])
h_gradient = torch.mul(h_gradient, h_mask)
valid_num = torch.sum(h_mask) + torch.sum(v_mask)
gradient_loss = torch.sum(h_gradient) + torch.sum(v_gradient)
gradient_loss = gradient_loss / (valid_num + 1e-8)
return gradient_loss
def forward(self, pred, gt, minmax_meanstd):
mask = gt > self.valid_threshold
grad_term = 0.0
gt_mean = minmax_meanstd[:, 2]
gt_std = minmax_meanstd[:, 3]
gt_trans = (gt - gt_mean[:, None, None, None]) / (gt_std[:, None, None, None] + 1e-8)
for i in range(self.scales_num):
d_gt = gt_trans[:, :, ::2, ::2]
d_pred = pred[:, :, ::2, ::2]
d_mask = mask[:, :, ::2, ::2]
grad_term += self.one_scale_gradient_loss(d_pred, d_gt, d_mask)
return grad_term
This is the multi-scale gradient loss that I used. I have revised the original formulation.
from adelaidepth.
def forward(self, pred, gt, minmax_meanstd):
mask = gt > self.valid_threshold
grad_term = 0.0
gt_mean = minmax_meanstd[:, 2]
gt_std = minmax_meanstd[:, 3]
gt_trans = (gt - gt_mean[:, None, None, None]) / (gt_std[:, None, None, None] + 1e-8)
for i in range(self.scales_num):
d_gt = gt_trans[:, :, ::2, ::2]#this value not change during for loop
d_pred = pred[:, :, ::2, ::2] #this value not change during for loop
d_mask = mask[:, :, ::2, ::2]#this value not change during for loop
grad_term += self.one_scale_gradient_loss(d_pred, d_gt, d_mask)
return grad_term
since d_gt, d_pred, d_mask is not change during for loop, the what's the meaning of repeat compute the one_scale_gradient_loss ? they all have same behavier
from adelaidepth.
Same question
from adelaidepth.
Hi sorry for late response. @frischzenger you are right. It should be in your posted codes. This is a bug in my code.
from adelaidepth.
@YvanYin This bug is still on your release code.
from adelaidepth.
Related Issues (20)
- No module named 'lib' error in AdelaiDepth_ResNet101.ipynb HOT 2
- Where to find "SparseTensor"? HOT 1
- Infinit focal length!!! HOT 1
- Error occurred in LeReS HOT 1
- Error on 'Download' step of Google Collab HOT 3
- how to generate depth data like you provide? HOT 1
- About Taskonomy dataset camera camera intrinsics HOT 2
- Need Pretrained Parameters HOT 1
- Torchsparse v1.2.0 vs. v2.1.0 HOT 1
- Visualize with texture. HOT 1
- DIML dataset missing 'disp' data
- some dataset
- Questions about the training resolution and auxiliary network.
- Evaluation samples on ScanNet
- Docker for RTX class GPU for LeReS
- Problem in downloading Weights HOT 3
- Reconstructing the 3D point cloud when the intrinsic is known
- problem with TorchSparse version
- How to get instance planes HOT 1
- Empty .pth of Google Colab HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adelaidepth.