mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-05 07:18:57 +08:00
messing with params
This commit is contained in:
1 parent
177b86d490
commit
88748050d2
4 files changed
+21
-22
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=8192,
|
train_num_rays_per_batch=16000,
|
||||||
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=16)
|
return PatchPixelSampler(*args, **kwargs,patch_size=8)
|
||||||
|
|
||||||
def setup_train(self):
|
def setup_train(self):
|
||||||
"""Sets up the data loaders for training"""
|
"""Sets up the data loaders for training"""
|
||||||
|
|||||||
@@ -303,24 +303,26 @@ 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=16):
|
def robust_rgb_loss(rgb_gt,rgb_outputs,patch_size=8):
|
||||||
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.median(residuals)
|
||||||
#equation 8
|
#equation 8
|
||||||
weight = (residuals<med_residual).float()
|
weight = (residuals<=med_residual).float()
|
||||||
#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()
|
blurred_w = (torch.nn.functional.conv2d(weight,(1/9.)*torch.ones((1,1,3,3),device=device),padding='same')>=0.5).float()
|
||||||
expected_w = torch.mean(torch.mean(blurred_w,dim=-1),dim=-1)
|
# expected_w = torch.mean(torch.mean(blurred_w,dim=-1),dim=-1)
|
||||||
#equation 10
|
#equation 10
|
||||||
weight_r8 = (expected_w > 0.6).float()
|
# weight_r8 = (expected_w > 0.6).float()
|
||||||
w_8x8 = weight_r8[...,None] * torch.ones((batch_size,8,8),device=device)
|
# w_8x8 = weight_r8[...,None] * torch.ones((batch_size,8,8),device=device)
|
||||||
final_w = torch.zeros((batch_size,patch_size,patch_size),device=device)
|
# final_w = torch.zeros((batch_size,patch_size,patch_size),device=device)
|
||||||
final_w[:,
|
# final_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),
|
||||||
(patch_size//2-patch_size//4):(patch_size//2+patch_size//4)] = w_8x8
|
# (patch_size//2-patch_size//4):(patch_size//2+patch_size//4)] = w_8x8
|
||||||
return torch.mean(residuals.squeeze()*final_w)
|
# loss = torch.mean(residuals.squeeze()*blurred_w)
|
||||||
|
loss = torch.mean(residuals.squeeze()*blurred_w)
|
||||||
|
return loss
|
||||||
@@ -186,8 +186,7 @@ class NerfactoModel(Model):
|
|||||||
# renderers
|
# renderers
|
||||||
self.renderer_rgb = RGBRenderer(background_color=self.config.background_color)
|
self.renderer_rgb = RGBRenderer(background_color=self.config.background_color)
|
||||||
self.renderer_accumulation = AccumulationRenderer()
|
self.renderer_accumulation = AccumulationRenderer()
|
||||||
self.renderer_depth = DepthRenderer(method='expected')
|
self.renderer_depth = DepthRenderer()
|
||||||
self.renderer_truncdepth = DepthRenderer(method='median')
|
|
||||||
self.renderer_normals = NormalsRenderer()
|
self.renderer_normals = NormalsRenderer()
|
||||||
|
|
||||||
# shaders
|
# shaders
|
||||||
@@ -264,8 +263,6 @@ class NerfactoModel(Model):
|
|||||||
"accumulation": accumulation,
|
"accumulation": accumulation,
|
||||||
"depth": depth,
|
"depth": depth,
|
||||||
}
|
}
|
||||||
with torch.no_grad():
|
|
||||||
outputs['depth_truncated']=self.renderer_truncdepth(weights=weights, ray_samples=ray_samples)
|
|
||||||
|
|
||||||
if self.config.predict_normals:
|
if self.config.predict_normals:
|
||||||
normals = self.renderer_normals(normals=field_outputs[FieldHeadNames.NORMALS], weights=weights)
|
normals = self.renderer_normals(normals=field_outputs[FieldHeadNames.NORMALS], weights=weights)
|
||||||
|
|||||||
Reference in new issue
Block a user