Home

Awesome

Baseline Model for Segmentation Fine-Tuning of the HLS Foundation Model

This repo contains the code, performance metrics and trained model weights for a supervised CNN model as the baseline for multi-temporal crop type segmentation fine-tuning of the HLS Foundation Model (FM). The FM is released by NASA and IBM here, and the fine-tuned FM model for this task is presented here. You can also access the training dataset for this task here.

This project is funded by an award from NASA to the Center for Geospatial Analytics at Clark University.

Instructions to run the code using Docker:

Step 1- Change directory to an empty folder in your machine and clone the repo.

$ cd /to_empty/dir/on_host/

$ git clone  git@github.com:ClarkCGA/multi-temporal-crop-classification-baseline.git

$ cd path/to/cloned directory/

Step 2- Make sure the Docker daemon is running and build the Docker image as following:

$ docker build -t <image_name>:<tag> .

Example:

$ docker build -t semseg_baseline:v1 .

step 3- Run the Docker image as a container from within the cloned folder:

$ docker run --gpus all -it -p 8888:8888 -v <path/to/the/cloned-repo/on-host>:/home/workdir -v <path/to/the/dataset/on-host>:/home/data  <image_name>:<tag>

This command will start a container based on the specified Docker image and starts a JupyterLab session. Type localhost:8888 in your browser and copy the provided token from the terminal to open the JupyterLab.

step 4- Run the pipeline:

Open the jupyter notebook located at notebooks/main.ipynb.

Modify the "default_config.yaml" or create your own config file and run the cells as explained in the notebook.

Model Weights

The model weights trained on the dataset for 100 epochs with the parameters specified in the "default_config.yaml", is stored in the model_weights/multi_temporal_crop_classification.pth. Instructions to load and use the pre-trained model for zero-shot inference or warm-up training is explained in the notebook.

Evaluation metrics:

Confusion Matrix

Overall Metrics:

MetricValue
Overall Accuracy0.63056
Mean Accuracy0.61915
Mean IoU0.42086
mean Precision0.57392
mean Recall0.57492
Mean F1 Score0.57251

Class-wise Metrics:

ClassAccuracyIoUPrecisionRecallF1 Score
Natural Vegetation0.63660.45770.61960.63660.6280
Forest0.71710.47720.58780.71710.6461
Corn0.63320.52260.74940.63320.6864
Soybeans0.66760.516750.69570.66760.6814
Wetlands0.60350.41090.56280.60350.5825
Developed/Barren0.60220.46370.66840.60220.6336
Open Water0.87750.75960.84960.87750.8633
Winter Wheat0.66390.49500.66060.66390.6622
Alfalfa0.59020.38470.52500.59020.5557
Fallow/Idle Cropland0.52930.35990.52920.52930.5293
Cotton0.45290.32580.53710.45290.4914
Sorghum0.61520.39090.51740.61520.5621
Other0.45890.32680.53160.45890.4926