File size: 916 Bytes
617c323
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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