Predictor#
The DepthPredictor class provides fine-grained control over depth prediction.
For most use cases, the top-level panodac.predict() function is sufficient. Use DepthPredictor directly when you need to:
- Reuse a loaded model across multiple predictions
- Access the underlying PyTorch model
- Customize preprocessing behavior
DepthPredictor#
DepthPredictor
#
DepthPredictor(model: str = 'outdoor-resnet101', device: Union[str, None] = None, fix_panorama_seam: bool = True)
High-level interface for depth prediction.
Handles model loading, preprocessing, and inference for any camera type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
str
|
Model name ('outdoor-resnet101', 'outdoor-swinl', etc.) |
'outdoor-resnet101'
|
device
|
Union[str, None]
|
Device to use ('cuda', 'mps', 'cpu', or None for auto) |
None
|
fix_panorama_seam
|
bool
|
If True, apply Poisson blending to correct left-right seam artifacts in ERP panorama depth outputs. |
True
|
Source code in src/panodac/predictor.py
__call__
#
Predict depth from an image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Union[str, Path, ndarray, Image]
|
Input image (path, numpy array, or PIL Image) |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Depth map as numpy array (H, W) in meters |
Source code in src/panodac/predictor.py
Usage#
from panodac import DepthPredictor
# Create predictor (model loads once)
predictor = DepthPredictor(model="outdoor-swinl", device="cuda")
# Reuse for multiple images
for image_path in image_paths:
depth = predictor(image_path)
The top-level panodac.predict() function caches predictors internally, so this is mainly useful when you need direct access to the predictor instance.