Multiclass LandCover dataset segmentation
The following example shows how to prepare the onnx model for field segmentation.
Dataset
The example is based on the LandCover.ai dataset. It provides satellite images with 25 cm/px and 50 cm/px resolution. Annotation masks for the following classes are provided for the images: building (1), woodland (2), water(3), road(4).
Architecture and training
Note
The code will be published as soon as possible.
We built our pipeline based on Pytorch, Pytorch Lightning, and Pytchorchsegmentation_models.pytorch repository.
Model
DeepLabV3+
withtu-semnasnet_100
backendLoss function: balanced
FocalDiceLoss
Input image size:
512x512
Normalization:
mean=[0.485, 0.456, 0.406]
,std=[0.229, 0.224, 0.225]
Converting to onnx
When model training is completed, export the model using the script below:
model.eval()
x = next(iter(datamodule.test_dataloader()))[0]
torch.onnx.export(model,
x[:1], # model input
'model.onnx', # where to save the model
export_params=True,
opset_version=15,
input_names=['input'],
output_names=['output'],
do_constant_folding=False)
Example inference
Run QGIS, next add Google Eart map using QuickMapServices
plugin.
Then run our plugin and set parameters like in the screenshot below. You can find the pre-trained onnx model at examples/deeplabv3_segmentation_landcover/deeplabv3_landcover_4c.onnx
path. Push the Run button to start processing.
After a few seconds, the results are available:
stats
output layers
predicted mask
predicted mask with Google Earth background