-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathauto_run_paramsets.py
More file actions
426 lines (366 loc) · 18.7 KB
/
Copy pathauto_run_paramsets.py
File metadata and controls
426 lines (366 loc) · 18.7 KB
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
import os
import pdb
import threading, queue
import numpy as np
import time
def getFolderLocker(logFolder):
while True:
try:
os.makedirs(logFolder+"/lockFolder")
break
except:
time.sleep(0.01)
def releaseFolderLocker(logFolder):
os.removedirs(logFolder+"/lockFolder")
def getStopFolder(logFolder):
return os.path.isdir(logFolder+"/stopFolder")
def get_param_str(key, val):
if key == 'data_name':
return f'--datadir {datafolder}/{val} '
else:
return f'--{key} {val} '
def get_param_list(param_dict):
param_keys = list(param_dict.keys())
param_modes = len(param_keys)
param_nums = [len(param_dict[key]) for key in param_keys]
param_ids = np.zeros(param_nums+[param_modes], dtype=int)
for i in range(param_modes):
broad_tuple = np.ones(param_modes, dtype=int).tolist()
broad_tuple[i] = param_nums[i]
broad_tuple = tuple(broad_tuple)
print(broad_tuple)
param_ids[...,i] = np.arange(param_nums[i]).reshape(broad_tuple)
param_ids = param_ids.reshape(-1, param_modes)
# print(param_ids)
print(len(param_ids), "scenes")
params = []
expnames = []
for i in range(param_ids.shape[0]):
one = ""
name = ""
param_id = param_ids[i]
for j in range(param_modes):
key = param_keys[j]
val = param_dict[key][param_id[j]]
if type(key) is tuple:
assert len(key) == len(val)
for k in range(len(key)):
one += get_param_str(key[k], val[k])
name += f'{val[k]},'
name=name[:-1]+'-'
else:
one += get_param_str(key, val)
name += f'{val}-'
params.append(one)
name=name.replace(' ','')
print(name)
expnames.append(name[:-1])
# print(params)
return params, expnames
if __name__ == '__main__':
# nerf
# expFolder = "nerf/"
# # parameters to iterate, use tuple to couple multiple parameters
# datafolder = '/mnt/new_disk_2/anpei/Dataset/nerf_synthetic/'
# param_dict = {
# 'data_name': ['ship', 'mic', 'chair', 'lego', 'drums', 'ficus', 'hotdog', 'materials'],
# 'data_dim_color': [13, 27, 54]
# }
# n_iters = 30000
# for data_name in ['Robot']:#'Bike','Lifestyle','Palace','Robot','Spaceship','Steamtrain','Toad','Wineholder'
# cmd = f'CUDA_VISIBLE_DEVICES={cuda} python train.py ' \
# f'--dataset_name nsvf --datadir /mnt/new_disk_2/anpei/Dataset/TeRF/Synthetic_NSVF/{data_name} '\
# f'--expname {data_name} --batch_size {batch_size} ' \
# f'--n_iters {n_iters} ' \
# f'--N_voxel_init {128**3} --N_voxel_final {300**3} '\
# f'--N_vis {5} ' \
# f'--n_lamb_sigma "[16,16,16]" --n_lamb_sh "[48,48,48]" ' \
# f'--upsamp_list "[2000, 3000, 4000, 5500,7000]" --update_AlphaMask_list "[3000,4000]" ' \
# f'--shadingMode MLP_Fea --fea2denseAct softplus --view_pe {2} --fea_pe {2} ' \
# f'--L1_weight_inital {8e-5} --L1_weight_rest {4e-5} --rm_weight_mask_thre {1e-4} --add_timestamp 0 ' \
# f'--render_test 1 '
# print(cmd)
# os.system(cmd)
# nsvf
# expFolder = "nsvf_0227/"
# datafolder = '/mnt/new_disk_2/anpei/Dataset/TeRF/Synthetic_NSVF/'
# param_dict = {
# 'data_name': ['Robot','Steamtrain','Bike','Lifestyle','Palace','Spaceship','Toad','Wineholder'],#'Bike','Lifestyle','Palace','Robot','Spaceship','Steamtrain','Toad','Wineholder'
# 'shadingMode': ['SH'],
# ('n_lamb_sigma', 'n_lamb_sh'): [ ("[8,8,8]", "[8,8,8]")],
# ('view_pe', 'fea_pe', 'featureC','fea2denseAct','N_voxel_init') : [(2, 2, 128, 'softplus',128**3)],
# ('L1_weight_inital', 'L1_weight_rest', 'rm_weight_mask_thre'):[(4e-5, 4e-5, 1e-4)],
# ('n_iters','N_voxel_final'): [(30000,300**3)],
# ('dataset_name','N_vis','render_test') : [("nsvf",5,1)],
# ('upsamp_list','update_AlphaMask_list'): [("[2000,3000,4000,5500,7000]","[3000,4000]")]
#
# }
# tankstemple
# expFolder = "tankstemple_0304/"
# datafolder = '/mnt/new_disk_2/anpei/Dataset/TeRF/TanksAndTemple/'
# param_dict = {
# 'data_name': ['Truck','Barn','Caterpillar','Family','Ignatius'],
# 'shadingMode': ['MLP_Fea'],
# ('n_lamb_sigma', 'n_lamb_sh'): [("[16,16,16]", "[48,48,48]")],
# ('view_pe', 'fea_pe','fea2denseAct','N_voxel_init','render_test') : [(2, 2, 'softplus',128**3,1)],
# ('TV_weight_density','TV_weight_app'):[(0.1,0.01)],
# # ('L1_weight_inital', 'L1_weight_rest', 'rm_weight_mask_thre'): [(4e-5, 4e-5, 1e-4)],
# ('n_iters','N_voxel_final'): [(15000,300**3)],
# ('dataset_name','N_vis') : [("tankstemple",5)],
# ('upsamp_list','update_AlphaMask_list'): [("[2000,3000,4000,5500,7000]","[2000,4000]")]
# }
# llff
# expFolder = "real_iconic/"
# datafolder = '/mnt/new_disk_2/anpei/Dataset/MVSNeRF/real_iconic/'
# List = os.listdir(datafolder)
# param_dict = {
# 'data_name': List,
# ('shadingMode', 'view_pe', 'fea_pe','fea2denseAct', 'nSamples','N_voxel_init') : [('MLP_Fea', 0, 0, 'relu',512,128**3)],
# ('n_lamb_sigma', 'n_lamb_sh') : [("[16,4,4]", "[48,12,12]")],
# ('TV_weight_density', 'TV_weight_app'):[(1.0,1.0)],
# ('n_iters','N_voxel_final'): [(25000,640**3)],
# ('dataset_name','downsample_train','ndc_ray','N_vis','render_path') : [("llff",4.0, 1,-1,1)],
# ('upsamp_list','update_AlphaMask_list'): [("[2000,3000,4000,5500,7000]","[2500]")],
# }
# expFolder = "llff/"
# datafolder = '/mnt/new_disk_2/anpei/Dataset/MVSNeRF/nerf_llff_data'
# param_dict = {
# 'data_name': ['fern', 'flower', 'room', 'leaves', 'horns', 'trex', 'fortress', 'orchids'],#'fern', 'flower', 'room', 'leaves', 'horns', 'trex', 'fortress', 'orchids'
# ('n_lamb_sigma', 'n_lamb_sh'): [("[16,4,4]", "[48,12,12]")],
# ('shadingMode', 'view_pe', 'fea_pe', 'featureC','fea2denseAct', 'nSamples','N_voxel_init') : [('MLP_Fea', 0, 0, 128, 'relu',512,128**3),('SH', 0, 0, 128, 'relu',512,128**3)],
# ('TV_weight_density', 'TV_weight_app'):[(1.0,1.0)],
# ('n_iters','N_voxel_final'): [(25000,640**3)],
# ('dataset_name','downsample_train','ndc_ray','N_vis','render_test','render_path') : [("llff",4.0, 1,-1,1,1)],
# ('upsamp_list','update_AlphaMask_list'): [("[2000,3000,4000,5500,7000]","[2500]")],
# }
# nsvf(jason)
# expFolder = "nsvf/"
# datafolder = '/work/Users/lisicheng/Dataset/Synthetic-NSVF/'
# param_dict = {
# 'data_name': ['Robot','Steamtrain','Bike','Lifestyle','Palace','Spaceship','Toad','Wineholder'],#'Bike','Lifestyle','Palace','Robot','Spaceship','Steamtrain','Toad','Wineholder'
# }
# falling_google(jason)
# expFolder = "falling_google/"
# datafolder = '/work/Users/lisicheng/Dataset/RTMV_all/falling_google_scenes/'
# #
# param_dict = {
# 'data_name': [f"{idx:05d}" for idx in range(50) ],#'Bike','Lifestyle','Palace','Robot','Spaceship','Steamtrain','Toad','Wineholder'
# }
#######################################################
# nerf-synthetic(tanh)
# expFolder = "nerf_synthetic_tanh_mlp_qat/"
# datafolder = '/work/Users/lisicheng/Dataset/Synthetic_NeRF_nerf/'
# #
# param_dict = {
# 'data_name': ['chair', 'lego'],
# }
# NeRFCodec ** nerf-synthetic(tanh)
expFolder = "NeRFCodec_nerf-syn/"
datafolder = '/work/Users/lisicheng/Dataset/Synthetic_NeRF_nerf/'
#
param_dict = {
'data_name': [ 'chair', 'drums', 'ficus', 'hotdog', 'lego', 'materials', 'mic', 'ship',], #'ship', 'mic', 'chair', 'lego', 'drums', 'ficus',
}
# # NeRFCodec ** nerf-synthetic(tanh)
# expFolder = "NeRFCodec_nerf-syn_384_1027/"
# datafolder = '/work/Users/lisicheng/Dataset/Synthetic_NeRF_nerf/'
# #
# param_dict = {
# 'data_name': [ 'mic'], #'ship', 'mic', 'chair', 'lego', 'drums', 'ficus',
# }
# NeRFCodec ** nerf-synthetic(tanh) - Finetune QAT
# expFolder = "NeRFCodec_nerf-syn_384_QAT_1106/"
# datafolder = '/work/Users/lisicheng/Dataset/Synthetic_NeRF_nerf/'
# #
# param_dict = {
# 'data_name': ['ship', 'mic', 'chair', 'lego', 'drums', 'ficus', 'materials'], #'ship', 'mic', 'chair', 'lego', 'drums', 'ficus',
# }
# # # NeRFCodec ** nerf-synthetic(tanh) - codec_adaptor 7bit quant
# expFolder = "NeRFCodec_nerf-syn_384_7bit_quant_0312/"
# datafolder = '/work/Users/lisicheng/Dataset/Synthetic_NeRF_nerf/'
# #
# param_dict = {
# 'data_name': ['chair', 'lego', 'ship', 'mic', 'drums', 'ficus', 'hotdog', 'materials'],
# }
# # NeRFCodec ** nerf-synthetic(tanh) - codec_adaptor 7bit quant - mlp 10 bit quant
# expFolder = "NeRFCodec_nerf-syn_codec_7bit_mlp_10bit_0314/"
# datafolder = '/work/Users/lisicheng/Dataset/Synthetic_NeRF_nerf/'
# #
# param_dict = {
# 'data_name': ['chair', 'lego',],
# }
#############################################################
# nsvf-synthetic(tanh)
# expFolder = "nsvf_synthetic_tanh_384/"
# datafolder = '/work/Users/lisicheng/Dataset/Synthetic-NSVF/'
# #
# param_dict = {
# 'data_name': ['Robot','Steamtrain','Bike','Lifestyle',
# 'Palace','Spaceship','Toad','Wineholder'],
# }
# NeRFCodec ** nsvf-synthetic(tanh)
# expFolder = "NeRFCodec_nsvf-syn_384_1102/"
# datafolder = '/work/Users/lisicheng/Dataset/Synthetic-NSVF/'
# #
# param_dict = {
# 'data_name': ['Wineholder'],
# }
# NeRFCodec ** nsvf-synthetic(tanh) - Finetune QAT
# expFolder = "NeRFCodec_nsvf-syn_384_QAT_1106/"
# datafolder = '/work/Users/lisicheng/Dataset/Synthetic-NSVF/'
# param_dict = {
# 'data_name': ['Robot','Steamtrain','Bike','Lifestyle',
# 'Palace','Spaceship','Toad','Wineholder']
# }
#############################################################
# tat(tanh)
# expFolder = "tat_tanh/"
# datafolder = '/work/Users/lisicheng/Dataset/TanksAndTemples/'
# #
# param_dict = {
# 'data_name': ['Barn',],
# 'data_name': ['Truck','Barn','Caterpillar','Family','Ignatius'],
# }
# NeRFCodec ** tat(tanh)
# expFolder = "NeRFCodec_tat_1029/"
# datafolder = '/work/Users/lisicheng/Dataset/TanksAndTemples/'
# #
# param_dict = {
# 'data_name': ['Barn'],
# }
# NeRFCodec ** tat(tanh) - Finetune QAT
# expFolder = "NeRFCodec_tat_384_QAT_1106/"
# datafolder = '/work/Users/lisicheng/Dataset/TanksAndTemples/'
# param_dict = {
# 'data_name': ['Truck','Barn','Caterpillar','Family','Ignatius'],
# }
#setting available gpus
gpus_que = queue.Queue()
for i in [1,2,3,4]: # for i in [0,1,2,3,4,5,6,7]:
gpus_que.put(i)
os.makedirs(f"log/{expFolder}", exist_ok=True)
def run_program(gpu, expname, param):
### NeRF-Synthetic: Pre-Training
# cmd = f'CUDA_VISIBLE_DEVICES={gpu} python train.py ' \
# f'--expname {expname} --basedir ./log/{expFolder} --config configs/chair.txt ' \
# f'{param}' \
# f'> "log/{expFolder}{expname}/{expname}.txt"'
### NeRF-Synthetic: Joint Training
cmd = f'CUDA_VISIBLE_DEVICES={gpu} python train.py ' \
f'--expname {expname} --basedir ./log/{expFolder} --config configs/chair_codec.txt ' \
f'--ckpt log/nerf_synthetic_tanh/{expname}/{expname}.th ' \
f'{param}' \
f'--compression --render_test 1 --batch_size 65536 ' \
f'--codec_training --compression_strategy adaptor_feat_coding ' \
f'--lr_feat_codec 2e-4 --lr_aux 1e-3 --lr_decay_target_ratio 1 ' \
f'--fix_decoder_prior --compress_before_volrend --rate_penalty ' \
f'--warm_up ' \
f'--shadingMode MLP_Fea_Q ' \
f'> "log/{expFolder}{expname}/{expname}.txt"'
# 65536 -> 49152 -> 32768
# f'--adaptor_q_bit 7 ' \
# f'--vec_qat ' \
### NeRF-Synthetic: Finetune with QAT
# cmd = f'CUDA_VISIBLE_DEVICES={gpu} python train.py ' \
# f'--expname {expname} --basedir ./log/{expFolder} --config configs/chair_codec_384.txt ' \
# f'--ckpt log/nerf_synthetic_tanh_384/{expname}/{expname}.th ' \
# f'{param}' \
# f'--compression --render_test 1 --batch_size 65536 ' \
# f'--codec_training --compression_strategy adaptor_feat_coding ' \
# f'--lr_feat_codec 2e-4 --lr_aux 1e-3 --lr_decay_target_ratio 1 ' \
# f'--fix_decoder_prior --compress_before_volrend --rate_penalty ' \
# f'--lr_decay_target_ratio 1 ' \
# f'--n_iters 10000 --vis_every 1000 ' \
# f'--system_ckpt log/NeRFCodec_nerf-syn_384_1027/{expname}/{expname}_compression.th ' \
# f'--resume_finetune --additional_vec --vec_qat ' \
# f'--shadingMode MLP_Fea_Q ' \
# f'> "log/{expFolder}{expname}/{expname}.txt"'
### NSVF-Synthetic: Pre-Training
# cmd = f'CUDA_VISIBLE_DEVICES={gpu} python train.py ' \
# f'--expname {expname} --basedir ./log/{expFolder} --config configs/wineholder_384.txt ' \
# f'{param}' \
# f'> "log/{expFolder}{expname}/{expname}.txt"'
### NSVF-Synthetic: Joint Training
# cmd = f'CUDA_VISIBLE_DEVICES={gpu} python train.py ' \
# f'--expname {expname} --basedir ./log/{expFolder} --config configs/wineholder_codec_384.txt ' \
# f'--ckpt log/nsvf_synthetic_tanh_384/{expname}/{expname}.th ' \
# f'{param}' \
# f'--compression --render_test 1 --batch_size 65536 ' \
# f'--codec_training --compression_strategy adaptor_feat_coding ' \
# f'--lr_feat_codec 2e-4 --lr_aux 1e-3 --lr_decay_target_ratio 1 ' \
# f'--fix_decoder_prior --compress_before_volrend --rate_penalty ' \
# f'--warm_up ' \
# f'> "log/{expFolder}{expname}/{expname}.txt"'
### NSVF-Synthetic: Finetune with QAT
# cmd = f'CUDA_VISIBLE_DEVICES={gpu} python train.py ' \
# f'--expname {expname} --basedir ./log/{expFolder} --config configs/wineholder_codec_384.txt ' \
# f'--ckpt log/nsvf_synthetic_tanh_384/{expname}/{expname}.th ' \
# f'{param}' \
# f'--compression --render_test 1 --batch_size 65536 ' \
# f'--codec_training --compression_strategy adaptor_feat_coding ' \
# f'--lr_feat_codec 2e-4 --lr_aux 1e-3 --lr_decay_target_ratio 1 ' \
# f'--fix_decoder_prior --compress_before_volrend --rate_penalty ' \
# f'--lr_decay_target_ratio 1 ' \
# f'--n_iters 10000 --vis_every 1000 ' \
# f'--system_ckpt log/NeRFCodec_nsvf-syn_384_1102/{expname}/{expname}_compression.th ' \
# f'--resume_finetune --additional_vec --vec_qat ' \
# f'--shadingMode MLP_Fea_Q ' \
# f'> "log/{expFolder}{expname}/{expname}.txt"'
### Tat: Pre-Training
# cmd = f'CUDA_VISIBLE_DEVICES={gpu} python train.py ' \
# f'--expname {expname} --basedir ./log/{expFolder} --config configs/truck.txt ' \
# f'{param}' \
# f'> "log/{expFolder}{expname}/{expname}.txt"'
### Tat: Joint Training
# cmd = f'CUDA_VISIBLE_DEVICES={gpu} python train.py ' \
# f'--expname {expname} --basedir ./log/{expFolder} --config configs/truck_codec.txt ' \
# f'--ckpt log/tat_tanh/{expname}/{expname}.th ' \
# f'{param}' \
# f'--compression --render_test 1 --batch_size 32768 ' \
# f'--codec_training --compression_strategy adaptor_feat_coding ' \
# f'--lr_feat_codec 2e-4 --lr_aux 1e-3 --lr_decay_target_ratio 1 ' \
# f'--fix_decoder_prior --compress_before_volrend --rate_penalty ' \
# f'--warm_up ' \
# f'> "log/{expFolder}{expname}/{expname}.txt"'
# 65536 -> 49152 -> 32768
### Tat: Finetune with QAT
# cmd = f'CUDA_VISIBLE_DEVICES={gpu} python train.py ' \
# f'--expname {expname} --basedir ./log/{expFolder} --config configs/truck_codec_384.txt ' \
# f'--ckpt log/tat_tanh_384/{expname}/{expname}.th ' \
# f'{param}' \
# f'--compression --render_test 1 --batch_size 32768 ' \
# f'--codec_training --compression_strategy adaptor_feat_coding ' \
# f'--lr_feat_codec 2e-4 --lr_aux 1e-3 --lr_decay_target_ratio 1 ' \
# f'--fix_decoder_prior --compress_before_volrend --rate_penalty ' \
# f'--lr_decay_target_ratio 1 ' \
# f'--n_iters 10000 --vis_every 1000 ' \
# f'--system_ckpt log/NeRFCodec_tat_384_1029/{expname}/{expname}_compression.th ' \
# f'--resume_finetune --additional_vec --vec_qat ' \
# f'--shadingMode MLP_Fea_Q ' \
# f'> "log/{expFolder}{expname}/{expname}.txt"'
print(cmd)
os.system(cmd)
gpus_que.put(gpu)
params, expnames = get_param_list(param_dict)
logFolder=f"log/{expFolder}"
os.makedirs(logFolder, exist_ok=True)
ths = []
for i in range(len(params)):
if getStopFolder(logFolder):
break
targetFolder = f"log/{expFolder}{expnames[i]}"
gpu = gpus_que.get()
getFolderLocker(logFolder)
if os.path.isdir(targetFolder):
releaseFolderLocker(logFolder)
gpus_que.put(gpu)
continue
else:
os.makedirs(targetFolder, exist_ok=True)
print("making",targetFolder, "running",expnames[i], params[i])
releaseFolderLocker(logFolder)
t = threading.Thread(target=run_program, args=(gpu, expnames[i], params[i]), daemon=True)
t.start()
ths.append(t)
for th in ths:
th.join()