API Reference#
Top-Level API#
The main entry points are in the panodac module.
predict
#
predict(image: Union[str, Path, ndarray, Image], model: str = 'outdoor-resnet101', device: Union[str, None] = None, fix_panorama_seam: bool = True) -> np.ndarray
Predict metric depth from any camera image.
Supports perspective, fisheye, and 360° panorama images. Models are automatically downloaded from HuggingFace on first use.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Union[str, Path, ndarray, Image]
|
Input image. Can be: - Path to image file (str or Path) - numpy array (H, W, 3) in RGB format, values 0-255 - PIL Image |
required |
model
|
str
|
Model to use. One of: - 'outdoor-resnet101' (default): Fast outdoor model - 'outdoor-swinl': High-quality outdoor model - 'indoor-resnet101': Fast indoor model - 'indoor-swinl': High-quality indoor model |
'outdoor-resnet101'
|
device
|
Union[str, None]
|
Device to use ('cuda', 'mps', 'cpu', or None for auto-detect) |
None
|
fix_panorama_seam
|
bool
|
If True (default), apply Poisson blending to correct left-right seam artifacts in ERP panorama depth outputs. |
True
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Depth map as numpy array (H, W) with metric depth in meters. |
Example
import panodac depth = panodac.predict("photo.jpg") depth = panodac.predict("panorama.jpg", model="outdoor-swinl")
Source code in src/panodac/__init__.py
list_models
#
List all available pretrained models.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of model names that can be passed to predict() |
get_device
#
Get the best available device for inference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device
|
Union[str, None]
|
Specific device to use ('cuda', 'mps', 'cpu'), or None for auto-detection. |
None
|
Returns:
| Type | Description |
|---|---|
device
|
torch.device for inference |
Source code in src/panodac/utils.py
Panorama Seam Correction#
Panoramic (ERP) depth outputs can show a visible seam at the left/right boundary. panodac applies a Poisson-based seam correction by default when a panorama is detected. You can also call the seam blender directly.
fix_panorama_seam
#
fix_panorama_seam(depth: ndarray, blend_width: int | None = None, *, anchor_strength: float = 0.001) -> np.ndarray
Convenience wrapper to fix ERP panorama depth seam artifacts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
depth
|
ndarray
|
(H, W) depth map. |
required |
blend_width
|
int | None
|
Half-width of the solve band. If None, auto-pick from width. |
None
|
Source code in src/panodac/seam_blending.py
Module Structure#
panodac/
├── __init__.py # Top-level API (predict, list_models, get_device)
├── predictor.py # DepthPredictor class
├── seam_blending.py # Poisson seam correction for ERP panoramas
├── hub.py # HuggingFace model download
├── utils.py # Device detection, image loading
└── models/ # Neural network architectures
├── idisc.py # IDisc model (perspective)
├── idisc_erp.py # IDiscERP model (panorama)
├── encoder.py # Image encoder
└── backbones/ # ResNet, Swin Transformer
Submodules#
- Predictor -
DepthPredictorclass for advanced usage - Seam Blending - Poisson seam correction utilities
- Hub - Model download utilities