Skip to content

Commit

Permalink
remove network gui
Browse files Browse the repository at this point in the history
  • Loading branch information
bouchardi committed Mar 15, 2024
1 parent 5a1a3c3 commit 188c286
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 143 deletions.
86 changes: 0 additions & 86 deletions gaussian_splatting/gaussian_renderer/network_gui.py

This file was deleted.

56 changes: 3 additions & 53 deletions gaussian_splatting/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import torch
from random import randint
from gaussian_splatting.utils.loss_utils import l1_loss, ssim
from gaussian_splatting.gaussian_renderer import render, network_gui
from gaussian_splatting.gaussian_renderer import render
import sys
from gaussian_splatting.scene import Scene, GaussianModel
from gaussian_splatting.utils.general_utils import safe_state
Expand All @@ -12,12 +12,6 @@
from argparse import Namespace
from gaussian_splatting.arguments import ModelParams, PipelineParams, OptimizationParams

try:
from torch.utils.tensorboard import SummaryWriter
TENSORBOARD_FOUND = True
except ImportError:
TENSORBOARD_FOUND = False


class Trainer:
def __init__(
Expand All @@ -28,8 +22,6 @@ def __init__(
checkpoint=None,
debug_from=-1,
quiet=False,
ip="127.0.0.1",
port=6009,
detect_anomaly=False
):
if testing_iterations is None:
Expand All @@ -47,10 +39,8 @@ def __init__(
self._checkpoint = checkpoint
self._debug_from = debug_from

# Initialize system state (RNG)
safe_state(quiet)
# Start GUI server, configure and run training
network_gui.init(ip, port)

torch.autograd.set_detect_anomaly(detect_anomaly)


Expand All @@ -61,7 +51,6 @@ def run(
pipe,
):
first_iter = 0
tb_writer = prepare_output_and_logger(dataset)
gaussians = GaussianModel(dataset.sh_degree)
scene = Scene(dataset, gaussians)
gaussians.training_setup(opt)
Expand All @@ -80,21 +69,6 @@ def run(
progress_bar = tqdm(range(first_iter, opt.iterations), desc="Training progress")
first_iter += 1
for iteration in range(first_iter, opt.iterations + 1):
if network_gui.conn == None:
network_gui.try_connect()
while network_gui.conn != None:
try:
net_image_bytes = None
custom_cam, do_training, pipe.convert_SHs_python, pipe.compute_cov3D_python, keep_alive, scaling_modifer = network_gui.receive()
if custom_cam != None:
net_image = render(custom_cam, gaussians, pipe, background, scaling_modifer)["render"]
net_image_bytes = memoryview((torch.clamp(net_image, min=0, max=1.0) * 255).byte().permute(1, 2, 0).contiguous().cpu().numpy())
network_gui.send(net_image_bytes, dataset.source_path)
if do_training and ((iteration < int(opt.iterations)) or not keep_alive):
break
except Exception as e:
network_gui.conn = None

iter_start.record()

gaussians.update_learning_rate(iteration)
Expand Down Expand Up @@ -136,7 +110,6 @@ def run(

# Log and save
training_report(
tb_writer,
iteration,
Ll1,
loss,
Expand Down Expand Up @@ -188,21 +161,8 @@ def prepare_output_and_logger(args):
with open(os.path.join(args.model_path, "cfg_args"), 'w') as cfg_log_f:
cfg_log_f.write(str(Namespace(**vars(args))))

# Create Tensorboard writer
tb_writer = None
if TENSORBOARD_FOUND:
tb_writer = SummaryWriter(args.model_path)
else:
print("Tensorboard not available: not logging progress")
return tb_writer


def training_report(tb_writer, iteration, Ll1, loss, l1_loss, elapsed, testing_iterations, scene : Scene, renderFunc, renderArgs):
if tb_writer:
tb_writer.add_scalar('train_loss_patches/l1_loss', Ll1.item(), iteration)
tb_writer.add_scalar('train_loss_patches/total_loss', loss.item(), iteration)
tb_writer.add_scalar('iter_time', elapsed, iteration)

def training_report(iteration, Ll1, loss, l1_loss, elapsed, testing_iterations, scene : Scene, renderFunc, renderArgs):
# Report test and samples of training set
if iteration in testing_iterations:
torch.cuda.empty_cache()
Expand All @@ -216,22 +176,12 @@ def training_report(tb_writer, iteration, Ll1, loss, l1_loss, elapsed, testing_i
for idx, viewpoint in enumerate(config['cameras']):
image = torch.clamp(renderFunc(viewpoint, scene.gaussians, *renderArgs)["render"], 0.0, 1.0)
gt_image = torch.clamp(viewpoint.original_image.to("cuda"), 0.0, 1.0)
if tb_writer and (idx < 5):
tb_writer.add_images(config['name'] + "_view_{}/render".format(viewpoint.image_name), image[None], global_step=iteration)
if iteration == testing_iterations[0]:
tb_writer.add_images(config['name'] + "_view_{}/ground_truth".format(viewpoint.image_name), gt_image[None], global_step=iteration)
l1_test += l1_loss(image, gt_image).mean().double()
psnr_test += psnr(image, gt_image).mean().double()
psnr_test /= len(config['cameras'])
l1_test /= len(config['cameras'])
print("\n[ITER {}] Evaluating {}: L1 {} PSNR {}".format(iteration, config['name'], l1_test, psnr_test))
if tb_writer:
tb_writer.add_scalar(config['name'] + '/loss_viewpoint - l1_loss', l1_test, iteration)
tb_writer.add_scalar(config['name'] + '/loss_viewpoint - psnr', psnr_test, iteration)

if tb_writer:
tb_writer.add_histogram("scene/opacity_histogram", scene.gaussians.get_opacity, iteration)
tb_writer.add_scalar('total_points', scene.gaussians.get_xyz.shape[0], iteration)
torch.cuda.empty_cache()

print("\nTraining complete.")
Expand Down
4 changes: 0 additions & 4 deletions scripts/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
lp = ModelParams(parser)
op = OptimizationParams(parser)
pp = PipelineParams(parser)
parser.add_argument('--ip', type=str, default="127.0.0.1")
parser.add_argument('--port', type=int, default=6009)
parser.add_argument('--debug_from', type=int, default=-1)
parser.add_argument('--detect_anomaly', action='store_true', default=False)
parser.add_argument("--test_iterations", nargs="+", type=int, default=[7_000, 30_000])
Expand All @@ -39,8 +37,6 @@
checkpoint=args.start_checkpoint,
debug_from=args.debug_from,
quiet=args.quiet,
ip=args.ip,
port=args.port,
detect_anomaly=args.detect_anomaly
)
trainer.run(
Expand Down

0 comments on commit 188c286

Please sign in to comment.