mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-05 15:28:49 +08:00
padding changes, some params
This commit is contained in:
1 parent
88748050d2
commit
95793f5313
3 files changed
+21
-19
No files matched your search
@@ -83,7 +83,7 @@ method_configs["nerfacto"] = TrainerConfig(
|
|||||||
pipeline=VanillaPipelineConfig(
|
pipeline=VanillaPipelineConfig(
|
||||||
datamanager=VanillaDataManagerConfig(
|
datamanager=VanillaDataManagerConfig(
|
||||||
dataparser=NerfstudioDataParserConfig(),
|
dataparser=NerfstudioDataParserConfig(),
|
||||||
train_num_rays_per_batch=16000,
|
train_num_rays_per_batch=17000,
|
||||||
eval_num_rays_per_batch=4096,
|
eval_num_rays_per_batch=4096,
|
||||||
camera_optimizer=CameraOptimizerConfig(
|
camera_optimizer=CameraOptimizerConfig(
|
||||||
mode="SO3xR3", optimizer=AdamOptimizerConfig(lr=6e-4, eps=1e-8, weight_decay=1e-2)
|
mode="SO3xR3", optimizer=AdamOptimizerConfig(lr=6e-4, eps=1e-8, weight_decay=1e-2)
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ class VanillaDataManager(DataManager): # pylint: disable=abstract-method
|
|||||||
# Otherwise, use the default pixel sampler
|
# Otherwise, use the default pixel sampler
|
||||||
if is_equirectangular.any():
|
if is_equirectangular.any():
|
||||||
CONSOLE.print("[bold yellow]Warning: Some cameras are equirectangular, but using default pixel sampler.")
|
CONSOLE.print("[bold yellow]Warning: Some cameras are equirectangular, but using default pixel sampler.")
|
||||||
return PatchPixelSampler(*args, **kwargs,patch_size=8)
|
return PatchPixelSampler(*args, **kwargs,patch_size=16)
|
||||||
|
|
||||||
def setup_train(self):
|
def setup_train(self):
|
||||||
"""Sets up the data loaders for training"""
|
"""Sets up the data loaders for training"""
|
||||||
|
|||||||
@@ -303,26 +303,28 @@ def depth_loss(
|
|||||||
|
|
||||||
raise NotImplementedError("Provided depth loss type not implemented.")
|
raise NotImplementedError("Provided depth loss type not implemented.")
|
||||||
|
|
||||||
def robust_rgb_loss(rgb_gt,rgb_outputs,patch_size=8):
|
def robust_rgb_loss(rgb_gt,rgb_outputs,patch_size=16):
|
||||||
out_patches = rgb_outputs.view(-1,1,patch_size,patch_size,3)
|
out_patches = rgb_outputs.view(-1,1,patch_size,patch_size,3)
|
||||||
gt_patches = rgb_gt.view(-1,1,patch_size,patch_size,3)
|
gt_patches = rgb_gt.view(-1,1,patch_size,patch_size,3)
|
||||||
device = rgb_outputs.device
|
device = rgb_outputs.device
|
||||||
batch_size = out_patches.shape[0]
|
batch_size = out_patches.shape[0]
|
||||||
residuals = torch.mean((out_patches - gt_patches)**2,dim=-1)
|
residuals = torch.mean((out_patches - gt_patches)**2,dim=-1)
|
||||||
# with torch.no_grad():
|
with torch.no_grad():
|
||||||
med_residual = torch.median(residuals)
|
med_residual = torch.quantile(residuals,.9)
|
||||||
#equation 8
|
#equation 8
|
||||||
weight = (residuals<=med_residual).float()
|
weight = (residuals<=med_residual).float()#B x patch x patch
|
||||||
#equation 9
|
#equation 9
|
||||||
blurred_w = (torch.nn.functional.conv2d(weight,(1/9.)*torch.ones((1,1,3,3),device=device),padding='same')>=0.5).float()
|
weight = torch.nn.functional.pad(weight,(1,1,1,1),mode='replicate')
|
||||||
# expected_w = torch.mean(torch.mean(blurred_w,dim=-1),dim=-1)
|
blurred_w = (torch.nn.functional.conv2d(weight,(1/9.)*torch.ones((1,1,3,3),device=device),
|
||||||
#equation 10
|
padding='valid')>=0.5).float()
|
||||||
# weight_r8 = (expected_w > 0.6).float()
|
#equation 10
|
||||||
# w_8x8 = weight_r8[...,None] * torch.ones((batch_size,8,8),device=device)
|
expected_w = blurred_w.view(batch_size,-1).mean(1)
|
||||||
# final_w = torch.zeros((batch_size,patch_size,patch_size),device=device)
|
weight_r8 = (expected_w >= 0.6).float() #Bx1
|
||||||
# final_w[:,
|
#the paper uses the lines below and multiplies residuals by final_w, but I found that just using
|
||||||
# (patch_size//2-patch_size//4):(patch_size//2+patch_size//4),
|
#the value for all 16 pixels worked better.
|
||||||
# (patch_size//2-patch_size//4):(patch_size//2+patch_size//4)] = w_8x8
|
# final_w = torch.zeros((batch_size,patch_size,patch_size),device=device)
|
||||||
# loss = torch.mean(residuals.squeeze()*blurred_w)
|
# final_w[:,
|
||||||
loss = torch.mean(residuals.squeeze()*blurred_w)
|
# (patch_size//2-patch_size//4):(patch_size//2+patch_size//4),
|
||||||
|
# (patch_size//2-patch_size//4):(patch_size//2+patch_size//4)] = weight_r8[:,None,None]
|
||||||
|
# loss = torch.mean(residuals.squeeze()*weight_r8[:,None,None])
|
||||||
return loss
|
return loss
|
||||||
Reference in new issue
Block a user