Skip to content

Commit e093f36

Browse files
committed
Clean up
1 parent ccf3f12 commit e093f36

16 files changed

+145
-1392
lines changed

configs/decompose/train.gin

-13
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ TrainConfig.log_every = 100
3232
TrainConfig.histogram_every = 100
3333
TrainConfig.save_every = 2000
3434
TrainConfig.use_background_loss = False
35-
TrainConfig.use_bg_decompose_loss = False
36-
TrainConfig.bg_decompose_loss_weight = 1.0
3735
# TrainConfig.blendw_loss_weight = 0.001
3836
# TrainConfig.blendw_loss_weight_schedule = ('constant', 0.001)
3937
TrainConfig.blendw_loss_weight_schedule = {
@@ -43,20 +41,9 @@ TrainConfig.blendw_loss_weight_schedule = {
4341
'num_steps': 200000,
4442
}
4543
TrainConfig.blendw_loss_skewness = 1.25
46-
TrainConfig.blendw_pixel_loss_weight_schedule = ('constant', 0.0)
47-
TrainConfig.blendw_ray_loss_weight = 0.001
48-
TrainConfig.blendw_ray_loss_threshold = .5
4944
TrainConfig.use_ex_ray_entropy_loss = True
5045
TrainConfig.blendw_area_loss_weight = 0.0001
51-
TrainConfig.shadow_loss_threshold = 0.2
52-
TrainConfig.shadow_loss_weight = 0.
53-
TrainConfig.blendw_sample_loss_weight = 0.
5446

55-
# initialize static model for some iterations first
56-
TrainConfig.fix_blendw_steps = 0
57-
TrainConfig.force_blendw_steps = 0
58-
TrainConfig.force_blendw_loss_weight = .1
59-
TrainConfig.fix_blendw_value = 0.15
6047

6148
DecomposeNerfModel.blend_mode = 'nsff'
6249
DecomposeNerfModel.extra_renders = ('static_full', 'dynamic', 'blendw')

configs/decompose/train_kubric_template.gin

-6
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,8 @@ TrainConfig.blendw_loss_weight_schedule = {
2323
'num_steps': 75000 #%max_steps,
2424
}
2525
TrainConfig.blendw_loss_skewness = 2.5
26-
TrainConfig.blendw_ray_loss_weight = 0.
27-
TrainConfig.blendw_ray_loss_threshold = .5
2826
TrainConfig.use_ex_ray_entropy_loss = False
2927
TrainConfig.blendw_area_loss_weight = 0.00001
30-
TrainConfig.shadow_loss_threshold = 0.2
31-
TrainConfig.shadow_loss_weight = 0.
32-
TrainConfig.blendw_sample_loss_weight = 0.
3328

3429
DecomposeNerfModel.separate_shadow_model = True
3530
# TrainConfig.shadow_r_loss_weight = ('constant', 0.01)
@@ -39,7 +34,6 @@ TrainConfig.shadow_r_loss_weight = {
3934
'final_value': 0.1,
4035
'num_steps': 100000 #%max_steps,
4136
}
42-
TrainConfig.shadow_r_l2_loss_weight = 0.01
4337
DecomposeNerfModel.sigma_threshold = 0.1
4438
DecomposeNerfModel.shadow_r_shift = 0.
4539

configs/decompose/train_lf_template.gin

-14
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,8 @@ TrainConfig.blendw_loss_weight_schedule = {
2222
}
2323
TrainConfig.blendw_loss_skewness = 3.0
2424

25-
# TrainConfig.blendw_pixel_loss_weight_schedule = {
26-
# 'type': 'exp_increase',
27-
# 'initial_value': 1e-06,
28-
# 'final_value': 0.01,
29-
# 'num_steps': 100000,
30-
# }
31-
# TrainConfig.blendw_pixel_loss_skewness = 1.0
32-
33-
TrainConfig.blendw_ray_loss_weight = 0.
34-
TrainConfig.blendw_ray_loss_threshold = .5
3525
TrainConfig.use_ex_ray_entropy_loss = False
3626
TrainConfig.blendw_area_loss_weight = 0.0001
37-
TrainConfig.shadow_loss_threshold = 0.2
38-
TrainConfig.shadow_loss_weight = 0.
39-
TrainConfig.blendw_sample_loss_weight = 0.
4027
TrainConfig.sigma_s_ray_loss_weight = 0.0
4128

4229
DecomposeNerfModel.separate_shadow_model = True
@@ -48,7 +35,6 @@ TrainConfig.shadow_r_loss_weight = {
4835
(0, ('linear', 0.0005, 1.0, 90000))
4936
],
5037
}
51-
TrainConfig.shadow_r_l2_loss_weight = 0.
5238
DecomposeNerfModel.sigma_threshold = 0.1
5339
DecomposeNerfModel.shadow_r_shift = 0.
5440

