Metadata-Version: 2.1
Name: satseg
Version: 0.1.0
Summary: A python package to assist in multispectral satellite image segmentation.
Author: Dilith Jayakody
Author-email: dilithjay@gmail.com
Requires-Python: >=3.8,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: geopandas (>=0.12.2,<0.13.0)
Requires-Dist: numpy (>=1.24.2,<2.0.0)
Requires-Dist: opencv-python (>=4.7.0.72,<5.0.0.0)
Requires-Dist: pandas (>=2.0.0,<3.0.0)
Requires-Dist: rasterio (>=1.3.6,<2.0.0)
Requires-Dist: segmentation-models-pytorch (>=0.3.2,<0.4.0)
Requires-Dist: torch (>=2.0.0,<3.0.0)
Requires-Dist: torchgeo (>=0.4.1,<0.5.0)
Requires-Dist: torchvision (>=0.15.1,<0.16.0)
Description-Content-Type: text/markdown

# SatSeg (WIP)
A python package to assist in multispectral satellite image segmentation.

## Installation
```
pip install satseg
```

## Usage

### Training
```python
from satseg.dataset import create_datasets
from satseg.model import save_model, train_model

# A list of paths to the satellite image tif files (.TIF)
tif_paths = ["01.tif". "02.tif"]
# A list of paths to the shapefiles (.SHP) of the masks
mask_paths = ["mask.shp"]

# Create the train and validation datasets
# The intermediate image files will be saved at ./temp/labeled/
train_set, val_set = create_datasets(tif_paths, mask_paths, "temp/labeled")

# Train the model
model, metrics = train_model(train_set, val_set, "unet")

# Save the model at a specified path
model_path = "model.pt"
save_model(model, model_path)
```


### Inference
```python
from satseg.dataset import create_inference_dataset
from satseg.model import load_model, run_inference


tif_paths = ["03.tif", "04.tif"]
# The intermediate image files will be saved at ./temp/unlabeled/
dataset = create_inference_dataset(tif_paths, "temp/unlabeled/", 256)

# Load a previously saved model
model_path = "model.pt"
model = load_model(model_path)

# Run inference on the dataset using the loaded model
# Results will be saved ./temp/infer/
run_inference(dataset, model, "temp/infer/")

```

