mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-27 19:40:17 +08:00
Fix benchmarking: apply get_background_color in renderer and set profiler to none (#2397)
* apply get_background_color and set profiler to none * Apply override first --------- Co-authored-by: Brent Yi <yibrenth@gmail.com>
This commit is contained in:
1 parent
570ccf3c0a
commit
cc98fb6bd4
2 files changed
+10
-13
No files matched your search
@@ -102,21 +102,18 @@ class RGBRenderer(nn.Module):
|
|||||||
comp_rgb = torch.sum(weights * rgb, dim=-2)
|
comp_rgb = torch.sum(weights * rgb, dim=-2)
|
||||||
accumulated_weight = torch.sum(weights, dim=-2)
|
accumulated_weight = torch.sum(weights, dim=-2)
|
||||||
if BACKGROUND_COLOR_OVERRIDE is not None:
|
if BACKGROUND_COLOR_OVERRIDE is not None:
|
||||||
# This case must be before the others or the override is not properly applied
|
background_color = BACKGROUND_COLOR_OVERRIDE
|
||||||
background_color = cls.get_background_color(
|
if background_color == "random":
|
||||||
BACKGROUND_COLOR_OVERRIDE, shape=comp_rgb.shape, device=comp_rgb.device
|
|
||||||
)
|
|
||||||
elif background_color == "random":
|
|
||||||
# If background color is random, the predicted color is returned without blending,
|
# If background color is random, the predicted color is returned without blending,
|
||||||
# as if the background color was black.
|
# as if the background color was black.
|
||||||
return comp_rgb
|
return comp_rgb
|
||||||
|
|
||||||
elif background_color == "last_sample":
|
elif background_color == "last_sample":
|
||||||
# Note, this is only supported for non-packed samples.
|
# Note, this is only supported for non-packed samples.
|
||||||
background_color = rgb[..., -1, :]
|
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)
|
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
|
return comp_rgb
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -124,13 +121,13 @@ class RGBRenderer(nn.Module):
|
|||||||
cls, background_color: BackgroundColor, shape: Tuple[int, ...], device: torch.device
|
cls, background_color: BackgroundColor, shape: Tuple[int, ...], device: torch.device
|
||||||
) -> Union[Float[Tensor, "3"], Float[Tensor, "*bs 3"]]:
|
) -> Union[Float[Tensor, "3"], Float[Tensor, "*bs 3"]]:
|
||||||
"""Returns the RGB background color for a specified background color.
|
"""Returns the RGB background color for a specified background color.
|
||||||
|
|
||||||
Note:
|
Note:
|
||||||
This function CANNOT be called for background_color being either "last_sample" or "random".
|
This function CANNOT be called for background_color being either "last_sample" or "random".
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
rgb: RGB for each sample.
|
background_color: The background color specification. If a string is provided, it must be a valid color name.
|
||||||
background_color: The background color specification.
|
shape: Shape of the output tensor.
|
||||||
|
device: Device on which to create the tensor.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Background color as RGB.
|
Background color as RGB.
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ while getopts "m:v:s" opt; do
|
|||||||
m ) method_name="$OPTARG" ;;
|
m ) method_name="$OPTARG" ;;
|
||||||
v ) vis="$OPTARG" ;;
|
v ) vis="$OPTARG" ;;
|
||||||
s ) single=true ;;
|
s ) single=true ;;
|
||||||
? ) helpFunction ;;
|
? ) helpFunction ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -83,12 +83,12 @@ for dataset in "${DATASETS[@]}"; do
|
|||||||
--steps-per-save=1000 \
|
--steps-per-save=1000 \
|
||||||
--max-num-iterations=16500 \
|
--max-num-iterations=16500 \
|
||||||
--logging.local-writer.enable=False \
|
--logging.local-writer.enable=False \
|
||||||
--logging.enable-profiler=False \
|
--logging.profiler="none" \
|
||||||
--vis "${vis}" \
|
--vis "${vis}" \
|
||||||
--timestamp "$timestamp" \
|
--timestamp "$timestamp" \
|
||||||
${dataparser} & GPU_PID[$idx]=$!
|
${dataparser} & GPU_PID[$idx]=$!
|
||||||
echo "Launched ${method_name} ${dataset} on gpu ${GPU_IDX[$idx]}, ${tag}"
|
echo "Launched ${method_name} ${dataset} on gpu ${GPU_IDX[$idx]}, ${tag}"
|
||||||
|
|
||||||
# update gpu
|
# update gpu
|
||||||
((idx=(idx+1)%len))
|
((idx=(idx+1)%len))
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in new issue
Block a user