configs/rl/001.gin

-6
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,8 @@ TrainConfig.blendw_loss_weight_schedule = {
2222
}
2323
TrainConfig.blendw_loss_skewness = 1.75
2424

25-
TrainConfig.blendw_ray_loss_weight = 0.
26-
TrainConfig.blendw_ray_loss_threshold = .5
2725
TrainConfig.use_ex_ray_entropy_loss = False
2826
TrainConfig.blendw_area_loss_weight = 0.001
29-
TrainConfig.shadow_loss_threshold = 0.2
30-
TrainConfig.shadow_loss_weight = 0.
31-
TrainConfig.blendw_sample_loss_weight = 0.
3227

3328
DecomposeNerfModel.separate_shadow_model = True
3429
TrainConfig.shadow_r_loss_weight = {
@@ -37,7 +32,6 @@ TrainConfig.shadow_r_loss_weight = {
3732
'final_value': 0.1,
3833
'num_steps': 100000 #%max_steps,
3934
}
40-
TrainConfig.shadow_r_l2_loss_weight = 0.01
4135
DecomposeNerfModel.sigma_threshold = 0.1
4236
DecomposeNerfModel.shadow_r_shift = 0.
4337

configs/rl/002.gin

-6
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,8 @@ TrainConfig.blendw_loss_weight_schedule = {
2121
}
2222
TrainConfig.blendw_loss_skewness = 3.0
2323

24-
TrainConfig.blendw_ray_loss_weight = 0.
25-
TrainConfig.blendw_ray_loss_threshold = .5
2624
TrainConfig.use_ex_ray_entropy_loss = False
2725
TrainConfig.blendw_area_loss_weight = 0.0001
28-
TrainConfig.shadow_loss_threshold = 0.2
29-
TrainConfig.shadow_loss_weight = 0.
30-
TrainConfig.blendw_sample_loss_weight = 0.
3126
TrainConfig.sigma_s_ray_loss_weight = 0.001
3227

3328
DecomposeNerfModel.separate_shadow_model = True
@@ -37,7 +32,6 @@ TrainConfig.shadow_r_loss_weight = {
3732
'final_value': 0.1,
3833
'num_steps': 100000 #%max_steps,
3934
}
40-
TrainConfig.shadow_r_l2_loss_weight = 0.
4135
DecomposeNerfModel.sigma_threshold = 0.1
4236
DecomposeNerfModel.shadow_r_shift = 0.
4337

configs/rl/005.gin

-12
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,16 @@ TrainConfig.blendw_loss_weight_schedule = {
2323
'num_steps': 100000,
2424
}
2525
TrainConfig.blendw_loss_skewness = 1.5
26-
TrainConfig.blendw_ray_loss_weight = 0
27-
TrainConfig.blendw_ray_loss_threshold = .5
2826
TrainConfig.use_ex_ray_entropy_loss = False
2927
TrainConfig.blendw_area_loss_weight = 0.1
3028
TrainConfig.sigma_s_ray_loss_weight = 0.0
31-
TrainConfig.shadow_loss_threshold = 0.2
32-
TrainConfig.shadow_loss_weight = 0.
33-
TrainConfig.blendw_sample_loss_weight = 0.
3429
TrainConfig.sigma_s_ray_loss_weight = 0.01
3530

3631
DecomposeNerfModel.separate_shadow_model = True
3732
# TrainConfig.shadow_r_loss_weight = ('constant', 0.01)
3833
TrainConfig.shadow_r_loss_weight = ('constant', 0.01)
3934

40-
# TrainConfig.shadow_r_consistency_loss_weight_schedule = {
41-
# 'type': 'linear',
42-
# 'initial_value': 0.00001,
43-
# 'final_value': 0.1,
44-
# 'num_steps': 50000 #%max_steps,
45-
# }
4635

47-
TrainConfig.shadow_r_l2_loss_weight = 0.0
4836
DecomposeNerfModel.sigma_threshold = 0.1
4937
DecomposeNerfModel.shadow_r_shift = 0.
5038

configs/synthetic/002.gin

-5
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,8 @@ TrainConfig.blendw_loss_weight_schedule = {
2222
'num_steps': 75000 #%max_steps,
2323
}
2424
TrainConfig.blendw_loss_skewness = 1.25
25-
TrainConfig.blendw_ray_loss_weight = 0.
26-
TrainConfig.blendw_ray_loss_threshold = .5
2725
TrainConfig.use_ex_ray_entropy_loss = False
2826
TrainConfig.blendw_area_loss_weight = 0.0001
29-
TrainConfig.shadow_loss_threshold = 0.2
30-
TrainConfig.shadow_loss_weight = 0.
31-
TrainConfig.blendw_sample_loss_weight = 0.
3227

3328

3429
EvalConfig.niter_runtime_eval = 10000

hypernerf/configs.py

+2-42
Original file line numberDiff line numberDiff line change
@@ -102,43 +102,17 @@ class TrainConfig:
102102
elastic_loss_type: str = 'log_svals'
103103
# Whether to use background regularization.
104104
use_background_loss: bool = False
105-
# Whether to use background decompose loss. This loss is only defined for DecomposeNerfModel
106-
use_bg_decompose_loss: bool = False
107-
# The weight for the background loss.
108105
background_loss_weight: float = 0.0
109-
bg_decompose_loss_weight: float = 0.0
110106
# Adaptive blendw loss weight setting
111107
blendw_loss_weight_schedule: Optional[ScheduleDef] = None
112-
# Adaptive blendw loss weight setting
113-
blendw_pixel_loss_weight_schedule: Optional[ScheduleDef] = immutabledict.immutabledict({
114-
'type': 'constant',
115-
'value': 0.0,
116-
})
117108
blendw_loss_skewness: float = 1.0
118-
blendw_pixel_loss_skewness: float = 1.0
119-
force_blendw_loss_weight: float = 1.0
120-
blendw_ray_loss_weight: float = 0.0
121109
sigma_s_ray_loss_weight: float = 0.0
122-
sigma_d_ray_loss_weight: float = 0.0
123110
blendw_area_loss_weight: float = 0.0
124-
blendw_ray_loss_threshold: float = 1.0
125-
shadow_loss_threshold: float = 0.2
126-
shadow_loss_weight: float = 0.0
127-
blendw_sample_loss_weight: float = 0.0
128111
shadow_r_loss_weight: Optional[ScheduleDef] = immutabledict.immutabledict({
129112
'type': 'constant',
130113
'value': 0.0,
131114
})
132-
cubic_shadow_r_loss_weight_schedule: Optional[ScheduleDef] = immutabledict.immutabledict({
133-
'type': 'constant',
134-
'value': 0.0,
135-
})
136-
shadow_r_consistency_loss_weight_schedule: Optional[ScheduleDef] = immutabledict.immutabledict({
137-
'type': 'constant',
138-
'value': 0.0,
139-
})
140-
shadow_r_l2_loss_weight: float = 0.0
141-
blendw_spatial_loss_weight: float = 0.0
115+
142116
# The batch size for background regularization loss.
143117
background_points_batch_size: int = 16384
144118
# Whether to use the warp reg loss.
@@ -177,21 +151,9 @@ class TrainConfig:
177151
# Use decompose NeRF or not
178152
use_decompose_nerf: bool = False
179153

180-
# Initialize the static model for several iterations first
181-
# During this, dynamic model would be frozen
182-
freeze_dynamic_steps: int = 0
183-
# Fix blendw to certain values for a fixed number of iters
184-
fix_blendw_steps: int = 0
185-
# Encourage the predicted blendw to be close to a certain value for some iters
186-
# This is different to fixing the value
187-
force_blendw_steps: int = 0
188-
fix_blendw_value: float = 0.25
189-
190-
# Use provided dynmaic object mask to separately train the dynamic and static component
191-
use_mask_sep_train: bool = False
192-
193154
# Regularize the decompose model using rays combined with different time frame
194155
use_ex_ray_entropy_loss: bool = False
156+
use_lap_blendw_loss: bool = False
195157

196158
@gin.configurable()
197159
@dataclasses.dataclass
@@ -234,8 +196,6 @@ class EvalConfig:
234196
# Evalution setting for fixed time circulating camera experiments
235197
novel_view_eval: bool = False
236198

237-
# test_time_id: int = 0
238-
239199
# Evalution setting for fixed view varying time experiments
240200
fix_view_eval: bool = False
241201
# Number of views rendered for each fixed time frame

hypernerf/datasets/core.py

-21
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ def __init__(self,
215215
use_camera_id=False,
216216
use_warp_id=False,
217217
use_depth=False,
218-
use_mask=False,
219218
mask_interest_region=False,
220219
use_relative_depth=False,
221220
use_time=False,
@@ -233,7 +232,6 @@ def __init__(self,
233232
self.use_warp_id = use_warp_id
234233
self.use_depth = use_depth
235234
self.use_time = use_time
236-
self.use_mask = use_mask
237235
self.mask_interest_region = mask_interest_region
238236
self.use_relative_depth = use_relative_depth
239237
self.rng = np.random.RandomState(random_seed)
@@ -489,25 +487,6 @@ def _prepare_array(x):
489487

490488
dataset = tf.data.Dataset.from_tensor_slices(out_dict)
491489

492-
if self.use_mask:
493-
# separate two datasets, one with all rays that are on static background and the other for dynamic object
494-
static_ray_ids = (out_dict['mask'][:,0]==0).nonzero()[0]
495-
dynamic_ray_ids = np.setdiff1d(np.arange(num_rays), static_ray_ids)
496-
static_dict = {}
497-
dynamic_dict = {}
498-
for key, value in out_dict.items():
499-
static_dict[key] = jax.tree_map(lambda x: x[static_ray_ids], value)
500-
dynamic_dict[key] = jax.tree_map(lambda x: x[dynamic_ray_ids], value)
501-
502-
static_data = tf.data.Dataset.from_tensor_slices(static_dict).repeat().batch(batch_size)
503-
dynamic_data = tf.data.Dataset.from_tensor_slices(dynamic_dict).repeat().batch(batch_size)
504-
505-
zipped = tf.data.Dataset.zip((static_data, dynamic_data))
506-
dataset = zipped.flat_map(lambda x0, x1: tf.data.Dataset.from_tensors(x0).concatenate(tf.data.Dataset.from_tensors(x1)))
507-
dataset = dataset.unbatch()
508-
509-
# dataset = tf.data.Dataset.from_tensor_slices(static_dict)
510-
511490
return dataset
512491

513492
def _create_lazy_dataset(self,

hypernerf/model_utils.py

-13
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ class TrainState:
3333
warp_alpha: Optional[jnp.ndarray] = None
3434
hyper_alpha: Optional[jnp.ndarray] = None
3535
hyper_sheet_alpha: Optional[jnp.ndarray] = None
36-
# not implemented modification
37-
# render_mode: jnp.ndarray = jnp.array([RENDER_MODE['regular']])
38-
freeze_static: jnp.ndarray = jnp.array([False])
39-
freeze_dynamic: jnp.ndarray = jnp.array([False])
40-
freeze_blendw: jnp.ndarray = jnp.array([False])
41-
force_blendw: jnp.ndarray = jnp.array([False])
42-
freeze_blendw_value: jnp.ndarray = jnp.array([0.5])
4336

4437
@property
4538
def extra_params(self):
@@ -48,12 +41,6 @@ def extra_params(self):
4841
'warp_alpha': self.warp_alpha,
4942
'hyper_alpha': self.hyper_alpha,
5043
'hyper_sheet_alpha': self.hyper_sheet_alpha,
51-
# 'render_mode': self.render_mode,
52-
'freeze_static': self.freeze_static,
53-
'freeze_dynamic': self.freeze_dynamic,
54-
'freeze_blendw': self.freeze_blendw,
55-
'force_blendw': self.force_blendw,
56-
'freeze_blendw_value': self.freeze_blendw_value
5744
}
5845

5946

0 commit comments

Comments
 (0)