-
Notifications
You must be signed in to change notification settings - Fork 24
/
ssdnerf_cars_recons1v_16bit.py
187 lines (179 loc) · 5.37 KB
/
ssdnerf_cars_recons1v_16bit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name = 'ssdnerf_cars_recons1v_16bit'
model = dict(
type='DiffusionNeRF',
code_size=(3, 6, 128, 128),
code_reshape=(18, 128, 128),
code_activation=dict(
type='NormalizedTanhCode', mean=0.0, std=0.5, clip_range=2),
grid_size=64,
diffusion=dict(
type='GaussianDiffusion',
num_timesteps=1000,
betas_cfg=dict(type='linear'),
denoising=dict(
type='DenoisingUnetMod',
image_size=128,
in_channels=18,
base_channels=128,
channels_cfg=[1, 2, 2, 4, 4],
resblocks_per_downsample=2,
dropout=0.0,
use_scale_shift_norm=True,
downsample_conv=True,
upsample_conv=True,
num_heads=4,
attention_res=[32, 16, 8]),
timestep_sampler=dict(
type='SNRWeightedTimeStepSampler',
power=0.5),
ddpm_loss=dict(
type='DDPMMSELossMod',
rescale_mode='timestep_weight',
log_cfgs=dict(
type='quartile', prefix_name='loss_mse', total_timesteps=1000),
data_info=dict(pred='v_t_pred', target='v_t'),
weight_scale=20)),
decoder=dict(
type='TriPlaneDecoder',
interp_mode='bilinear',
base_layers=[6 * 3, 64],
density_layers=[64, 1],
color_layers=[64, 3],
use_dir_enc=True,
dir_layers=[16, 64],
activation='silu',
sigma_activation='trunc_exp',
sigmoid_saturation=0.001,
max_steps=256),
decoder_use_ema=True,
freeze_decoder=False,
bg_color=1,
pixel_loss=dict(
type='MSELoss',
loss_weight=20),
cache_size=2458,
cache_16bit=True)
save_interval = 5000
eval_interval = 20000
code_dir = 'cache/' + name + '/code'
work_dir = 'work_dirs/' + name
train_cfg = dict(
dt_gamma_scale=0.5,
density_thresh=0.1,
extra_scene_step=15,
n_inverse_rays=2 ** 12,
n_decoder_rays=2 ** 12,
loss_coef=0.1 / (128 * 128),
optimizer=dict(type='Adam', lr=0.04, weight_decay=0.),
cache_load_from=code_dir,
viz_dir=None)
test_cfg = dict(
img_size=(128, 128),
num_timesteps=75,
clip_range=[-2, 2],
density_thresh=0.1,
# max_render_rays=16 * 128 * 128,
dt_gamma_scale=0.5,
n_inverse_rays=2 ** 14,
override_cfg={'diffusion_ema.ddpm_loss.weight_scale': 5.0},
loss_coef=0.1 / (128 * 128),
guidance_gain=2.2 * (2 ** 14),
cond_mode='guide_optim',
n_inverse_steps=25,
extra_scene_step=3,
optimizer=dict(type='Adam', lr=0.02, weight_decay=0.),
lr_scheduler=dict(type='ExponentialLR', gamma=0.998)
)
optimizer = dict(
diffusion=dict(type='Adam', lr=1e-4, weight_decay=0.),
decoder=dict(type='Adam', lr=1e-3, weight_decay=0.))
dataset_type = 'ShapeNetSRN'
data = dict(
samples_per_gpu=8,
workers_per_gpu=1,
train=dict(
type=dataset_type,
data_prefix='data/shapenet/cars_train',
cache_path='data/shapenet/cars_train_cache.pkl'),
val_uncond=dict(
type=dataset_type,
data_prefix='data/shapenet/cars_test',
load_imgs=False,
num_test_imgs=251,
scene_id_as_name=True,
cache_path='data/shapenet/cars_test_cache.pkl'),
val_cond=dict(
type=dataset_type,
data_prefix='data/shapenet/cars_test',
specific_observation_idcs=[64],
cache_path='data/shapenet/cars_test_cache.pkl'),
train_dataloader=dict(split_data=True))
lr_config = dict(
policy='Fixed',
warmup='linear',
warmup_iters=500,
warmup_ratio=0.001)
checkpoint_config = dict(interval=save_interval, by_epoch=False, max_keep_ckpts=2)
evaluation = [
dict(
type='GenerativeEvalHook3D',
data='val_cond',
interval=eval_interval,
feed_batch_size=32,
viz_step=32,
metrics=dict(
type='FID',
num_images=704 * 250,
inception_pkl='work_dirs/cache/cars_test_inception_stylegan.pkl',
inception_args=dict(
type='StyleGAN',
inception_path='work_dirs/cache/inception-2015-12-05.pt'),
bgr2rgb=False), # already is rgb
viz_dir=work_dir + '/viz_cond',
save_best_ckpt=False)]
total_iters = 60000
log_config = dict(
interval=50,
hooks=[
dict(type='TextLoggerHook'),
dict(type='TensorboardLoggerHook'),
])
# yapf:enable
custom_hooks = [
dict(
type='ExponentialMovingAverageHook',
module_keys=('diffusion_ema', 'decoder_ema'),
interp_mode='lerp',
interval=1,
start_iter=0,
momentum_policy='rampup',
momentum_cfg=dict(
ema_kimg=4, ema_rampup=0.05, batch_size=16, eps=1e-8),
priority='VERY_HIGH'),
dict(
type='SaveCacheHook',
interval=save_interval,
by_epoch=False,
out_dir=code_dir,
viz_dir='cache/' + name + '/viz'),
dict(
type='ModelUpdaterHook',
step=[2000],
cfgs=[{'train_cfg.extra_scene_step': 3}],
by_epoch=False)
]
# use dynamic runner
runner = dict(
type='DynamicIterBasedRunner',
is_dynamic_ddp=False,
pass_training_status=True)
dist_params = dict(backend='nccl')
log_level = 'INFO'
load_from = None
resume_from = None
workflow = [('train', save_interval)]
use_ddp_wrapper = True
find_unused_parameters = False
cudnn_benchmark = True
opencv_num_threads = 0
mp_start_method = 'fork'