nerfbaselines.utils

class nerfbaselines.utils.CancellationToken(parent_token: CancellationToken | None = None)[source]

Bases: object

cancel()[source]
property cancelled
invoke(fn, *args, **kwargs)[source]
raise_for_cancelled()[source]
register_callback(callback)[source]
unregister_callback(callback)[source]
exception nerfbaselines.utils.CancelledException[source]

Bases: Exception

class nerfbaselines.utils.Formatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]

Bases: Formatter

format(record: LogRecord)[source]

Format the specified record as text.

The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.

class nerfbaselines.utils.IndicesClickType[source]

Bases: ParamType

convert(value, param, ctx)[source]

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail() with a descriptive message.

Parameters:
  • value – The value to convert.

  • param – The parameter that is using this type to convert its value. May be None.

  • ctx – The current context that arrived at this value. May be None.

name: str = 'indices'

the descriptive name of this type

class nerfbaselines.utils.MetricsAccumulator(options: Dict[str, Literal['average', 'last', 'sum']] | None = None)[source]

Bases: object

pop() Dict[str, float | int][source]
update(metrics: Dict[str, float | int]) None[source]
exception nerfbaselines.utils.NoGPUError(message='GPUs not available')[source]

Bases: RuntimeError

class nerfbaselines.utils.ResourcesUtilizationInfo[source]

Bases: TypedDict

gpu_memory: int
gpu_name: str
memory: int
class nerfbaselines.utils.SetParamOptionType[source]

Bases: ParamType

convert(value, param, ctx)[source]

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail() with a descriptive message.

Parameters:
  • value – The value to convert.

  • param – The parameter that is using this type to convert its value. May be None.

  • ctx – The current context that arrived at this value. May be None.

name: str = 'key-value'

the descriptive name of this type

nerfbaselines.utils.apply_colormap(array: TTensor, *, pallete: str = 'viridis', invert: bool = False) TTensor[source]
nerfbaselines.utils.assert_not_none(value: T | None) T[source]
nerfbaselines.utils.batched(array, batch_size)[source]
nerfbaselines.utils.build_measure_iter_time()[source]
nerfbaselines.utils.cancellable(fn: TCallable, *, mark_only: bool = False, cancellation_token: CancellationToken | None = None) TCallable[source]
nerfbaselines.utils.cancellable(*, mark_only: bool = False, cancellation_token: CancellationToken | None = None) Callable[[TCallable], TCallable]
nerfbaselines.utils.cast_value(tp, value)[source]
nerfbaselines.utils.convert_image_dtype(image: ndarray, dtype) ndarray[source]
nerfbaselines.utils.flatten_hparams(hparams: Any, *, separator: str = '/', _prefix: str = '') Dict[str, Any][source]
nerfbaselines.utils.get_package_dependencies(extra=None, ignore: Set[str] | None = None, ignore_viewer: bool = False)[source]
nerfbaselines.utils.get_resources_utilization_info(pid: int | None = None) ResourcesUtilizationInfo[source]
nerfbaselines.utils.handle_cli_error(fn)[source]
nerfbaselines.utils.image_to_srgb(tensor, dtype, color_space: str | None = None, allow_alpha: bool = False, background_color: ndarray | None = None)[source]
nerfbaselines.utils.is_broadcastable(shape1, shape2)[source]
nerfbaselines.utils.is_gpu_error(e: Exception) bool[source]
nerfbaselines.utils.linear_to_srgb(img)[source]
nerfbaselines.utils.make_image_grid(*images: ndarray, ncol=None, padding=2, max_width=1920, background: None | Tuple[float, float, float] | ndarray = None)[source]
nerfbaselines.utils.mark_host(fn)[source]
nerfbaselines.utils.padded_stack(tensors: ndarray | Tuple[ndarray, ...] | List[ndarray]) ndarray[source]
nerfbaselines.utils.partialclass(cls, *args, **kwargs)[source]
nerfbaselines.utils.partialmethod(func, *args, **kwargs)[source]
nerfbaselines.utils.read_image(file: BinaryIO | str | Path) ndarray[source]
nerfbaselines.utils.remap_error(fn)[source]
nerfbaselines.utils.run_inside_eval_container(backend_name: str | None = None)[source]

Ensures PyTorch is available to compute extra metrics (lpips)

nerfbaselines.utils.run_on_host()[source]
nerfbaselines.utils.save_depth(file: BinaryIO | str | Path, tensor: ndarray)[source]
nerfbaselines.utils.save_image(file: BinaryIO | str | Path, tensor: ndarray)[source]
nerfbaselines.utils.setup_logging(verbose: bool | Literal['disabled'])[source]
nerfbaselines.utils.srgb_to_linear(img)[source]
nerfbaselines.utils.visualize_depth(depth: ndarray, expected_scale: float | None = None, near_far: ndarray | None = None, pallete: str = 'viridis') ndarray[source]