MCPcopy Create free account
hub / github.com/NVlabs/InstantSplat / training_report

Function training_report

train.py:256–295  ·  view source on GitHub ↗
(tb_writer, iteration, Ll1, loss, l1_loss, elapsed, testing_iterations, scene : Scene, renderFunc, renderArgs)

Source from the content-addressed store, hash-verified

254 return tb_writer
255
256def training_report(tb_writer, iteration, Ll1, loss, l1_loss, elapsed, testing_iterations, scene : Scene, renderFunc, renderArgs):
257 if tb_writer:
258 tb_writer.add_scalar('train_loss_patches/l1_loss', Ll1.item(), iteration)
259 tb_writer.add_scalar('train_loss_patches/total_loss', loss.item(), iteration)
260 tb_writer.add_scalar('iter_time', elapsed, iteration)
261
262 # Report test and samples of training set
263 if iteration in testing_iterations or iteration % 5000 == 0:
264 torch.cuda.empty_cache()
265 validation_configs = ({'name': 'test', 'cameras' : scene.getTestCameras()},
266 {'name': 'train', 'cameras' : [scene.getTrainCameras()[idx % len(scene.getTrainCameras())] for idx in range(len(scene.getTrainCameras()))]})
267
268 for config in validation_configs:
269 if config['cameras'] and len(config['cameras']) > 0:
270 l1_test = 0.0
271 psnr_test = 0.0
272 for idx, viewpoint in enumerate(config['cameras']):
273 if config['name']=="train":
274 pose = scene.gaussians.get_RT(viewpoint.uid)
275 else:
276 pose = scene.gaussians.get_RT_test(viewpoint.uid)
277 image = torch.clamp(renderFunc(viewpoint, scene.gaussians, *renderArgs, camera_pose=pose)["render"], 0.0, 1.0)
278 gt_image = torch.clamp(viewpoint.original_image.to("cuda"), 0.0, 1.0)
279 if tb_writer and (idx < 5):
280 tb_writer.add_images(config['name'] + "_view_{}/render".format(viewpoint.image_name), image[None], global_step=iteration)
281 if iteration == testing_iterations[0]:
282 tb_writer.add_images(config['name'] + "_view_{}/ground_truth".format(viewpoint.image_name), gt_image[None], global_step=iteration)
283 l1_test += l1_loss(image, gt_image).mean().double()
284 psnr_test += psnr(image, gt_image).mean().double()
285 psnr_test /= len(config['cameras'])
286 l1_test /= len(config['cameras'])
287 print("\n[ITER {}] Evaluating {}: L1 {} PSNR {}".format(iteration, config['name'], l1_test, psnr_test))
288 if tb_writer:
289 tb_writer.add_scalar(config['name'] + '/loss_viewpoint - l1_loss', l1_test, iteration)
290 tb_writer.add_scalar(config['name'] + '/loss_viewpoint - psnr', psnr_test, iteration)
291
292 if tb_writer:
293 tb_writer.add_histogram("scene/opacity_histogram", scene.gaussians.get_opacity, iteration)
294 tb_writer.add_scalar('total_points', scene.gaussians.get_xyz.shape[0], iteration)
295 torch.cuda.empty_cache()
296
297if __name__ == "__main__":
298 # Set up command line argument parser

Callers 1

trainingFunction · 0.85

Calls 6

l1_lossFunction · 0.90
psnrFunction · 0.90
getTestCamerasMethod · 0.80
getTrainCamerasMethod · 0.80
get_RTMethod · 0.80
get_RT_testMethod · 0.80

Tested by

no test coverage detected