Code Monkey home page Code Monkey logo

sam-ugis-homework's Introduction

SAM application in remote sensing images object-based classification for UGIS course

The homework of UGIS course: to develop a software (including algorithm and GUI) equipped with SAM to do segmentation and classification for remote sensing images.


Geography Information Science Grade 2020, School of Geography and Planning, Sun Yat-Sen Univeristy.

June 14, 2023


Introduction

This is a software that can use SAM or multiscale segmentation to sement remote sensing images, then classify the images with input samples based on the segmenation and check the accuracy. The software is entirely written by Python, and the GUI is written by Python package tkinter.


Features

  • Easy installation and visualized GUI
  • Two segmentation algorithms and three classification algorithms
  • All results can be seen in GUI

Installation

Install the requirement

git clone https://github.com/JeasunLok/SAM-UGIS-Homework.git && cd SAM-UGIS-Homework
conda create -n SAM-UGIS-Homework python=3.9
conda activate SAM-UGIS-Homework
pip install -r requirements.txt
pip install torch==1.13.1+cu117 -f https://download.pytorch.org/whl/torch_stable.html

Run the GUI in main to complete your task

python main.py

Download the pth parameters file of sam_vit_b in: Parameters file of sam_vit_b Then place it under folder asset.
Or you can modify the code and switch the backbone to sam_vit_l or sam_vit_h in src/sam_segmentation.py


How to use it

The GUI is shown below: GUI

  1. Segmentation
    Two file paths are need: click "选择路径" for ""输入图像文件" and ""输出分割文件"""输入图像文件" is the original image you want to do segmentation and the output segmentation file is ""输出分割文件", then select the segmentation algorithm in "选择分割算法". All these files are tif file. Two selections "SAM分割" and ""多尺度分割" can be selected. The former uses SAM to do segmentation and the latter uses quickshift algorithm to do segmentation. When using ""多尺度分割", two parmaters ""核大小" and ""最大距离" are needed, which represent the scale of the segmentation. When doing segmentation, you should select the device GPU or CPU in "选择运算设备".
    "SAM分割" uses segment-anything model and ""多尺度分割" uses quickshift algorithm.

  1. Classification
    After completing the segmentation or you have the segmentation result of original image, you can enter two paths: click "选择路径" for ""输入样本文件" and ""输出分类文件"""输入样本文件" is the training and testing samples of the classfier, and the output classification file is ""输出分割文件" Then select the classification algorithm in "选择分类算法", "决策树" is decision tree algorithm, "支持向量机" is support vector machine algorithm and "随机森林" is random forest algorithm. It should be noticed that the samples file is shp point file and the output classification file is tif file. The train ratio ranged from 0 to 1 should be entered in "训练集比例", and the classification accuracies (i.e. Overall accuracy (OA) and kappa coefficient (Kappa)) are shown in GUI immediately.

  1. Image visualization
    The "图片" button can check the original image, segmentation result and classification result of the task: Image
  • "初始图片" button shows the original image.
  • "分割结果" button shows the segmentation result.
  • "分类结果" button shows the classification result.

Source

We provide 3 example images and samples in folder images for users to use and test our software and the video of how to use the software in Chinese is released at video of how to use the software.


License

The software is licensed under the Apache 2.0 license.


Acknowledgement

This software is made possible by the following open source projects. Credit goes to the developers of these projects: segment-geospatial
segment-anything

sam-ugis-homework's People

Contributors

jeasunlok avatar

Stargazers

MK_Li avatar  avatar  avatar  avatar Wangjie Zhou avatar  avatar WhuLife avatar  avatar Xu Zhengzhe avatar angleboy avatar  avatar Shenzhou Liu avatar pangzi avatar  avatar  avatar  avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.