# buildseg
**Repository Path**: Geoyee/buildseg
## Basic Information
- **Project Name**: buildseg
- **Description**: buildseg is a building extraction plugin of QGIS based on ONNX『buildseg是一个基于ONNX的用于建筑提取的QGIS插件』
- **Primary Language**: Python
- **License**: GPL-3.0
- **Default Branch**: develop
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2022-09-28
- **Last Updated**: 2023-07-05
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README

buildseg: QGIS plugin for building extraction
English |
简体中文
[](https://www.python.org/downloads/release/python-380/) [](https://www.qgis.org/)  
buildseg is a Building Extraction plugin for QGIS based on ONNX (Use PaddlePaddle to train and convert to ONNX), and it using the semantic segmentation ability provided by paddleseg, large areas can be extracted and spliced. At present, automatic downloading of raster images and building extraction are added, and users need to register in mapbox and record Token.

*\*Noto: The raster is downloaded from mapbox according to the vector range, and model is SegFormer_B2.*
## News
- xx Apr 2022 [v0.3] : 1. Add support for online map tiles based on Mapbpx; 2. Internationalization support.
- 08 Feb 2022 [v0.2] : 1. ONNX is used instead of PaddlePaddle; 2. Test in Windows / Linux / Mac OS.
- 23 Dec 2021 [v0.1] : 1. Add segmentation based on PaddlePaddle; 2. Add mask to shapefile; 3. Add simplify.
## How to use
1. Download and install [QGIS](https://www.qgis.org/en/site/) and clone the repo:
```git
git clone git@github.com:deepbands/buildseg.git
```
2. Install requirements:
- Enter the folder and install dependent libraries using OSGeo4W shell (Open As Administrator) :
```shell
cd buildseg
pip install -r requirements.txt
```
- Or open OSGeo4W shell as administrator and enter:
```shell
pip install opencv-python onnx onnxruntime --user
```
3. Copy folder named buildseg in QGIS configuration folder and choose the plugin from plugin manager in QGIS (If not appeared restart QGIS).
- You can know this folder from QGIS Setting Menu at the top-left of QGIS UI `[Settings] > [User Profiles] > [Open Active Profile Folder]`.
- Go to `python\plugins` then paste the buildseg folder.
- Full path should be like : `C:\Users\$USER\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\buildseg`.
4. Open QGIS, load your raster and select the ONNX file (`*.onnx`) then click `ok`.
## Model and Parameter
- mIoU from PaddlePaddle and other from ONNX.
- Train / Eval (5k) Dataset: [AI Studio](https://aistudio.baidu.com/aistudio/datasetdetail/102929).
- Run time test environment: [Win10] / [i7-10750H] / [RTX 2060] and test image: [Baidu drive](https://pan.baidu.com/s/14novqjR7gEXVCLwZkxqepw) | [Google drive](https://drive.google.com/file/d/1aySfvIzAnQDkVKUkFmyNq8O7p2S3IhUl/view?usp=sharing).
| Model | Backbone | Resolution | mIoU | Params(MB) | Running Time(s) | Static Weight |
|:----------------------------------------------------:|:---------:|:----------:|:------:|:----------:|:---------------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| [OCRNet](https://arxiv.org/pdf/1909.11065.pdf) | HRNet_W18 | 512x512 | 89.38% | 46.49 | 39.090 | [Baidu drive](https://pan.baidu.com/s/1ZOy4HpC2TPWIGSGU0DX2UQ) \| [Google drive](https://drive.google.com/file/d/1wKC5PxroqDzrUz9nOFuA1KOFlv18MqS9/view?usp=sharing) |
| [SegFormer_B2](https://arxiv.org/pdf/2112.08275.pdf) | - | 512x512 | 89.47% | 104.56 | 59.498 | [Baidu drive](https://pan.baidu.com/s/1knnge-bRkXIhzS-RRTJ8lQ) \| [Google drive](https://drive.google.com/file/d/1TXF2T6LORRyDoCmkwmZsxjo0Km9BwuAK/view?usp=sharing) |
| [BiSeNet_V2](https://arxiv.org/pdf/2004.02147.pdf) | - | 512x512 | 84.61% | 8.94 | 7.004 | [Baidu drive](https://pan.baidu.com/s/1pDBLc7MoLaBERKe2I536sA) \| [Google drive](https://drive.google.com/file/d/1SYwzWBU4wMJfzOf83Tboe7_P7TLW44xw/view?usp=sharing) |
*\*Noto : All of Baidu drive's code is `band`.*
## How to Train
This work is in progress, at present, the relevant documents are as follows :
- [\* How to make dataset in QGIS](https://github.com/deepbands/deep-learning-datasets-maker)
- [How to train your data](./docs/train/train.md)
- [How to convert to ONNX weight](./docs/train/to_onnx.md)
## TODO:
- [ ] Build a sample plugin instead of use plugin builder.