Skip to content

Repository of change detection methods in Radar satellite imagery (SAR) to be implemented in the Data Cube Chile.

Notifications You must be signed in to change notification settings

DenisSebastian/CD_DataCube

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

title author date
Change Detection SAR to Data Cube
Denis Berroeta
2023-10-30

Convencional Methods

Segmenting remote sensing imagery with FastSAM

[📕Paper] [🤗HuggingFace Demo] [Colab demo] [Replicate demo & API] [Model Zoo] [BibTeX]

The Fast Segment Anything Model(FastSAM) is a CNN Segment Anything Model trained using only 2% of the SA-1B dataset published by SAM authors. FastSAM achieves comparable performance with the SAM method at 50× higher run-time speed. Reference: https://samgeo.gishub.org/examples/fast_sam/

Installation

Clone the repository locally:

git clone https://github.com/CASIA-IVA-Lab/FastSAM.git

Create the conda env. The code requires python>=3.7, as well as pytorch>=1.7 and torchvision>=0.8. Please follow the instructions here to install both PyTorch and TorchVision dependencies. Installing both PyTorch and TorchVision with CUDA support is strongly recommended.

conda create -n FastSAM python=3.9
conda activate FastSAM

Install the packages:

cd FastSAM
pip install -r requirements.txt

Install CLIP:

pip install git+https://github.com/openai/CLIP.git

Model Checkpoints

Two model versions of the model are available with different sizes. Click the links below to download the checkpoint for the corresponding model type.

Usage

Step 1: Image preprocessing

preprocessing unique:

To transform image to be read by FastSAM then apply the utils/transform_image.py script, for example:

apply_transform(input_image_file='./images/ST_001/DD_ST_001_255.tif',
                output_image_file='./sam_imputs/ST_001/DD_ST_001_255.tif')

Multi preprocessing:

If you want to apply the above procedure massively to all image files contained in folders and subfolders you should use the utils/transform_fsam_sp.py script and add only the source folder (input_folder) and the output folder (output_folder).

...

# Iterar por multiples carpetas
input_folder = "MC_DIF_samsara"
output_folder = 'sam_input'

...

Step 2: Apply FastSAM

This procedure returns the segmentation in different formats:

  • Image PNG
  • Image TIF
  • Polygon Shapefile
  • Polygon geojson

unique segmentation:

The second step is the segmentation with the FastSAM model, where you can apply the model for an image using the fastSAM_sp.py script, just modify the path of the input image, as shown below:

...

# model fastSAM
model_path = 'weights/FastSAM-x.pt'
sam = SamGeo(model=model_path)

image = "sam_imputs/ST_007/DD_ST_007.tif"
sam.set_image(image)
...

Multi segmentation:

If you want to apply the above procedure in bulk to all image files contained in folders and subfolders you should use the fastSAM_all.py script and add only the source folder (input_folder) and the output folder (output_folder).

...

# Modelos SAM
model_path = 'weights/FastSAM-x.pt'
sam = SamGeo(model=model_path)

# Iterar por multiples carpetas
input_folder = "sam_input"
output_folder = 'results'
...

About

Repository of change detection methods in Radar satellite imagery (SAR) to be implemented in the Data Cube Chile.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published