You can fine-tune the Prithvi - Flood Segmentation model to suit your geographic area, imagery, or features of interest. Fine-tuning a model requires less training data, computational resources, and time compared to training a new model.
Fine-tuning the model is recommended if you do not get satisfactory results from the available ArcGIS pretrained deep learning models. This can happen when your area of interest falls outside the applicable geographies for the models or if your imagery properties such as resolution, scale, and seasonality are different.
You can use the Export Training Data For Deep Learning tool to prepare training data. Next, you can fine-tune this model on your data using the Train Deep Learning Model tool in ArcGIS Pro. Follow the steps below to fine-tune the model.
Prepare training data
This model is trained on the six bands composite of either Harmonized Landsat 8 (HLSL30) or Harmonized Sentinel 2 (HLSS30) and flood labels. Use the Export Training Data For Deep Learning tool to prepare training data for fine-tuning the model.
- Browse to Tools under the Analysis tab.
- Click the Toolboxes tab in the Geoprocessing pane, select Image Analyst Tools, and browse to the Export Training Data For Deep Learning tool in the Deep Learning toolset.
- Set the variables under the Parameters tab as follows:
- Input Raster—Select the six-band imagery. For more details regarding input raster, refer to Recommended imagery configuration.
- Output Folder—Any directory of your choice on your machine.
- Input Feature Class Or Classified Raster Or Table (optional)—Labeled feature class or Classified Raster representing water.
The feature class should also have a text field named ClassName with value set to Water.
- Class Value Field—This is the ClassValue field, set the value to 1.
- Image Format—TIFF format
- Tile Size X—224
- Tile Size Y—224
- Stride X—0
- Stride Y—0
- Metadata Format—Classified Tiles
- Set the variables under the Environments tab.
- Processing Extent—Select Current Display Extent or any other option from the drop-down menu as needed.
- Cell Size—Set the value to the desired cell size.
- Click Run.
Once processing is complete, the exported training data is saved in the specified directory.
Fine-tune the Prithvi - Flood Segmentation model
Complete the following steps to fine-tune the model using the learn module of ArcGIS API for Python:
- Open the Python command prompt with the environment that has deep learning dependencies, go to the desired directory, and type jupyter-notebook.
- In the browser, click New and select Python 3 (ipykernel) to create a new notebook.
- Use the following functions for fine-tuning the model:
- Import the arcgis.learn module.
- prepare_data—Prepare a data object from training sample exported by the Export Training Data tool or training samples in the supported dataset formats.
- path—Provide a path to your exported training data from the previous step.
- batch_size—Specify the number of image tiles processed in each step of the model inference. batch_size depends on the memory of your graphic card.
- Initialize an MMSegmentation model and assign it to a variable name, for example, model.
- data—Provide the data object created using the prepare_data function.
- model—Specify the model name as prithivi100m_crop_classification.
- fit—Train the model for the specified number of epochs using the automatically generated optimal learning rate using the fit method.
- save—Save the trained model as a deep learning package (.dlpk format) using the save method. The deep learning package format is the standard format used to deploy deep learning models on the ArcGIS platform. By default, it will be saved to the models subfolder within the training data folder.
- per_class_metrics—Compute per class precision, recall, and f1-score on validation set using the per_class_metrics method.
You can now use the saved model to run inferencing against your imagery.