diff --git a/nerfstudio/model_components/renderers.py b/nerfstudio/model_components/renderers.py index 20a506b1e..1fde0d693 100644 --- a/nerfstudio/model_components/renderers.py +++ b/nerfstudio/model_components/renderers.py @@ -102,21 +102,18 @@ class RGBRenderer(nn.Module): comp_rgb = torch.sum(weights * rgb, dim=-2) accumulated_weight = torch.sum(weights, dim=-2) if BACKGROUND_COLOR_OVERRIDE is not None: - # This case must be before the others or the override is not properly applied - background_color = cls.get_background_color( - BACKGROUND_COLOR_OVERRIDE, shape=comp_rgb.shape, device=comp_rgb.device - ) - elif background_color == "random": + background_color = BACKGROUND_COLOR_OVERRIDE + if background_color == "random": # If background color is random, the predicted color is returned without blending, # as if the background color was black. return comp_rgb - elif background_color == "last_sample": # Note, this is only supported for non-packed samples. background_color = rgb[..., -1, :] + background_color = cls.get_background_color(background_color, shape=comp_rgb.shape, device=comp_rgb.device) assert isinstance(background_color, torch.Tensor) - comp_rgb = comp_rgb + background_color.to(comp_rgb.device) * (1.0 - accumulated_weight) + comp_rgb = comp_rgb + background_color * (1.0 - accumulated_weight) return comp_rgb @classmethod @@ -124,13 +121,13 @@ class RGBRenderer(nn.Module): cls, background_color: BackgroundColor, shape: Tuple[int, ...], device: torch.device ) -> Union[Float[Tensor, "3"], Float[Tensor, "*bs 3"]]: """Returns the RGB background color for a specified background color. - Note: This function CANNOT be called for background_color being either "last_sample" or "random". Args: - rgb: RGB for each sample. - background_color: The background color specification. + background_color: The background color specification. If a string is provided, it must be a valid color name. + shape: Shape of the output tensor. + device: Device on which to create the tensor. Returns: Background color as RGB. diff --git a/nerfstudio/scripts/benchmarking/launch_train_blender.sh b/nerfstudio/scripts/benchmarking/launch_train_blender.sh index cbdd7d754..7b9db727d 100644 --- a/nerfstudio/scripts/benchmarking/launch_train_blender.sh +++ b/nerfstudio/scripts/benchmarking/launch_train_blender.sh @@ -17,7 +17,7 @@ while getopts "m:v:s" opt; do m ) method_name="$OPTARG" ;; v ) vis="$OPTARG" ;; s ) single=true ;; - ? ) helpFunction ;; + ? ) helpFunction ;; esac done @@ -83,12 +83,12 @@ for dataset in "${DATASETS[@]}"; do --steps-per-save=1000 \ --max-num-iterations=16500 \ --logging.local-writer.enable=False \ - --logging.enable-profiler=False \ + --logging.profiler="none" \ --vis "${vis}" \ --timestamp "$timestamp" \ ${dataparser} & GPU_PID[$idx]=$! echo "Launched ${method_name} ${dataset} on gpu ${GPU_IDX[$idx]}, ${tag}" - + # update gpu ((idx=(idx+1)%len)) done