Skip To Content

Fine-tune the model

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.

  1. Browse to Tools under the Analysis tab.
    Tools icon
  2. 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.
    Export Training Data For Deep Learning
  3. Set the variables under the Parameters tab as follows:
    1. Input Raster—Select the six-band imagery. For more details regarding input raster, refer to Recommended imagery configuration.
    2. Output Folder—Any directory of your choice on your machine.
    3. 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.

    4. Class Value Field—This is the ClassValue field, set the value to 1.
    5. Image Format—TIFF format
    6. Tile Size X—224
    7. Tile Size Y—224
    8. Stride X—0
    9. Stride Y—0
    10. Metadata Format—Classified Tiles
      Export Training Data for Deep Learning tool parameters
  4. Set the variables under the Environments tab.
    1. Processing Extent—Select Current Display Extent or any other option from the drop-down menu as needed.
    2. Cell Size—Set the value to the desired cell size.
      Export Training Data For Deep Learning tool parameters on the Environments tab
  5. 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:

  1. Open the Python command prompt with the environment that has deep learning dependencies, go to the desired directory, and type jupyter-notebook.
    Python command prompt
  2. In the browser, click New and select Python 3 (ipykernel) to create a new notebook.
    jupyter notebook
  3. Use the following functions for fine-tuning the model:
    1. Import the arcgis.learn module.
    2. prepare_data—Prepare a data object from training sample exported by the Export Training Data tool or training samples in the supported dataset formats.

      1. path—Provide a path to your exported training data from the previous step.
      2. 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.

    3. Initialize an MMSegmentation model and assign it to a variable name, for example, model.

      1. data—Provide the data object created using the prepare_data function.
      2. model—Specify the model name as prithivi100m_crop_classification.

    4. fit—Train the model for the specified number of epochs using the automatically generated optimal learning rate using the fit method.
    5. 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.
    6. per_class_metrics—Compute per class precision, recall, and f1-score on validation set using the per_class_metrics method.
      Fine-tuning using ArcGIS API for Python

    You can now use the saved model to run inferencing against your imagery.