Currently implemented fastai process using fastai's unet_learner(). Similar segmentation using other deep learning libraries will be added over time.
Makes use of rschip for image preprocessing and creating normaliser.
Fully reproducible simple example including 4 band (B,G,R,NiR) Sentinel 2 image and mask image to classify water bodies.
-
Clone this repository.
-
cd
to the repo and build the docker image:
docker build . --file .devcontainer/Dockerfile -t segment
- Run the docker image ensuring access to gpu:
docker run --rm --gpus all -i -t -p 127.0.0.1:8888:8888 -w /app \
--mount type=bind,src="$(pwd)",target=/app segment
python src/preprocess/tile.py
To generate image chips for use with unet_learner
.
python src/fast_ai/train.py --image-path inputs/chips_img --epochs 2
Many more training options with defaults. Run python src/fast_ai/train.py -h
to see them.
(update the train-model
argument to the model trained in previous step):
python src/fast_ai/predict.py \
--input-image inputs/s2_flow_country_2023_06_16_example.tif \
--trained-model models/fastai_unet_31_10_2024_1209 \
--normaliser-scaler inputs/chips_img/s2_flow_country_2023_06_16_example_normaliser.pkl \
--boundary-remove