Skip to content

Commit 0e5a418

Browse files
authored
[EISeg] Update to 0.4.0 (#1517)
1 parent 3839e7f commit 0e5a418

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+3455
-1884
lines changed

EISeg/.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,8 @@ test_output/
156156

157157
# mask_sm
158158
tool/mask.png
159+
160+
# static_weights
161+
*.pdiparams
162+
*.pdiparams.info
163+
*.pdmodel

EISeg/README.md

+182-172
Large diffs are not rendered by default.

EISeg/README_EN.md

+169
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# EISeg
2+
3+
[![Python 3.6](https://img.shields.io/badge/python-3.6+-blue.svg)](https://www.python.org/downloads/release/python-360/) [![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](LICENSE) [![Downloads](https://pepy.tech/badge/eiseg)](https://pepy.tech/project/eiseg)
4+
<!-- [![GitHub release](https://img.shields.io/github/release/Naereen/StrapDown.js.svg)](https://github.com/PaddleCV-SIG/iseg/releases) -->
5+
6+
English | [简体中文](README.md)
7+
8+
## Latest Developments
9+
10+
- Our paper on interactive segmentation named [EdgeFlow](https://arxiv.org/abs/2109.09406) is accepted by ICCV 2021 Workshop.
11+
- We release EISeg 0.3.0 with more functions and support for Polygon editing.
12+
13+
## Introduction
14+
15+
EISeg (Efficient Interactive Segmentation) is an efficient and intelligent interactive segmentation annotation software developed based on PaddlePaddle. It relies on the interactivate image segmentation methods [RITM](https://github.com/saic-vul/ritm_interactive_segmentation) and [EdgeFlow](https://arxiv.org/abs/2109.09406) .It covers a large number of high-quality segmentation models in different directions such as *high-performance* and *lightweight*, providing convenience to the rapid annotation of semantic and instance labels with reduced cost. In addition, by applying the annotations obtained by EISeg to other segmentation models provided by PaddleSeg for training, high-performance models with customized scenarios can be created, integrating the whole process of segmentation tasks from data annotation to model training and prediction.
16+
17+
![eiseg_demo](../docs/images/eiseg_demo.gif)
18+
19+
## Model Preparation
20+
21+
Please download the model parameters before using EIseg. EISeg provides four annotation models trained on COCO+LVIS and large-scale portrait data to meet the needs of both generic and portrait scenarios. The model architecture corresponds to the network selection module in EISeg interactive tools, and users need to select different network structures and loading parameters in accordance with their own needs.
22+
23+
| Model Type | Applicable Scenarios | Model Architecture | Download Link |
24+
| ---------------------- | ------------------------------------- | ------------------ | ------------------------------------------------------------ |
25+
| High Performance Model | Image annotation in generic scenarios | HRNet18_OCR64 | [hrnet18_ocr64_cocolvis](https://bj.bcebos.com/paddleseg/dygraph/interactive_segmentation/ritm/hrnet18_ocr64_cocolvis.pdparams) |
26+
| Lightweight Model | Image annotation in generic scenarios | HRNet18s_OCR48 | [hrnet18s_ocr48_cocolvis](https://bj.bcebos.com/paddleseg/dygraph/interactive_segmentation/ritm/hrnet18s_ocr48_cocolvis.pdparams) |
27+
| High Performance Model | Annotation in portrait scenarios | HRNet18_OCR64 | [hrnet18_ocr64_human](https://bj.bcebos.com/paddleseg/dygraph/interactive_segmentation/ritm/hrnet18_ocr64_human.pdparams) |
28+
| Lightweight Model | Annotation in portrait scenarios | HRNet18s_OCR48 | [hrnet18s_ocr48_human](https://bj.bcebos.com/paddleseg/dygraph/interactive_segmentation/ritm/hrnet18s_ocr48_human.pdparams) |
29+
30+
31+
32+
## Installation
33+
34+
EISeg provides multiple ways of installation, among which [pip](#PIP) and [run code](#run code) are compatible with Windows, Mac OS and Linux. It is recommended to install in a virtual environment created by conda for fear of environmental conflicts.
35+
36+
System Requirements:
37+
38+
* PaddlePaddle >= 2.2.0
39+
40+
For more details of the installation of PaddlePaddle, please refer to our [official website](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/windows-pip.html)
41+
42+
### Clone
43+
44+
Clone PaddleSeg to your local system through git:
45+
46+
```shell
47+
git clone https://github.com/PaddlePaddle/PaddleSeg.git
48+
```
49+
50+
Enable EISeg by running eiseg after installing the needed environment:
51+
52+
```shell
53+
cd PaddleSeg\contrib\EISeg
54+
python -m eiseg
55+
```
56+
57+
Or you can run exe.py in eiseg:
58+
59+
```shell
60+
cd PaddleSeg\contrib\EISeg\eiseg
61+
python exe.py
62+
```
63+
64+
### PIP
65+
66+
Install pip as follows:
67+
68+
```shell
69+
pip install eiseg
70+
```
71+
72+
pip will install dependencies automatically. After that, enter the following at the command line:
73+
74+
```shell
75+
eiseg
76+
```
77+
78+
Now, you can run pip.
79+
80+
### Windows exe
81+
82+
EISeg uses [QPT](https://github.com/GT-ZhangAcer/QPT) to package. You can download the latest EISeg from [here](https://paddleseg.bj.bcebos.com/eiseg/EISeg0.3.0.1.7z), unzip it, and run the program by double-clicking its .exe. The program will initialize the packages needed for installation in its first run, please be patient.
83+
84+
## Using
85+
86+
After opening the software, make the following settings before annotating:
87+
88+
1. **Load Model Parameter**
89+
90+
Select the appropriate network and load the corresponding model parameters. Currently, networks in EISeg are `HRNet18s_OCR48` and `HRNet18_OCR64`, which provide model parameters for portrait and generic scenarios respectively. Successful loading is shown at the status bar in the lower right corner, while a mismatch between the network parameters and model parameters will trigger a warning of failure load, requiring to be reloaded. The correctly loaded model parameters will be recorded in `Recent Model Parameters`, which can be easily switched, and the exiting model parameter will be loaded automatically the next time you open the software.
91+
92+
2. **Load Image**
93+
94+
Open the image or image folder. Things go well when you see that the main screen image is loaded correctly and the image path is rightly shown in `Data List`.
95+
96+
3. **Add/Load Label**
97+
98+
Add/load labels. New labels can be created by `Add Label`, which are divided into 4 columns corresponding to pixel value, description, color and deletion. The newly created labels can be saved as txt files by `Save Label List`, and other collaborators can import labels by `Load Label List`. Labels imported by loading will be loaded automatically after restarting the software.
99+
100+
4. **Autosave**
101+
102+
You can choose the right folder and have the `autosave` set up, so that the annotated image will be saved automatically when switching images.
103+
104+
Start the annotation when the above are all set up. Here are the commonly used keys/shortcut keys by default, press `E` to modify them as you need.
105+
106+
| Keys/Shortcut Keys | Function |
107+
| --------------------------------- | ------------------------------ |
108+
| Left Mouse Button | Add Positive Sample Points |
109+
| Right Mouse Button | Add Negative Sample Points |
110+
| Middle Mouse Button | Image Panning |
111+
| Ctrl+Middle Mouse Button(wheel) | Image Zooming |
112+
| S | Previous Image |
113+
| F | Next Image |
114+
| Space | Finish Annotation/Switch State |
115+
| Ctrl+Z | Undo |
116+
| Ctrl+Shift+Z | Clear |
117+
| Ctrl+Y | Redo |
118+
| Ctrl+A | Open Image |
119+
| Shift+A | Open Folder |
120+
| E | Open Shortcut Key List |
121+
| Backspace | Delete Polygon |
122+
| Double Click(point) | Delete Point |
123+
| Double Click(edge) | Add Point |
124+
125+
## Instruction of New Functions
126+
127+
- **Polygon**
128+
129+
1. Click Space key to complete interactive annotation, then appears the polygon boundary; when you need to continue the interactive process inside the polygon, click Space to switch to interactive mode so the polygon cannot be selected and changed.
130+
2. The polygon can be dragged and deleted. Use the left mouse to drag the anchor point, double-click the anchor point to delete it, and double-click a side to add an anchor point.
131+
3. With `Keep Maximum Connected Blocks` on, only the largest area will remain in the image, the rest of the small areas will not be displayed and saved.
132+
133+
- **Save Format**
134+
135+
1. Polygons will be recorded and automatically loaded after setting `JSON Save` or `COCO Save`.
136+
2. With no specified save path, the image is save to the label folder under the current image folder by default.
137+
3. If there are images with the same name but different suffixes, you can open `labels and images with the same extensions`.
138+
4. You can also save as grayscale, pseudo-color or matting image, see tools 7-9 in the toolbar
139+
140+
- **Generate mask**
141+
142+
1. Labels can be dragged by holding down the second column, and the final generated mask will be overwritten from top to bottom according to the label list.
143+
144+
- **Interface Module**
145+
146+
1. You can select the interface module to be presented in `Display`, and the normal exit status and location of the interface module will be recorded, and loaded automatically when you open it next time.
147+
148+
149+
## Version Updates
150+
151+
- 2021.09.16 **0.3.0**:【1】Complete the function of polygon editing with support for editing the results of interactive annotation;【2】Support CH/EN interface;【3】Support saving as grayscale/pseudo-color labels and COCO format;【4】More flexible interface dragging;【5】Achieve the dragging of label bar, and the generated mask is overwritten from top to bottom.
152+
- 2021.07.07 **0.2.0**: Newly added contrib:EISeg,which enables rapid interactive annotation of portrait and generic images.
153+
154+
## Developer
155+
156+
[Yuying Hao](https://github.com/haoyuying), [Lin Han](https://github.com/linhandev/), [Yizhou Chen](https://github.com/geoyee), [Yiakwy](https://github.com/yiakwy), [GT](https://github.com/GT-ZhangAcer), [Zhiliang Yu](https://github.com/yzl19940819)
157+
158+
## Academic Citation
159+
160+
If you find our project useful in your research, please consider citing :
161+
162+
```latex
163+
@article{hao2021edgeflow,
164+
title={EdgeFlow: Achieving Practical Interactive Segmentation with Edge-Guided Flow},
165+
author={Hao, Yuying and Liu, Yi and Wu, Zewu and Han, Lin and Chen, Yizhou and Chen, Guowei and Chu, Lutao and Tang, Shiyu and Yu, Zhiliang and Chen, Zeyu and others},
166+
journal={arXiv preprint arXiv:2109.09406},
167+
year={2021}
168+
}
169+
```

EISeg/docs/RS.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# 遥感相关
2+
3+
以下内容为EISeg中遥感垂类相关的文档,主要包括环境配置和功能介绍两大方面。
4+
5+
## 1 环境配置
6+
7+
EISeg中对遥感数据的支持来自GDAL/OGR,GDAL是一个在X/MIT许可协议下的开源栅格空间数据转换库,OGR与其功能类似但主要提供对矢量数据的支持。
8+
9+
### 1.1 依赖安装
10+
11+
关于GDAL的安装,可参考如下安装方式:
12+
13+
#### 1.1.1 Windows
14+
15+
Windows用户可以通过[这里](https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal)下载对应Python和系统版本的二进制文件(*.whl)到本地,以GDAL‑3.3.3‑cp39‑cp39‑win_amd64.whl为例,进入下载目录:
16+
17+
```shell
18+
cd download
19+
```
20+
21+
安装依赖:
22+
23+
```shell
24+
pip install GDAL‑3.3.3‑cp39‑cp39‑win_amd64.whl
25+
```
26+
27+
#### 1.1.2 Linux/Mac安装
28+
29+
Mac用户建议利用conda安装,如下:
30+
31+
```shell script
32+
conda install gdal
33+
```
34+
35+
36+
## 2 功能介绍
37+
38+
目前EISeg中的遥感垂类功能建设还比较简单,基本完成了GTiff类数据加载、大幅遥感影像切片与合并、地理栅格/矢量数据(GTiff/ESRI Shapefile)导出。并基于各类建筑提取数据集40余万张数据训练了一个建筑分割的交互式模型。
39+
40+
### 2.1 数据加载
41+
42+
目前EISeg仅支持了*.tif/tiff图像后缀的的遥感影像读取,由于训练数据都是来自于RGB三通道的遥感图像切片,因此交互分割也仅在RGB三通道上完成,也就表示EISeg支持多波段数据的波段选择。
43+
44+
当使用EISeg打开GTiff图像时,会获取当前波段数,可通过波段设置的下拉列表进行设置。默认为[b1, b1, b1]。下例展示的是天宫一号多光谱数据设置真彩色:
45+
46+
![](https://user-images.githubusercontent.com/35907364/140917802-6b2a15f2-c8ce-4c8e-b89c-41ec9039f59c.gif)
47+
48+
### 2.2 大幅数据切片
49+
50+
目前EISeg对于大幅遥感图像(目前最大尝试为900M,17000*10000大小三通道图像),支持切片预测后合并,其中切片的重叠区域overlap为24。
51+
52+
![overlap](https://user-images.githubusercontent.com/35907364/140916007-86076366-62ce-49ba-b1d9-18239baafc90.png)
53+
54+
55+
下面是一副来自谷歌地球的重庆部分地区的切片演示:
56+
57+
![](https://user-images.githubusercontent.com/35907364/140921859-d927dea5-1fc4-4f6a-b467-3c139dab697e.gif)
58+
59+
### 2.3 地理数据保存
60+
61+
当打开标注的GTiff图像带有地理参考,可设置EISeg保存时保存为带有地理参考的GTiff和ESRI Shapefile。
62+
63+
- GTiff:已成为GIS和卫星遥感应用的行业图像标准文件。
64+
- ESRI Shapefile:是最常见的的矢量数据格式,Shapefile文件是美国环境系统研究所(ESRI)所研制的GIS文件系统格式文件,是工业标准的矢量数据文件。 所有的商业和开源GIS软件都支持。无处不在的它已成为行业标准。
65+
66+
![](https://user-images.githubusercontent.com/35907364/140917817-0626a53b-970e-4a7f-a34e-f2bc38c8d422.gif)
67+
68+
### 2.4 遥感标注模型选择
69+
70+
建筑物标注建议使用[static_hrnet18_ocr48_rsbuilding_instance](https://paddleseg.bj.bcebos.com/eiseg/0.4/static_hrnet18_ocr48_rsbuilding_instance.zip)

EISeg/docs/medical.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# 医疗相关
2+
3+
以下内容为EISeg中医疗垂类相关的文档,主要包括环境配置和功能介绍两大方面。
4+
5+
## 1 环境配置
6+
7+
EISeg使用SimpleITK打开医学影像,安装方式如下:
8+
9+
```shell
10+
pip install SimpleITK
11+
```
12+
13+
## 2 功能介绍
14+
15+
目前EISeg只支持打开单层的Dicom格式图像,对Nitfi格式和多张Dicom格式的支持正在开发中。如果打开图像的后缀为 .dcm 会询问是否开启医疗组件。
16+
17+
![med-prompt](https://linhandev.github.io/assets/img/post/Med/med-prompt.png)
18+
19+
点击确定后会出现图像窗宽窗位的设置
20+
21+
![med-widget](https://linhandev.github.io/assets/img/post/Med/med-widget.png)
22+
23+
目前EISeg提供[肝脏分割预训练模型](https://paddleseg.bj.bcebos.com/eiseg/0.4/static_hrnet18s_ocr48_lits.zip),推荐窗宽窗位400, 0。该模型用于肝脏分割效果最佳,但也可以用于其他组织或器官的分割。

EISeg/eiseg/__init__.py

+57-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,68 @@
1+
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
import sys
16+
import os
217
import os.path as osp
18+
import logging
19+
from datetime import datetime
320

4-
pjpath = osp.dirname(osp.realpath(__file__))
5-
sys.path.append(pjpath)
21+
from qtpy import QtCore
22+
import cv2
623

724
__APPNAME__ = "EISeg"
8-
__VERSION__ = "0.3.0"
25+
__VERSION__ = "0.4.0"
926

1027

11-
import os
12-
import cv2
28+
pjpath = osp.dirname(osp.realpath(__file__))
29+
sys.path.append(pjpath)
1330

1431
for k, v in os.environ.items():
1532
if k.startswith("QT_") and "cv2" in v:
1633
del os.environ[k]
34+
35+
# log
36+
settings = QtCore.QSettings(
37+
osp.join(pjpath, "config/setting.ini"), QtCore.QSettings.IniFormat
38+
)
39+
40+
logFolder = settings.value("logFolder")
41+
logLevel = bool(settings.value("log"))
42+
logDays = settings.value("logDays")
43+
44+
if logFolder is None or len(logFolder) == 0:
45+
logFolder = osp.normcase(osp.join(pjpath, "log"))
46+
if not osp.exists(logFolder):
47+
os.makedirs(logFolder)
48+
49+
if logLevel:
50+
logLevel = logging.DEBUG
51+
else:
52+
logLevel = logging.CRITICAL
53+
if logDays:
54+
logDays = int(logDays)
55+
else:
56+
logDays = 7
57+
# TODO: 删除大于logDays 的 log
58+
59+
t = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
60+
logger = logging.getLogger("EISeg Logger")
61+
handler = logging.FileHandler(osp.normcase(osp.join(logFolder, f"eiseg-{t}.log")))
62+
handler.setFormatter(
63+
logging.Formatter(
64+
"%(levelname)s - %(asctime)s - %(filename)s - %(funcName)s - %(message)s"
65+
)
66+
)
67+
logger.setLevel(logLevel)
68+
logger.addHandler(handler)

EISeg/eiseg/__main__.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1+
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
from run import main
216

17+
318
if __name__ == "__main__":
4-
main()
19+
main()

0 commit comments

Comments
 (0)