API Reference
Prediction Functions
predict_from_array
omnicloudmask.predict_from_array(
input_array,
patch_size=1000,
patch_overlap=300,
batch_size=1,
inference_device=None,
mosaic_device=None,
inference_dtype=torch.float32,
export_confidence=False,
softmax_output=True,
no_data_value=0,
apply_no_data_mask=True,
custom_models=None,
pred_classes=4,
destination_model_dir=None,
model_download_source="hugging_face",
compile_models=False,
compile_mode="default",
model_version=None,
)
Predict cloud and cloud shadow mask from a numpy array.
Parameters:
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
required |
Array with shape |
|
|
|
Size of patches for inference |
|
|
|
Overlap between adjacent patches |
|
|
|
Number of patches per batch |
|
|
|
Device for inference ( |
|
|
|
Device for patch mosaicking. Defaults to |
|
|
|
Data type. Accepts |
|
|
|
Return confidence maps instead of class predictions |
|
|
|
Apply softmax to confidence output |
|
|
|
Value indicating no-data pixels in input |
|
|
|
Mask no-data regions in output |
|
|
|
Custom model(s) instead of default |
|
|
|
Number of output classes (for custom models) |
|
|
|
Directory to cache downloaded models |
|
|
|
Model source: |
|
|
|
Compile models with torch.compile for faster inference |
|
|
|
torch.compile mode |
|
|
|
Model version ( |
Returns:
np.ndarray with shape (1, height, width) for class predictions, or (4, height, width) if export_confidence=True.
predict_from_load_func
omnicloudmask.predict_from_load_func(
scene_paths,
load_func,
patch_size=1000,
patch_overlap=300,
batch_size=1,
inference_device=None,
mosaic_device=None,
inference_dtype=torch.float32,
export_confidence=False,
softmax_output=True,
no_data_value=0,
overwrite=True,
apply_no_data_mask=True,
output_dir=None,
custom_models=None,
pred_classes=4,
destination_model_dir=None,
model_download_source="hugging_face",
compile_models=False,
compile_mode="default",
model_version=None,
)
Predict cloud masks for multiple scene files, saving results as GeoTIFFs.
Parameters:
All parameters from predict_from_array plus:
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
required |
Paths to scene files or directories |
|
|
required |
Function that loads scene data (see Data Loaders) |
|
|
|
Overwrite existing prediction files |
|
|
|
Output directory. Defaults to same directory as input |
Returns:
list[Path] of output prediction file paths.
Data Loaders
load_s2
omnicloudmask.load_s2(
input_path,
resolution=10.0,
required_bands=None,
)
Load Sentinel-2 L1C or L2A scenes from .SAFE directories.
Parameters:
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
required |
Path to |
|
|
|
Output resolution in meters (10-50) |
|
|
|
Band names to load (Red, Green, NIR). B8A (20 m) is used instead of B08 (10 m) for faster loading due to smaller file size |
Returns:
Tuple of (np.ndarray, rasterio.Profile).
load_ls8
omnicloudmask.load_ls8(
input_path,
resolution=30,
required_bands=None,
)
Load Landsat 8 scenes.
Parameters:
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
required |
Path to Landsat scene directory |
|
|
|
Resolution in meters (must be 30) |
|
|
|
Band names to load (Red, Green, NIR) |
Returns:
Tuple of (np.ndarray, rasterio.Profile).
load_multiband
omnicloudmask.load_multiband(
input_path,
resample_res=None,
band_order=None,
)
Load a multiband GeoTIFF.
Parameters:
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
required |
Path to GeoTIFF file |
|
|
|
Target resolution for resampling |
|
|
|
1-indexed band numbers for Red, Green, NIR. Warns and defaults to |
Returns:
Tuple of (np.ndarray, rasterio.Profile).