zensvi.cv.DepthEstimator

class zensvi.cv.DepthEstimator(device=None, task='relative')

A class for estimating depth in images.

The class uses the DPT model from Hugging Face for relative depth estimation (https://huggingface.co/Intel/dpt-large) and the ZoeDepth model for absolute (metric) depth estimation (https://github.com/LiheYoung/Depth-Anything/tree/1e1c8d373ae6383ef6490a5c2eb5ef29fd085993/metric_depth).

Parameters:
  • device (str, optional) – Device to use for inference. Defaults to None.

  • task (str) – Task to perform, either “relative” or “absolute”. Defaults to “relative”.

estimate_depth(dir_input: str | pathlib.Path, dir_image_output: str | pathlib.Path, batch_size: int = 1, max_workers: int = 4)

Estimates depth in the images and saves the depth maps.

Parameters:
  • dir_input (Union[str, Path]) – Directory containing input images or a single image file.

  • dir_image_output (Union[str, Path]) – Directory to save the depth maps.

  • batch_size (int) – Batch size for inference. Defaults to 1.

  • max_workers (int) – Maximum number of workers for parallel processing. Defaults to 4.

Raises:

ValueError – If dir_input is neither a file nor a directory.