chm-meta-v2 / base.py
RhodWeo's picture
Add/update base.py
617c323 verified
raw
history blame contribute delete
916 Bytes
from abc import ABC, abstractmethod
from typing import List, Optional
import numpy as np
class BaseModel(ABC):
@abstractmethod
def predict(self, image: np.ndarray) -> np.ndarray:
"""
Run CHM inference on a single image.
Args:
image: (3, H, W) float32 numpy array, values in [0, 1]
Returns:
(H, W) float32 numpy array — canopy height in metres
"""
pass
@abstractmethod
def predict_tif(
self,
input_path: str,
output_path: str,
bands: Optional[List[int]] = None,
) -> None:
"""
Full GeoTIFF CHM pipeline.
Args:
input_path : path to input RGB or multi-band GeoTIFF
output_path : output path for CHM GeoTIFF (1 band, metres)
bands : 0-based band indices to use as RGB (default: [0,1,2])
"""
pass