This commit is contained in:
yatenglg 2023-04-20 00:00:19 +08:00
parent cdc86e92cd
commit cd1e24af92
74 changed files with 18145 additions and 14 deletions

View File

@ -2,7 +2,7 @@
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="jdk" jdkName="Python 3.8 (ISAT_with_segment_anything)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

2
.idea/misc.xml generated
View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (base) (2)" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (ISAT_with_segment_anything)" project-jdk-type="Python SDK" />
</project>

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

16
LICENSE Normal file
View File

@ -0,0 +1,16 @@
Copyright 2023 yatengLG
https://github.com/yatengLG/ISAT_with_segment_anything
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -12,9 +12,54 @@
segment anything只是协助生成目标掩码最终标注以多边形呈现通过拖拽多边形顶点可快速修改标注区域。
## 安装
### 1. 源码运行
```shell
# 创建虚拟环境
conda create -n ISAT_with_segment_anything python==3.8
conda activate ISAT_with_segment_anything
```
```shell
# 安装Segment anything
git clone git@github.com:facebookresearch/segment-anything.git
cd segment-anything
pip install -e .
cd ..
```
```shell
# 安装ISAT_with_segment_anything
git clone https://github.com/yatengLG/ISAT_with_segment_anything.git
cd ISAT_with_segment_anything
pip install -r requirements.txt
```
```text
# 下载Segment anything预训练模型
下载任一模型并将模型存放于ISAT_with_segment_anything/segment_any目录下
模型链接:
https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth
https://dl.fbaipublicfiles.com/segment_anything/sam_vit_l_0b3195.pth
https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth
h模型最大效果也最好
b模型最小效果也最差
请按照硬件下载合适的模型h模型在示例样本上的显存需求约8G.
```
```shell
# 运行软件
python main.py
```
## 标注操作
1. 通过鼠标左键(或右键)提示感兴趣区域(或不感兴趣区域),自动形成目标分割掩码
2. 可通过多次左右键提示,提升掩码质量
3. 回车键确认掩码,选择类别,得到多边形标注区域
3. E键结束标注,选择类别,得到多边形标注区域
4. 拖拽多边形顶点,精细化调整标注
## 注意事项
1. 自动分割效果受segment anything模型分割效果限制如需更为精确的分割效果可通过手动绘制多边形实现。
2. 如只需要使用手动绘制多边形标注,推荐使用[ISAT](https://github.com/yatengLG/ISAT)。

63
README.md Normal file
View File

@ -0,0 +1,63 @@
# ISAT图像分割标注工具
![examples/demo/标注组合图.png](examples/demo/标注组合图.png)
基于多边形的图像分割标注工具,支持实例分割与语义分割。
## 特点
主要对语义标注过程中存在标注重复部分进行优化。
自己标注过分割样本或者使用coco分割数据集的朋友肯定遇到过标注多边形之间存在覆盖的问题。
本项目通过引入多边形图层高低的方式,让上层的多边形覆盖下层多边形,从而保证每一个像素的类别都是单一的,降低数据的干扰。
* 支持对多边形图层进行调整(图层置顶或置底)。
* 标注文件转png单通道图(支持实例与语义)。
* 支持滚轮缩放,左键拖动图片。
* 类别标签导入与导出,方便不同任务之间快速切换。
## 安装
### 1. 源码运行
```shell
git clone https://github.com/yatengLG/ISAT.git
cd ISAT
conda create -n ISAT python==3.8
conda activate ISAT
pip install -r requirements.txt
python main.py
```
### 2. 下载打包好的exe
- 2.1 点击[链接](https://github.com/yatengLG/ISAT/releases/download/v1.0.0/ISAT_windows.zip)下载ISAT_windows.zip
- 2.2 解压
- 2.3 双击ISAT/main.exe运行
## 标注结果
### 标注文件与标签图片
ISAT提供了**json格式标注文件**,可以方便的进行传输与二次修改;同时,软件也提供将标注文件转换为**png单通道标签图片**的功能。
#### 1. json格式标注文件
主要用于传输、备份以及二次修改。但不方便直接参与模型训练等过程。
存储信息包括图片名、图片尺寸、图片额外说明、标注目标类别、标注目标实例id、标注目标多边形顶点等。
#### 2. png单通道标签图片
主要用于模型的训练、测试等过程。
转换后的单通道标签图片具有与原图一致的分辨率,**参与模型训练时直接读取像素值作为标签即可图片为单通道图像素值为单一的值不是rgb。**
> 部分软件查看png单通道图片时存在对颜色边界处进行调整的情况。具体表现为0 5 0到(0 255 0)过渡时,边缘会出现(0 125 0)的情况。https://github.com/yatengLG/ISAT/issues/2#issue-1662058434
**最终的标签是图像的像素值,而非颜色值**
这种情况不会对标签图片造成影响,请放心使用。
### 导出png单通道标签图片
软件内置了将json标注文件转换为png单通道标签图片的工具。
转换时,区分**语义分割**与**实例分割**
- 语义分割
转换后的语义分割png单通道标签图片中每个像素值为对应的类别id具体的类别含义与标注时类别设置相一致同时在转换目录中也会留存一份classesition.txt便于查看类别与id对应关系。
- 实例分割
转换后的实例分割png单通道标签图片中每个像素值为对应的组id。
![examples/demo/将标注结果导出为png单通道图.png](examples/demo/将标注结果导出为png单通道图.png)

84
annotation.py Normal file
View File

@ -0,0 +1,84 @@
# -*- coding: utf-8 -*-
# @Author : LG
import os
import cv2
from json import load, dump
from typing import List
class Object:
def __init__(self, category:str, group:int, segmentation, area, layer, bbox, iscrowd=0, note=''):
self.category = category
self.group = group
self.segmentation = segmentation
self.area = area
self.layer = layer
self.bbox = bbox
self.iscrowd = iscrowd
self.note = note
class Annotation:
def __init__(self, image_path, label_path):
img_folder, img_name = os.path.split(image_path)
self.description = 'ISAT'
self.img_folder = img_folder
self.img_name = img_name
self.label_path = label_path
self.note = ''
image = cv2.imread(image_path)
self.height, self.width, self.depth = image.shape
del image
self.objects:List[Object,...] = []
def load_annotation(self):
if os.path.exists(self.label_path):
with open(self.label_path, 'r') as f:
dataset = load(f)
info = dataset.get('info', {})
objects = dataset.get('objects', [])
self.img_name = info.get('name', '')
self.width = info.get('width', 0)
self.height = info.get('height', 0)
self.depth = info.get('depth', 0)
self.note = info.get('note', '')
for obj in objects:
category = obj.get('category', 'unknow')
group = obj.get('group', '')
segmentation = obj.get('segmentation', [])
iscrowd = obj.get('iscrowd', 0)
note = obj.get('note', '')
area = obj.get('area', 0)
layer = obj.get('layer', 1)
bbox = obj.get('bbox', [])
obj = Object(category, group, segmentation, area, layer, bbox, iscrowd, note)
self.objects.append(obj)
def save_annotation(self):
dataset = {}
dataset['info'] = {}
dataset['info']['description'] = self.description
dataset['info']['folder'] = self.img_folder
dataset['info']['name'] = self.img_name
dataset['info']['width'] = self.width
dataset['info']['height'] = self.height
dataset['info']['depth'] = self.depth
dataset['info']['note'] = self.note
dataset['objects'] = []
for obj in self.objects:
object = {}
object['category'] = obj.category
object['group'] = obj.group
object['segmentation'] = obj.segmentation
object['area'] = obj.area
object['layer'] = obj.layer
object['bbox'] = obj.bbox
object['iscrowd'] = obj.iscrowd
object['note'] = obj.note
dataset['objects'].append(object)
with open(self.label_path, 'w') as f:
dump(dataset, f, indent=4)
return True

35
configs.py Normal file
View File

@ -0,0 +1,35 @@
import yaml
from enum import Enum
DEFAULT_CONFIG_FILE = 'default.yaml'
CONFIG_FILE = 'isat.yaml'
def load_config(file):
with open(file, 'rb')as f:
cfg = yaml.load(f.read(), Loader=yaml.FullLoader)
return cfg
def save_config(cfg, file):
s = yaml.dump(cfg)
with open(file, 'w') as f:
f.write(s)
return True
class STATUSMode(Enum):
VIEW = 0
CREATE = 1
EDIT = 2
class DRAWMode(Enum):
POLYGON = 0
SEGMENTANYTHING = 1
class CLICKMode(Enum):
POSITIVE = 0
NEGATIVE = 1
class MAPMode(Enum):
LABEL = 0
SEMANTIC = 1
INSTANCE = 2

3
default.yaml Normal file
View File

@ -0,0 +1,3 @@
label:
- color: '#000000'
name: __background__

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 KiB

View File

@ -0,0 +1,813 @@
{
"info": {
"description": "ISAT",
"folder": "C:/Users/lg/PycharmProjects/ISAT_with_segment_anything/example/images",
"name": "000000000144.jpg",
"width": 640,
"height": 480,
"depth": 3,
"note": ""
},
"objects": [
{
"category": "fence",
"group": "1",
"segmentation": [
[
20,
239
],
[
17,
240
],
[
15,
241
],
[
13,
242
],
[
11,
244
],
[
10,
244
],
[
9,
245
],
[
6,
249
],
[
5,
251
],
[
4,
255
],
[
0,
261
],
[
0,
280
],
[
1,
277
],
[
6,
268
],
[
9,
259
],
[
13,
254
],
[
13,
252
],
[
15,
250
],
[
18,
248
],
[
20,
247
],
[
24,
247
],
[
26,
248
],
[
30,
252
],
[
33,
256
],
[
35,
260
],
[
38,
266
],
[
41,
273
],
[
43,
280
],
[
50,
294
],
[
53,
297
],
[
54,
297
],
[
59,
301
],
[
61,
303
],
[
62,
316
],
[
63,
341
],
[
63,
382
],
[
64,
405
],
[
66,
414
],
[
71,
413
],
[
72,
402
],
[
72,
399
],
[
71,
359
],
[
69,
324
],
[
70,
300
],
[
73,
299
],
[
78,
294
],
[
80,
291
],
[
81,
289
],
[
83,
283
],
[
85,
278
],
[
86,
272
],
[
91,
258
],
[
94,
252
],
[
98,
248
],
[
105,
248
],
[
107,
249
],
[
111,
253
],
[
116,
261
],
[
118,
265
],
[
121,
271
],
[
128,
288
],
[
130,
291
],
[
135,
296
],
[
138,
298
],
[
140,
299
],
[
143,
300
],
[
148,
300
],
[
151,
299
],
[
153,
298
],
[
156,
296
],
[
159,
293
],
[
161,
290
],
[
164,
284
],
[
179,
255
],
[
180,
253
],
[
180,
251
],
[
181,
249
],
[
183,
247
],
[
186,
248
],
[
187,
259
],
[
188,
282
],
[
188,
303
],
[
190,
320
],
[
190,
343
],
[
191,
355
],
[
192,
357
],
[
196,
358
],
[
198,
357
],
[
200,
353
],
[
200,
341
],
[
198,
321
],
[
197,
300
],
[
196,
279
],
[
195,
252
],
[
195,
250
],
[
196,
248
],
[
200,
248
],
[
200,
249
],
[
202,
251
],
[
207,
260
],
[
208,
262
],
[
208,
264
],
[
210,
266
],
[
212,
273
],
[
215,
279
],
[
217,
281
],
[
218,
283
],
[
219,
287
],
[
221,
290
],
[
225,
294
],
[
227,
295
],
[
230,
296
],
[
235,
296
],
[
239,
295
],
[
241,
294
],
[
245,
290
],
[
246,
288
],
[
247,
286
],
[
248,
283
],
[
248,
279
],
[
245,
281
],
[
244,
283
],
[
244,
285
],
[
243,
287
],
[
238,
292
],
[
230,
292
],
[
228,
291
],
[
224,
287
],
[
222,
284
],
[
219,
278
],
[
214,
268
],
[
214,
266
],
[
207,
252
],
[
205,
249
],
[
201,
245
],
[
198,
243
],
[
194,
242
],
[
188,
242
],
[
183,
243
],
[
180,
244
],
[
176,
246
],
[
174,
249
],
[
172,
252
],
[
170,
256
],
[
169,
260
],
[
168,
262
],
[
166,
264
],
[
165,
266
],
[
164,
268
],
[
161,
276
],
[
156,
286
],
[
153,
290
],
[
152,
291
],
[
151,
291
],
[
149,
293
],
[
147,
293
],
[
144,
293
],
[
142,
293
],
[
140,
292
],
[
138,
290
],
[
136,
287
],
[
133,
281
],
[
125,
263
],
[
123,
259
],
[
120,
253
],
[
117,
248
],
[
112,
243
],
[
110,
242
],
[
107,
241
],
[
98,
241
],
[
96,
242
],
[
94,
243
],
[
89,
248
],
[
85,
256
],
[
83,
261
],
[
81,
269
],
[
78,
274
],
[
76,
282
],
[
74,
287
],
[
73,
289
],
[
67,
295
],
[
63,
295
],
[
61,
294
],
[
55,
288
],
[
53,
284
],
[
50,
278
],
[
49,
273
],
[
41,
254
],
[
40,
252
],
[
38,
249
],
[
35,
246
],
[
35,
245
],
[
33,
243
],
[
30,
241
],
[
28,
240
],
[
24,
239
]
],
"area": 4485.0,
"layer": 1.0,
"bbox": [
0.0,
239.0,
248.0,
414.0
],
"iscrowd": 0,
"note": ""
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,10 @@
__background__ 0
person 1
knife 2
fork 3
cup 4
giraffe 5
plate 6
table 7
cake 8
fence 9

10
icons.py Normal file
View File

@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file '/home/super/PycharmProjects/ISAT/icons.qrc'
#
# Created by: PyQt5 UI code generator 5.15.7
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.

37
icons.qrc Normal file
View File

@ -0,0 +1,37 @@
<RCC>
<qresource prefix="icon">
<file>icons/semantic.png</file>
<file>icons/M_Favicon.ico</file>
<file>icons/instance.png</file>
<file>icons/转换文件夹1_folder-conversion-one.svg</file>
<file>icons/转换文件1_file-conversion-one.svg</file>
<file>icons/照片_pic.svg</file>
<file>icons/一对一_one-to-one.svg</file>
<file>icons/校验_check-one.svg</file>
<file>icons/下一步_next.svg</file>
<file>icons/我的_me.svg</file>
<file>icons/文件夹-开_folder-open.svg</file>
<file>icons/缩小_zoom-out.svg</file>
<file>icons/设置_setting-two.svg</file>
<file>icons/上一步_back.svg</file>
<file>icons/删除_delete.svg</file>
<file>icons/删除_delete-two.svg</file>
<file>icons/全宽_fullwidth.svg</file>
<file>icons/去顶部_to-top.svg</file>
<file>icons/去底部_to-bottom.svg</file>
<file>icons/锚点_anchor.svg</file>
<file>icons/列表_list.svg</file>
<file>icons/列表_list-middle.svg</file>
<file>icons/开关_power.svg</file>
<file>icons/键盘_keyboard-one.svg</file>
<file>icons/关闭_close-one.svg</file>
<file>icons/放大_zoom-in.svg</file>
<file>icons/翻译_translate.svg</file>
<file>icons/传入3_afferent-three.svg</file>
<file>icons/传出3_efferent-three.svg</file>
<file>icons/编辑文件_file-editing.svg</file>
<file>icons/编辑_edit.svg</file>
<file>icons/保存硬盘_save-one.svg</file>
<file>icons/保存_save.svg</file>
</qresource>
</RCC>

1825
icons_rc.py Normal file

File diff suppressed because it is too large Load Diff

22
isat.yaml Normal file
View File

@ -0,0 +1,22 @@
label:
- color: '#000000'
name: __background__
- color: '#ef2929'
name: person
- color: '#fcaf3e'
name: knife
- color: '#fce94f'
name: fork
- color: '#8ae234'
name: cup
- color: '#729fcf'
name: giraffe
- color: '#ad7fa8'
name: plate
- color: '#e9b96e'
name: table
- color: '#a40000'
name: cake
- color: '#5c3566'
name: fence
language: zh

22
main.py
View File

@ -1,16 +1,16 @@
# This is a sample Python script.
# -*- coding: utf-8 -*-
# @Author : LG
# import os
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
from PyQt5 import QtWidgets
from widgets.mainwindow import MainWindow
import sys
def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint.
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
print_hi('PyCharm')
# See PyCharm help at https://www.jetbrains.com/help/pycharm/
app = QtWidgets.QApplication([''])
mainwindow = MainWindow()
mainwindow.show()
sys.exit(app.exec_())

9
requirements.txt Normal file
View File

@ -0,0 +1,9 @@
imgviz==1.2.6
mahotas==1.4.13
numpy==1.21.4
opencv_python_headless==4.5.3.56
Pillow==9.2.0
PyQt5==5.15.7
PyYAML==6.0
torch==1.8.1
torchvision==0.9.1

View File

@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
# @Author : LG
from segment_anything import sam_model_registry, SamPredictor
import torch
import numpy as np
class SegAny:
def __init__(self, checkpoint):
if 'vit_b' in checkpoint:
model_type = "vit_b"
elif 'vit_l' in checkpoint:
model_type = "vit_l"
elif 'vit_h' in checkpoint:
model_type = "vit_h"
else:
raise ValueError('The checkpoint named {} is not supported.'.format(checkpoint))
device = 'cuda' if torch.cuda.is_available() else 'cpu'
sam = sam_model_registry[model_type](checkpoint=checkpoint)
sam.to(device=device)
self.predictor = SamPredictor(sam)
self.image = None
def set_image(self, image):
self.predictor.set_image(image)
def reset_image(self):
self.predictor.reset_image()
self.image = None
def predict(self, input_point, input_label):
input_point = np.array(input_point)
input_label = np.array(input_label)
masks, scores, logits = self.predictor.predict(
point_coords=input_point,
point_labels=input_label,
multimask_output=True,
)
mask_input = logits[np.argmax(scores), :, :] # Choose the model's best mask
masks, _, _ = self.predictor.predict(
point_coords=input_point,
point_labels=input_label,
mask_input=mask_input[None, :, :],
multimask_output=False,
)
print('masks: {}'.format(masks))
return masks

62
tools/label_convert.py Normal file
View File

@ -0,0 +1,62 @@
# -*- coding: utf-8 -*-
# @Author : LG
from json import load
import numpy as np
from PIL import Image, ImageDraw, ImageColor
import mahotas
import imgviz
class Converter:
def __init__(self, cfg, is_segmentation):
self.is_segmentation = is_segmentation
labels = cfg.get('label', [])
self.category_dict = {}
if self.is_segmentation:
self.cmap = imgviz.label_colormap()
else:
self.cmap = np.zeros((len(labels), 3), dtype=np.uint8)
for index, label_dict in enumerate(labels):
category = label_dict.get('name', 'unknow')
color = label_dict.get('color', '#000000')
self.category_dict[category] = {'index': index, 'color': color}
self.cmap[index] = (ImageColor.getrgb(color))
def convert(self, from_path:str, to_path:str):
assert from_path.endswith('.json')
with open(from_path, 'r') as f:
dataset = load(f)
info = dataset.get('info', {})
objects = dataset.get('objects', [])
img_name = info.get('name', '')
width = info.get('width', 0)
height = info.get('height', 0)
depth = info.get('depth', 0)
note = info.get('note', '')
img = np.zeros(shape=(height, width), dtype=np.uint8)
objects = sorted(objects, key=lambda obj:obj.get('layer', 1))
for obj in objects:
category = obj.get('category', 'unknow')
group = obj.get('group', '')
segmentation = obj.get('segmentation', [])
iscrowd = obj.get('iscrowd', 0)
note = obj.get('note', '')
area = obj.get('area', 0)
layer = obj.get('layer', 1)
bbox = obj.get('bbox', [])
segmentation = [(p[1], p[0]) for p in segmentation]
if self.is_segmentation and group != '':
mahotas.polygon.fill_polygon(segmentation, img, color=int(group))
else:
mahotas.polygon.fill_polygon(segmentation, img, color=self.category_dict.get(category, {}).get('index', 0))
img = Image.fromarray(img.astype(np.uint8), mode='P')
img.putpalette(self.cmap.flatten())
img.save(to_path)
return True

400
ui/MainWindow.py Normal file
View File

@ -0,0 +1,400 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file '/home/super/PycharmProjects/ISAT_with_segment_anything/ui/MainWindow.ui'
#
# Created by: PyQt5 UI code generator 5.15.7
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(1280, 760)
MainWindow.setMinimumSize(QtCore.QSize(800, 600))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
MainWindow.setFont(font)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/icons/icons/isat_bg_50x25.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
MainWindow.setWindowIcon(icon)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setSpacing(0)
self.verticalLayout.setObjectName("verticalLayout")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setEnabled(True)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1280, 24))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
self.menubar.setFont(font)
self.menubar.setAutoFillBackground(False)
self.menubar.setDefaultUp(False)
self.menubar.setNativeMenuBar(True)
self.menubar.setObjectName("menubar")
self.menuFile = QtWidgets.QMenu(self.menubar)
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
self.menuFile.setFont(font)
self.menuFile.setObjectName("menuFile")
self.menuView = QtWidgets.QMenu(self.menubar)
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
self.menuView.setFont(font)
self.menuView.setObjectName("menuView")
self.menuAbout = QtWidgets.QMenu(self.menubar)
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
self.menuAbout.setFont(font)
self.menuAbout.setObjectName("menuAbout")
self.menuLaguage = QtWidgets.QMenu(self.menuAbout)
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(":/icon/icons/翻译_translate.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.menuLaguage.setIcon(icon1)
self.menuLaguage.setObjectName("menuLaguage")
self.menuTools = QtWidgets.QMenu(self.menubar)
self.menuTools.setEnabled(True)
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
self.menuTools.setFont(font)
self.menuTools.setObjectName("menuTools")
self.menuEdit = QtWidgets.QMenu(self.menubar)
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
self.menuEdit.setFont(font)
self.menuEdit.setObjectName("menuEdit")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setLayoutDirection(QtCore.Qt.LeftToRight)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.toolBar = QtWidgets.QToolBar(MainWindow)
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
self.toolBar.setFont(font)
self.toolBar.setIconSize(QtCore.QSize(24, 24))
self.toolBar.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
self.toolBar.setFloatable(False)
self.toolBar.setObjectName("toolBar")
MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)
self.info_dock = QtWidgets.QDockWidget(MainWindow)
self.info_dock.setMinimumSize(QtCore.QSize(80, 38))
self.info_dock.setFeatures(QtWidgets.QDockWidget.AllDockWidgetFeatures)
self.info_dock.setObjectName("info_dock")
self.dockWidgetContents_2 = QtWidgets.QWidget()
self.dockWidgetContents_2.setObjectName("dockWidgetContents_2")
self.info_dock.setWidget(self.dockWidgetContents_2)
MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.info_dock)
self.labels_dock = QtWidgets.QDockWidget(MainWindow)
self.labels_dock.setMinimumSize(QtCore.QSize(80, 38))
self.labels_dock.setFeatures(QtWidgets.QDockWidget.AllDockWidgetFeatures)
self.labels_dock.setObjectName("labels_dock")
self.dockWidgetContents_3 = QtWidgets.QWidget()
self.dockWidgetContents_3.setObjectName("dockWidgetContents_3")
self.labels_dock.setWidget(self.dockWidgetContents_3)
MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.labels_dock)
self.files_dock = QtWidgets.QDockWidget(MainWindow)
self.files_dock.setObjectName("files_dock")
self.dockWidgetContents = QtWidgets.QWidget()
self.dockWidgetContents.setObjectName("dockWidgetContents")
self.files_dock.setWidget(self.dockWidgetContents)
MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.files_dock)
self.actionOpen_dir = QtWidgets.QAction(MainWindow)
icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(":/icon/icons/照片_pic.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionOpen_dir.setIcon(icon2)
self.actionOpen_dir.setObjectName("actionOpen_dir")
self.actionZoom_in = QtWidgets.QAction(MainWindow)
icon3 = QtGui.QIcon()
icon3.addPixmap(QtGui.QPixmap(":/icon/icons/放大_zoom-in.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionZoom_in.setIcon(icon3)
self.actionZoom_in.setObjectName("actionZoom_in")
self.actionZoom_out = QtWidgets.QAction(MainWindow)
icon4 = QtGui.QIcon()
icon4.addPixmap(QtGui.QPixmap(":/icon/icons/缩小_zoom-out.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionZoom_out.setIcon(icon4)
self.actionZoom_out.setObjectName("actionZoom_out")
self.actionFit_wiondow = QtWidgets.QAction(MainWindow)
icon5 = QtGui.QIcon()
icon5.addPixmap(QtGui.QPixmap(":/icon/icons/全宽_fullwidth.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionFit_wiondow.setIcon(icon5)
self.actionFit_wiondow.setObjectName("actionFit_wiondow")
self.actionSetting = QtWidgets.QAction(MainWindow)
icon6 = QtGui.QIcon()
icon6.addPixmap(QtGui.QPixmap(":/icon/icons/设置_setting-two.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionSetting.setIcon(icon6)
self.actionSetting.setObjectName("actionSetting")
self.actionExit = QtWidgets.QAction(MainWindow)
icon7 = QtGui.QIcon()
icon7.addPixmap(QtGui.QPixmap(":/icon/icons/开关_power.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionExit.setIcon(icon7)
self.actionExit.setObjectName("actionExit")
self.actionSave_dir = QtWidgets.QAction(MainWindow)
icon8 = QtGui.QIcon()
icon8.addPixmap(QtGui.QPixmap(":/icon/icons/文件夹-开_folder-open.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionSave_dir.setIcon(icon8)
self.actionSave_dir.setObjectName("actionSave_dir")
self.actionSave = QtWidgets.QAction(MainWindow)
icon9 = QtGui.QIcon()
icon9.addPixmap(QtGui.QPixmap(":/icon/icons/保存_save.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionSave.setIcon(icon9)
self.actionSave.setObjectName("actionSave")
self.actionPrev = QtWidgets.QAction(MainWindow)
self.actionPrev.setCheckable(False)
icon10 = QtGui.QIcon()
icon10.addPixmap(QtGui.QPixmap(":/icon/icons/上一步_back.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionPrev.setIcon(icon10)
self.actionPrev.setMenuRole(QtWidgets.QAction.TextHeuristicRole)
self.actionPrev.setPriority(QtWidgets.QAction.NormalPriority)
self.actionPrev.setObjectName("actionPrev")
self.actionNext = QtWidgets.QAction(MainWindow)
icon11 = QtGui.QIcon()
icon11.addPixmap(QtGui.QPixmap(":/icon/icons/下一步_next.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionNext.setIcon(icon11)
self.actionNext.setObjectName("actionNext")
self.actionShortcut = QtWidgets.QAction(MainWindow)
icon12 = QtGui.QIcon()
icon12.addPixmap(QtGui.QPixmap(":/icon/icons/键盘_keyboard-one.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionShortcut.setIcon(icon12)
self.actionShortcut.setObjectName("actionShortcut")
self.actionAbout = QtWidgets.QAction(MainWindow)
icon13 = QtGui.QIcon()
icon13.addPixmap(QtGui.QPixmap(":/icon/icons/我的_me.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionAbout.setIcon(icon13)
self.actionAbout.setObjectName("actionAbout")
self.actionSegment_anything = QtWidgets.QAction(MainWindow)
icon14 = QtGui.QIcon()
icon14.addPixmap(QtGui.QPixmap(":/icon/icons/M_Favicon.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionSegment_anything.setIcon(icon14)
self.actionSegment_anything.setObjectName("actionSegment_anything")
self.actionDelete = QtWidgets.QAction(MainWindow)
self.actionDelete.setEnabled(False)
icon15 = QtGui.QIcon()
icon15.addPixmap(QtGui.QPixmap(":/icon/icons/删除_delete.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionDelete.setIcon(icon15)
self.actionDelete.setObjectName("actionDelete")
self.actionBit_map = QtWidgets.QAction(MainWindow)
self.actionBit_map.setCheckable(False)
self.actionBit_map.setIcon(icon2)
self.actionBit_map.setObjectName("actionBit_map")
self.actionEdit = QtWidgets.QAction(MainWindow)
self.actionEdit.setEnabled(False)
icon16 = QtGui.QIcon()
icon16.addPixmap(QtGui.QPixmap(":/icon/icons/编辑_edit.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionEdit.setIcon(icon16)
self.actionEdit.setObjectName("actionEdit")
self.actionTo_top = QtWidgets.QAction(MainWindow)
self.actionTo_top.setEnabled(False)
icon17 = QtGui.QIcon()
icon17.addPixmap(QtGui.QPixmap(":/icon/icons/去顶部_to-top.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionTo_top.setIcon(icon17)
self.actionTo_top.setObjectName("actionTo_top")
self.actionTo_bottom = QtWidgets.QAction(MainWindow)
self.actionTo_bottom.setEnabled(False)
icon18 = QtGui.QIcon()
icon18.addPixmap(QtGui.QPixmap(":/icon/icons/去底部_to-bottom.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionTo_bottom.setIcon(icon18)
self.actionTo_bottom.setObjectName("actionTo_bottom")
self.actionConverter = QtWidgets.QAction(MainWindow)
icon19 = QtGui.QIcon()
icon19.addPixmap(QtGui.QPixmap(":/icon/icons/转换文件夹1_folder-conversion-one.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionConverter.setIcon(icon19)
self.actionConverter.setWhatsThis("")
self.actionConverter.setObjectName("actionConverter")
self.actionChinese = QtWidgets.QAction(MainWindow)
self.actionChinese.setCheckable(True)
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
self.actionChinese.setFont(font)
self.actionChinese.setObjectName("actionChinese")
self.actionEnglish = QtWidgets.QAction(MainWindow)
self.actionEnglish.setCheckable(True)
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
self.actionEnglish.setFont(font)
self.actionEnglish.setObjectName("actionEnglish")
self.actionBackspace = QtWidgets.QAction(MainWindow)
icon20 = QtGui.QIcon()
icon20.addPixmap(QtGui.QPixmap(":/icon/icons/删除_delete-two.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionBackspace.setIcon(icon20)
self.actionBackspace.setObjectName("actionBackspace")
self.actionCancel = QtWidgets.QAction(MainWindow)
icon21 = QtGui.QIcon()
icon21.addPixmap(QtGui.QPixmap(":/icon/icons/关闭_close-one.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionCancel.setIcon(icon21)
self.actionCancel.setObjectName("actionCancel")
self.actionFinish = QtWidgets.QAction(MainWindow)
icon22 = QtGui.QIcon()
icon22.addPixmap(QtGui.QPixmap(":/icon/icons/校验_check-one.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionFinish.setIcon(icon22)
self.actionFinish.setObjectName("actionFinish")
self.actionPolygon = QtWidgets.QAction(MainWindow)
icon23 = QtGui.QIcon()
icon23.addPixmap(QtGui.QPixmap(":/icon/icons/锚点_anchor.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionPolygon.setIcon(icon23)
self.actionPolygon.setObjectName("actionPolygon")
self.menuFile.addAction(self.actionOpen_dir)
self.menuFile.addAction(self.actionSave_dir)
self.menuFile.addSeparator()
self.menuFile.addAction(self.actionPrev)
self.menuFile.addAction(self.actionNext)
self.menuFile.addSeparator()
self.menuFile.addAction(self.actionSetting)
self.menuFile.addAction(self.actionExit)
self.menuView.addSeparator()
self.menuView.addAction(self.actionZoom_in)
self.menuView.addAction(self.actionZoom_out)
self.menuView.addAction(self.actionFit_wiondow)
self.menuView.addSeparator()
self.menuView.addAction(self.actionBit_map)
self.menuView.addSeparator()
self.menuLaguage.addAction(self.actionChinese)
self.menuLaguage.addAction(self.actionEnglish)
self.menuAbout.addAction(self.menuLaguage.menuAction())
self.menuAbout.addAction(self.actionShortcut)
self.menuAbout.addAction(self.actionAbout)
self.menuTools.addAction(self.actionConverter)
self.menuEdit.addAction(self.actionSegment_anything)
self.menuEdit.addAction(self.actionPolygon)
self.menuEdit.addAction(self.actionBackspace)
self.menuEdit.addAction(self.actionFinish)
self.menuEdit.addAction(self.actionCancel)
self.menuEdit.addSeparator()
self.menuEdit.addAction(self.actionTo_top)
self.menuEdit.addAction(self.actionTo_bottom)
self.menuEdit.addSeparator()
self.menuEdit.addAction(self.actionEdit)
self.menuEdit.addAction(self.actionDelete)
self.menuEdit.addAction(self.actionSave)
self.menubar.addAction(self.menuFile.menuAction())
self.menubar.addAction(self.menuEdit.menuAction())
self.menubar.addAction(self.menuView.menuAction())
self.menubar.addAction(self.menuTools.menuAction())
self.menubar.addAction(self.menuAbout.menuAction())
self.toolBar.addAction(self.actionPrev)
self.toolBar.addAction(self.actionNext)
self.toolBar.addSeparator()
self.toolBar.addSeparator()
self.toolBar.addAction(self.actionSegment_anything)
self.toolBar.addAction(self.actionPolygon)
self.toolBar.addAction(self.actionBackspace)
self.toolBar.addAction(self.actionFinish)
self.toolBar.addAction(self.actionCancel)
self.toolBar.addSeparator()
self.toolBar.addAction(self.actionTo_top)
self.toolBar.addAction(self.actionTo_bottom)
self.toolBar.addAction(self.actionEdit)
self.toolBar.addAction(self.actionDelete)
self.toolBar.addAction(self.actionSave)
self.toolBar.addSeparator()
self.toolBar.addAction(self.actionZoom_in)
self.toolBar.addAction(self.actionZoom_out)
self.toolBar.addAction(self.actionFit_wiondow)
self.toolBar.addAction(self.actionBit_map)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "ISAT"))
self.menuFile.setTitle(_translate("MainWindow", "File"))
self.menuView.setTitle(_translate("MainWindow", "View"))
self.menuAbout.setTitle(_translate("MainWindow", "Help"))
self.menuLaguage.setTitle(_translate("MainWindow", "Laguage"))
self.menuTools.setTitle(_translate("MainWindow", "Tools"))
self.menuEdit.setTitle(_translate("MainWindow", "Edit"))
self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar"))
self.info_dock.setWindowTitle(_translate("MainWindow", "Info"))
self.labels_dock.setWindowTitle(_translate("MainWindow", "Labels"))
self.files_dock.setWindowTitle(_translate("MainWindow", "Files"))
self.actionOpen_dir.setText(_translate("MainWindow", "Images dir"))
self.actionOpen_dir.setStatusTip(_translate("MainWindow", "Open images dir."))
self.actionZoom_in.setText(_translate("MainWindow", "Zoom in"))
self.actionZoom_in.setStatusTip(_translate("MainWindow", "Zoom in."))
self.actionZoom_out.setText(_translate("MainWindow", "Zoom out"))
self.actionZoom_out.setStatusTip(_translate("MainWindow", "Zoom out."))
self.actionFit_wiondow.setText(_translate("MainWindow", "Fit window"))
self.actionFit_wiondow.setToolTip(_translate("MainWindow", "Fit window"))
self.actionFit_wiondow.setStatusTip(_translate("MainWindow", "Fit window."))
self.actionFit_wiondow.setShortcut(_translate("MainWindow", "F"))
self.actionSetting.setText(_translate("MainWindow", "Setting"))
self.actionSetting.setStatusTip(_translate("MainWindow", "Setting."))
self.actionExit.setText(_translate("MainWindow", "Exit"))
self.actionExit.setToolTip(_translate("MainWindow", "Exit"))
self.actionExit.setStatusTip(_translate("MainWindow", "Exit."))
self.actionSave_dir.setText(_translate("MainWindow", "Label dir"))
self.actionSave_dir.setStatusTip(_translate("MainWindow", "Open label dir."))
self.actionSave.setText(_translate("MainWindow", "Save"))
self.actionSave.setStatusTip(_translate("MainWindow", "Save annotation."))
self.actionSave.setShortcut(_translate("MainWindow", "S"))
self.actionPrev.setText(_translate("MainWindow", "Prev image"))
self.actionPrev.setToolTip(_translate("MainWindow", "Prev image"))
self.actionPrev.setStatusTip(_translate("MainWindow", "Prev image."))
self.actionPrev.setShortcut(_translate("MainWindow", "A"))
self.actionNext.setText(_translate("MainWindow", "Next image"))
self.actionNext.setToolTip(_translate("MainWindow", "Next image"))
self.actionNext.setStatusTip(_translate("MainWindow", "Next image."))
self.actionNext.setShortcut(_translate("MainWindow", "D"))
self.actionShortcut.setText(_translate("MainWindow", "Shortcut"))
self.actionAbout.setText(_translate("MainWindow", "About"))
self.actionSegment_anything.setText(_translate("MainWindow", "Segment anything"))
self.actionSegment_anything.setToolTip(_translate("MainWindow", "Segment anything"))
self.actionSegment_anything.setStatusTip(_translate("MainWindow", "Quick annotate using Segment anything."))
self.actionSegment_anything.setShortcut(_translate("MainWindow", "Q"))
self.actionDelete.setText(_translate("MainWindow", "Delete"))
self.actionDelete.setToolTip(_translate("MainWindow", "Delete polygon"))
self.actionDelete.setStatusTip(_translate("MainWindow", "Delete polygon."))
self.actionDelete.setShortcut(_translate("MainWindow", "Del"))
self.actionBit_map.setText(_translate("MainWindow", "Bit map"))
self.actionBit_map.setStatusTip(_translate("MainWindow", "Show instance or segmeent state."))
self.actionBit_map.setShortcut(_translate("MainWindow", "Space"))
self.actionEdit.setText(_translate("MainWindow", "Edit"))
self.actionEdit.setToolTip(_translate("MainWindow", "Edit polygon"))
self.actionEdit.setStatusTip(_translate("MainWindow", "Edit polygon attribute."))
self.actionTo_top.setText(_translate("MainWindow", "To top"))
self.actionTo_top.setToolTip(_translate("MainWindow", "Move polygon to top layer"))
self.actionTo_top.setStatusTip(_translate("MainWindow", "Move polygon to top layer."))
self.actionTo_top.setShortcut(_translate("MainWindow", "T"))
self.actionTo_bottom.setText(_translate("MainWindow", "To bottom"))
self.actionTo_bottom.setToolTip(_translate("MainWindow", "Move polygon to bottom layer"))
self.actionTo_bottom.setStatusTip(_translate("MainWindow", "Move polygon to bottom layer."))
self.actionTo_bottom.setShortcut(_translate("MainWindow", "B"))
self.actionConverter.setText(_translate("MainWindow", "Label converter"))
self.actionConverter.setStatusTip(_translate("MainWindow", "Convert annotations to png image."))
self.actionChinese.setText(_translate("MainWindow", "中文"))
self.actionEnglish.setText(_translate("MainWindow", "English"))
self.actionBackspace.setText(_translate("MainWindow", "Backspace"))
self.actionBackspace.setToolTip(_translate("MainWindow", "Backspace"))
self.actionBackspace.setStatusTip(_translate("MainWindow", "Backspace."))
self.actionBackspace.setShortcut(_translate("MainWindow", "Z"))
self.actionCancel.setText(_translate("MainWindow", "Cancel"))
self.actionCancel.setToolTip(_translate("MainWindow", "Annotate canceled"))
self.actionCancel.setStatusTip(_translate("MainWindow", "Annotate canceled."))
self.actionCancel.setShortcut(_translate("MainWindow", "Esc"))
self.actionFinish.setText(_translate("MainWindow", "Finish"))
self.actionFinish.setToolTip(_translate("MainWindow", "Annotate finished"))
self.actionFinish.setStatusTip(_translate("MainWindow", "Annotate finished."))
self.actionFinish.setShortcut(_translate("MainWindow", "E"))
self.actionPolygon.setText(_translate("MainWindow", "Polygon"))
self.actionPolygon.setToolTip(_translate("MainWindow", "Draw polygon"))
self.actionPolygon.setStatusTip(_translate("MainWindow", "Accurately annotate by drawing polygon. "))
self.actionPolygon.setShortcut(_translate("MainWindow", "C"))
import icons_rc

691
ui/MainWindow.ui Normal file
View File

@ -0,0 +1,691 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1280</width>
<height>760</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>800</width>
<height>600</height>
</size>
</property>
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="windowTitle">
<string>ISAT</string>
</property>
<property name="windowIcon">
<iconset>
<normaloff>:/icons/icons/isat_bg_50x25.png</normaloff>:/icons/icons/isat_bg_50x25.png</iconset>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1280</width>
<height>24</height>
</rect>
</property>
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="defaultUp">
<bool>false</bool>
</property>
<property name="nativeMenuBar">
<bool>true</bool>
</property>
<widget class="QMenu" name="menuFile">
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>File</string>
</property>
<addaction name="actionOpen_dir"/>
<addaction name="actionSave_dir"/>
<addaction name="separator"/>
<addaction name="actionPrev"/>
<addaction name="actionNext"/>
<addaction name="separator"/>
<addaction name="actionSetting"/>
<addaction name="actionExit"/>
</widget>
<widget class="QMenu" name="menuView">
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>View</string>
</property>
<addaction name="separator"/>
<addaction name="actionZoom_in"/>
<addaction name="actionZoom_out"/>
<addaction name="actionFit_wiondow"/>
<addaction name="separator"/>
<addaction name="actionBit_map"/>
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="menuAbout">
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>Help</string>
</property>
<widget class="QMenu" name="menuLaguage">
<property name="title">
<string>Laguage</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/翻译_translate.svg</normaloff>:/icon/icons/翻译_translate.svg</iconset>
</property>
<addaction name="actionChinese"/>
<addaction name="actionEnglish"/>
</widget>
<addaction name="menuLaguage"/>
<addaction name="actionShortcut"/>
<addaction name="actionAbout"/>
</widget>
<widget class="QMenu" name="menuTools">
<property name="enabled">
<bool>true</bool>
</property>
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>Tools</string>
</property>
<addaction name="actionConverter"/>
</widget>
<widget class="QMenu" name="menuEdit">
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>Edit</string>
</property>
<addaction name="actionSegment_anything"/>
<addaction name="actionPolygon"/>
<addaction name="actionBackspace"/>
<addaction name="actionFinish"/>
<addaction name="actionCancel"/>
<addaction name="separator"/>
<addaction name="actionTo_top"/>
<addaction name="actionTo_bottom"/>
<addaction name="separator"/>
<addaction name="actionEdit"/>
<addaction name="actionDelete"/>
<addaction name="actionSave"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuEdit"/>
<addaction name="menuView"/>
<addaction name="menuTools"/>
<addaction name="menuAbout"/>
</widget>
<widget class="QStatusBar" name="statusbar">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
</widget>
<widget class="QToolBar" name="toolBar">
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="windowTitle">
<string>toolBar</string>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonIconOnly</enum>
</property>
<property name="floatable">
<bool>false</bool>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionPrev"/>
<addaction name="actionNext"/>
<addaction name="separator"/>
<addaction name="separator"/>
<addaction name="actionSegment_anything"/>
<addaction name="actionPolygon"/>
<addaction name="actionBackspace"/>
<addaction name="actionFinish"/>
<addaction name="actionCancel"/>
<addaction name="separator"/>
<addaction name="actionTo_top"/>
<addaction name="actionTo_bottom"/>
<addaction name="actionEdit"/>
<addaction name="actionDelete"/>
<addaction name="actionSave"/>
<addaction name="separator"/>
<addaction name="actionZoom_in"/>
<addaction name="actionZoom_out"/>
<addaction name="actionFit_wiondow"/>
<addaction name="actionBit_map"/>
</widget>
<widget class="QDockWidget" name="info_dock">
<property name="minimumSize">
<size>
<width>80</width>
<height>38</height>
</size>
</property>
<property name="features">
<set>QDockWidget::AllDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>Info</string>
</property>
<attribute name="dockWidgetArea">
<number>2</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents_2"/>
</widget>
<widget class="QDockWidget" name="labels_dock">
<property name="minimumSize">
<size>
<width>80</width>
<height>38</height>
</size>
</property>
<property name="features">
<set>QDockWidget::AllDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>Labels</string>
</property>
<attribute name="dockWidgetArea">
<number>2</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents_3"/>
</widget>
<widget class="QDockWidget" name="files_dock">
<property name="windowTitle">
<string>Files</string>
</property>
<attribute name="dockWidgetArea">
<number>2</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents"/>
</widget>
<action name="actionOpen_dir">
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/照片_pic.svg</normaloff>:/icon/icons/照片_pic.svg</iconset>
</property>
<property name="text">
<string>Images dir</string>
</property>
<property name="statusTip">
<string>Open images dir.</string>
</property>
</action>
<action name="actionZoom_in">
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/放大_zoom-in.svg</normaloff>:/icon/icons/放大_zoom-in.svg</iconset>
</property>
<property name="text">
<string>Zoom in</string>
</property>
<property name="statusTip">
<string>Zoom in.</string>
</property>
</action>
<action name="actionZoom_out">
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/缩小_zoom-out.svg</normaloff>:/icon/icons/缩小_zoom-out.svg</iconset>
</property>
<property name="text">
<string>Zoom out</string>
</property>
<property name="statusTip">
<string>Zoom out.</string>
</property>
</action>
<action name="actionFit_wiondow">
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/全宽_fullwidth.svg</normaloff>:/icon/icons/全宽_fullwidth.svg</iconset>
</property>
<property name="text">
<string>Fit window</string>
</property>
<property name="toolTip">
<string>Fit window</string>
</property>
<property name="statusTip">
<string>Fit window.</string>
</property>
<property name="shortcut">
<string>F</string>
</property>
</action>
<action name="actionSetting">
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/设置_setting-two.svg</normaloff>:/icon/icons/设置_setting-two.svg</iconset>
</property>
<property name="text">
<string>Setting</string>
</property>
<property name="statusTip">
<string>Setting.</string>
</property>
</action>
<action name="actionExit">
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/开关_power.svg</normaloff>:/icon/icons/开关_power.svg</iconset>
</property>
<property name="text">
<string>Exit</string>
</property>
<property name="toolTip">
<string>Exit</string>
</property>
<property name="statusTip">
<string>Exit.</string>
</property>
</action>
<action name="actionSave_dir">
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/文件夹-开_folder-open.svg</normaloff>:/icon/icons/文件夹-开_folder-open.svg</iconset>
</property>
<property name="text">
<string>Label dir</string>
</property>
<property name="statusTip">
<string>Open label dir.</string>
</property>
</action>
<action name="actionSave">
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/保存_save.svg</normaloff>:/icon/icons/保存_save.svg</iconset>
</property>
<property name="text">
<string>Save</string>
</property>
<property name="statusTip">
<string>Save annotation.</string>
</property>
<property name="shortcut">
<string>S</string>
</property>
</action>
<action name="actionPrev">
<property name="checkable">
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/上一步_back.svg</normaloff>:/icon/icons/上一步_back.svg</iconset>
</property>
<property name="text">
<string>Prev image</string>
</property>
<property name="toolTip">
<string>Prev image</string>
</property>
<property name="statusTip">
<string>Prev image.</string>
</property>
<property name="shortcut">
<string>A</string>
</property>
<property name="menuRole">
<enum>QAction::TextHeuristicRole</enum>
</property>
<property name="priority">
<enum>QAction::NormalPriority</enum>
</property>
</action>
<action name="actionNext">
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/下一步_next.svg</normaloff>:/icon/icons/下一步_next.svg</iconset>
</property>
<property name="text">
<string>Next image</string>
</property>
<property name="toolTip">
<string>Next image</string>
</property>
<property name="statusTip">
<string>Next image.</string>
</property>
<property name="shortcut">
<string>D</string>
</property>
</action>
<action name="actionShortcut">
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/键盘_keyboard-one.svg</normaloff>:/icon/icons/键盘_keyboard-one.svg</iconset>
</property>
<property name="text">
<string>Shortcut</string>
</property>
</action>
<action name="actionAbout">
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/我的_me.svg</normaloff>:/icon/icons/我的_me.svg</iconset>
</property>
<property name="text">
<string>About</string>
</property>
</action>
<action name="actionSegment_anything">
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/M_Favicon.ico</normaloff>:/icon/icons/M_Favicon.ico</iconset>
</property>
<property name="text">
<string>Segment anything</string>
</property>
<property name="toolTip">
<string>Segment anything</string>
</property>
<property name="statusTip">
<string>Quick annotate using Segment anything.</string>
</property>
<property name="shortcut">
<string>Q</string>
</property>
</action>
<action name="actionDelete">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/删除_delete.svg</normaloff>:/icon/icons/删除_delete.svg</iconset>
</property>
<property name="text">
<string>Delete</string>
</property>
<property name="toolTip">
<string>Delete polygon</string>
</property>
<property name="statusTip">
<string>Delete polygon.</string>
</property>
<property name="shortcut">
<string>Del</string>
</property>
</action>
<action name="actionBit_map">
<property name="checkable">
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/照片_pic.svg</normaloff>:/icon/icons/照片_pic.svg</iconset>
</property>
<property name="text">
<string>Bit map</string>
</property>
<property name="statusTip">
<string>Show instance or segmeent state.</string>
</property>
<property name="shortcut">
<string>Space</string>
</property>
</action>
<action name="actionEdit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/编辑_edit.svg</normaloff>:/icon/icons/编辑_edit.svg</iconset>
</property>
<property name="text">
<string>Edit</string>
</property>
<property name="toolTip">
<string>Edit polygon</string>
</property>
<property name="statusTip">
<string>Edit polygon attribute.</string>
</property>
</action>
<action name="actionTo_top">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/去顶部_to-top.svg</normaloff>:/icon/icons/去顶部_to-top.svg</iconset>
</property>
<property name="text">
<string>To top</string>
</property>
<property name="toolTip">
<string>Move polygon to top layer</string>
</property>
<property name="statusTip">
<string>Move polygon to top layer.</string>
</property>
<property name="shortcut">
<string>T</string>
</property>
</action>
<action name="actionTo_bottom">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/去底部_to-bottom.svg</normaloff>:/icon/icons/去底部_to-bottom.svg</iconset>
</property>
<property name="text">
<string>To bottom</string>
</property>
<property name="toolTip">
<string>Move polygon to bottom layer</string>
</property>
<property name="statusTip">
<string>Move polygon to bottom layer.</string>
</property>
<property name="shortcut">
<string>B</string>
</property>
</action>
<action name="actionConverter">
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/转换文件夹1_folder-conversion-one.svg</normaloff>:/icon/icons/转换文件夹1_folder-conversion-one.svg</iconset>
</property>
<property name="text">
<string>Label converter</string>
</property>
<property name="statusTip">
<string>Convert annotations to png image.</string>
</property>
<property name="whatsThis">
<string/>
</property>
</action>
<action name="actionChinese">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>中文</string>
</property>
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>12</pointsize>
</font>
</property>
</action>
<action name="actionEnglish">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>English</string>
</property>
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>12</pointsize>
</font>
</property>
</action>
<action name="actionBackspace">
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/删除_delete-two.svg</normaloff>:/icon/icons/删除_delete-two.svg</iconset>
</property>
<property name="text">
<string>Backspace</string>
</property>
<property name="toolTip">
<string>Backspace</string>
</property>
<property name="statusTip">
<string>Backspace.</string>
</property>
<property name="shortcut">
<string>Z</string>
</property>
</action>
<action name="actionCancel">
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/关闭_close-one.svg</normaloff>:/icon/icons/关闭_close-one.svg</iconset>
</property>
<property name="text">
<string>Cancel</string>
</property>
<property name="toolTip">
<string>Annotate canceled</string>
</property>
<property name="statusTip">
<string>Annotate canceled.</string>
</property>
<property name="shortcut">
<string>Esc</string>
</property>
</action>
<action name="actionFinish">
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/校验_check-one.svg</normaloff>:/icon/icons/校验_check-one.svg</iconset>
</property>
<property name="text">
<string>Finish</string>
</property>
<property name="toolTip">
<string>Annotate finished</string>
</property>
<property name="statusTip">
<string>Annotate finished.</string>
</property>
<property name="shortcut">
<string>E</string>
</property>
</action>
<action name="actionPolygon">
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icon/icons/锚点_anchor.svg</normaloff>:/icon/icons/锚点_anchor.svg</iconset>
</property>
<property name="text">
<string>Polygon</string>
</property>
<property name="toolTip">
<string>Draw polygon</string>
</property>
<property name="statusTip">
<string>Accurately annotate by drawing polygon. </string>
</property>
<property name="shortcut">
<string>C</string>
</property>
</action>
</widget>
<resources>
<include location="../icons.qrc"/>
</resources>
<connections/>
</ui>

77
ui/about_dialog.py Normal file
View File

@ -0,0 +1,77 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file '/home/super/PycharmProjects/ISAT_with_segment_anything/ui/about_dialog.ui'
#
# Created by: PyQt5 UI code generator 5.15.7
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(550, 280)
Dialog.setMinimumSize(QtCore.QSize(550, 280))
Dialog.setMaximumSize(QtCore.QSize(550, 280))
self.verticalLayout = QtWidgets.QVBoxLayout(Dialog)
self.verticalLayout.setObjectName("verticalLayout")
self.widget = QtWidgets.QWidget(Dialog)
self.widget.setObjectName("widget")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.widget)
self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
self.verticalLayout_2.setSpacing(0)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.widget_2 = QtWidgets.QWidget(self.widget)
self.widget_2.setMaximumSize(QtCore.QSize(16777215, 40))
self.widget_2.setObjectName("widget_2")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.widget_2)
self.horizontalLayout.setObjectName("horizontalLayout")
self.label = QtWidgets.QLabel(self.widget_2)
self.label.setMaximumSize(QtCore.QSize(16777215, 50))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(20)
self.label.setFont(font)
self.label.setObjectName("label")
self.horizontalLayout.addWidget(self.label)
self.verticalLayout_2.addWidget(self.widget_2)
self.widget_3 = QtWidgets.QWidget(self.widget)
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
self.widget_3.setFont(font)
self.widget_3.setObjectName("widget_3")
self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.widget_3)
self.verticalLayout_3.setObjectName("verticalLayout_3")
self.label_2 = QtWidgets.QLabel(self.widget_3)
font = QtGui.QFont()
font.setPointSize(18)
self.label_2.setFont(font)
self.label_2.setAlignment(QtCore.Qt.AlignCenter)
self.label_2.setObjectName("label_2")
self.verticalLayout_3.addWidget(self.label_2)
self.label_4 = QtWidgets.QLabel(self.widget_3)
self.label_4.setMaximumSize(QtCore.QSize(16777215, 40))
self.label_4.setLayoutDirection(QtCore.Qt.LeftToRight)
self.label_4.setStyleSheet("color: rgb(133, 0, 0);")
self.label_4.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_4.setObjectName("label_4")
self.verticalLayout_3.addWidget(self.label_4)
self.verticalLayout_2.addWidget(self.widget_3)
self.verticalLayout.addWidget(self.widget)
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "about"))
self.label.setText(_translate("Dialog", "About"))
self.label_2.setText(_translate("Dialog", "ISAT with Segment anything."))
self.label_4.setText(_translate("Dialog", "ISAT Copyright (C) 2022 yatengLG.\n"
"http://www.yatenglg.cn/isat"))
import icons_rc

137
ui/about_dialog.ui Normal file
View File

@ -0,0 +1,137 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>550</width>
<height>280</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>550</width>
<height>280</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>550</width>
<height>280</height>
</size>
</property>
<property name="windowTitle">
<string>about</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="widget_2" native="true">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>40</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>20</pointsize>
</font>
</property>
<property name="text">
<string>About</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_3" native="true">
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>12</pointsize>
</font>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>18</pointsize>
</font>
</property>
<property name="text">
<string>ISAT with Segment anything.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>40</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(133, 0, 0);</string>
</property>
<property name="text">
<string>ISAT Copyright (C) 2022 yatengLG.
http://www.yatenglg.cn/isat</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../icons.qrc"/>
</resources>
<connections/>
</ui>

128
ui/category_choice.py Normal file
View File

@ -0,0 +1,128 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file '/home/super/PycharmProjects/ISAT_with_segment_anything/ui/category_choice.ui'
#
# Created by: PyQt5 UI code generator 5.15.7
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(350, 400)
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
Dialog.setFont(font)
Dialog.setWindowTitle("")
self.verticalLayout = QtWidgets.QVBoxLayout(Dialog)
self.verticalLayout.setObjectName("verticalLayout")
self.listWidget = QtWidgets.QListWidget(Dialog)
self.listWidget.setObjectName("listWidget")
self.verticalLayout.addWidget(self.listWidget)
self.widget_3 = QtWidgets.QWidget(Dialog)
self.widget_3.setObjectName("widget_3")
self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.widget_3)
self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.label_2 = QtWidgets.QLabel(self.widget_3)
self.label_2.setMinimumSize(QtCore.QSize(60, 0))
self.label_2.setMaximumSize(QtCore.QSize(60, 16777215))
self.label_2.setObjectName("label_2")
self.horizontalLayout_3.addWidget(self.label_2)
self.lineEdit_category = QtWidgets.QLineEdit(self.widget_3)
self.lineEdit_category.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.lineEdit_category.setReadOnly(True)
self.lineEdit_category.setObjectName("lineEdit_category")
self.horizontalLayout_3.addWidget(self.lineEdit_category)
self.label = QtWidgets.QLabel(self.widget_3)
self.label.setMinimumSize(QtCore.QSize(50, 0))
self.label.setMaximumSize(QtCore.QSize(50, 16777215))
self.label.setObjectName("label")
self.horizontalLayout_3.addWidget(self.label)
self.lineEdit_group = QtWidgets.QLineEdit(self.widget_3)
self.lineEdit_group.setMinimumSize(QtCore.QSize(60, 0))
self.lineEdit_group.setMaximumSize(QtCore.QSize(60, 16777215))
self.lineEdit_group.setInputMethodHints(QtCore.Qt.ImhDigitsOnly)
self.lineEdit_group.setText("")
self.lineEdit_group.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.lineEdit_group.setObjectName("lineEdit_group")
self.horizontalLayout_3.addWidget(self.lineEdit_group)
self.verticalLayout.addWidget(self.widget_3)
self.widget_5 = QtWidgets.QWidget(Dialog)
self.widget_5.setObjectName("widget_5")
self.horizontalLayout_5 = QtWidgets.QHBoxLayout(self.widget_5)
self.horizontalLayout_5.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_5.setObjectName("horizontalLayout_5")
self.label_3 = QtWidgets.QLabel(self.widget_5)
self.label_3.setMinimumSize(QtCore.QSize(60, 0))
self.label_3.setMaximumSize(QtCore.QSize(60, 16777215))
self.label_3.setObjectName("label_3")
self.horizontalLayout_5.addWidget(self.label_3)
self.lineEdit_note = QtWidgets.QLineEdit(self.widget_5)
self.lineEdit_note.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.lineEdit_note.setObjectName("lineEdit_note")
self.horizontalLayout_5.addWidget(self.lineEdit_note)
self.label_4 = QtWidgets.QLabel(self.widget_5)
self.label_4.setMinimumSize(QtCore.QSize(50, 0))
self.label_4.setMaximumSize(QtCore.QSize(50, 16777215))
self.label_4.setObjectName("label_4")
self.horizontalLayout_5.addWidget(self.label_4)
self.label_layer = QtWidgets.QLabel(self.widget_5)
self.label_layer.setMinimumSize(QtCore.QSize(60, 0))
self.label_layer.setMaximumSize(QtCore.QSize(60, 16777215))
self.label_layer.setText("")
self.label_layer.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_layer.setObjectName("label_layer")
self.horizontalLayout_5.addWidget(self.label_layer)
self.verticalLayout.addWidget(self.widget_5)
self.widget = QtWidgets.QWidget(Dialog)
self.widget.setObjectName("widget")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.widget)
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout.setObjectName("horizontalLayout")
self.verticalLayout.addWidget(self.widget)
self.widget_2 = QtWidgets.QWidget(Dialog)
self.widget_2.setObjectName("widget_2")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.widget_2)
self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.checkBox_iscrowded = QtWidgets.QCheckBox(self.widget_2)
self.checkBox_iscrowded.setObjectName("checkBox_iscrowded")
self.horizontalLayout_2.addWidget(self.checkBox_iscrowded)
spacerItem = QtWidgets.QSpacerItem(97, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem)
self.pushButton_cache = QtWidgets.QPushButton(self.widget_2)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/icons/icons/关闭_close-one.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.pushButton_cache.setIcon(icon)
self.pushButton_cache.setObjectName("pushButton_cache")
self.horizontalLayout_2.addWidget(self.pushButton_cache)
self.pushButton_apply = QtWidgets.QPushButton(self.widget_2)
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(":/icons/icons/校验_check-one.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.pushButton_apply.setIcon(icon1)
self.pushButton_apply.setObjectName("pushButton_apply")
self.horizontalLayout_2.addWidget(self.pushButton_apply)
self.verticalLayout.addWidget(self.widget_2)
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
self.label_2.setText(_translate("Dialog", "category:"))
self.label.setText(_translate("Dialog", "group:"))
self.lineEdit_group.setPlaceholderText(_translate("Dialog", "group id"))
self.label_3.setText(_translate("Dialog", "note:"))
self.lineEdit_note.setPlaceholderText(_translate("Dialog", "add extra note here"))
self.label_4.setText(_translate("Dialog", "layer:"))
self.checkBox_iscrowded.setText(_translate("Dialog", "is crowded"))
self.pushButton_cache.setText(_translate("Dialog", "cache"))
self.pushButton_apply.setText(_translate("Dialog", "apply"))
import icons_rc

292
ui/category_choice.ui Normal file
View File

@ -0,0 +1,292 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>400</height>
</rect>
</property>
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="listWidget"/>
</item>
<item>
<widget class="QWidget" name="widget_3" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>category:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_category">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>group:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_group">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="inputMethodHints">
<set>Qt::ImhDigitsOnly</set>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="placeholderText">
<string>group id</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_5" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_3">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>note:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_note">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="placeholderText">
<string>add extra note here</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>layer:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_layer">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="checkBox_iscrowded">
<property name="text">
<string>is crowded</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>97</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_cache">
<property name="text">
<string>cache</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/icons/关闭_close-one.svg</normaloff>:/icons/icons/关闭_close-one.svg</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_apply">
<property name="text">
<string>apply</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/icons/校验_check-one.svg</normaloff>:/icons/icons/校验_check-one.svg</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../icons.qrc"/>
</resources>
<connections/>
</ui>

117
ui/convert_dialog.py Normal file
View File

@ -0,0 +1,117 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file '/home/super/PycharmProjects/ISAT_with_segment_anything/ui/convert_dialog.ui'
#
# Created by: PyQt5 UI code generator 5.15.7
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.setWindowModality(QtCore.Qt.NonModal)
Dialog.resize(450, 175)
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
Dialog.setFont(font)
Dialog.setSizeGripEnabled(False)
Dialog.setModal(False)
self.verticalLayout = QtWidgets.QVBoxLayout(Dialog)
self.verticalLayout.setObjectName("verticalLayout")
self.widget = QtWidgets.QWidget(Dialog)
self.widget.setObjectName("widget")
self.gridLayout = QtWidgets.QGridLayout(self.widget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout")
self.lineEdit_save_root = QtWidgets.QLineEdit(self.widget)
self.lineEdit_save_root.setEnabled(True)
self.lineEdit_save_root.setReadOnly(True)
self.lineEdit_save_root.setObjectName("lineEdit_save_root")
self.gridLayout.addWidget(self.lineEdit_save_root, 3, 0, 1, 1)
self.pushButton_save_root = QtWidgets.QPushButton(self.widget)
self.pushButton_save_root.setObjectName("pushButton_save_root")
self.gridLayout.addWidget(self.pushButton_save_root, 3, 1, 1, 1)
self.checkBox_is_instance = QtWidgets.QCheckBox(self.widget)
self.checkBox_is_instance.setToolTip("")
self.checkBox_is_instance.setAccessibleName("")
self.checkBox_is_instance.setAccessibleDescription("")
self.checkBox_is_instance.setObjectName("checkBox_is_instance")
self.gridLayout.addWidget(self.checkBox_is_instance, 4, 1, 1, 1)
self.lineEdit_label_root = QtWidgets.QLineEdit(self.widget)
self.lineEdit_label_root.setEnabled(True)
self.lineEdit_label_root.setReadOnly(True)
self.lineEdit_label_root.setObjectName("lineEdit_label_root")
self.gridLayout.addWidget(self.lineEdit_label_root, 2, 0, 1, 1)
self.pushButton_label_root = QtWidgets.QPushButton(self.widget)
self.pushButton_label_root.setObjectName("pushButton_label_root")
self.gridLayout.addWidget(self.pushButton_label_root, 2, 1, 1, 1)
self.verticalLayout.addWidget(self.widget)
self.widget_process = QtWidgets.QWidget(Dialog)
self.widget_process.setObjectName("widget_process")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.widget_process)
self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.progressBar = QtWidgets.QProgressBar(self.widget_process)
self.progressBar.setProperty("value", 0)
self.progressBar.setObjectName("progressBar")
self.horizontalLayout_2.addWidget(self.progressBar)
self.current_num = QtWidgets.QLabel(self.widget_process)
self.current_num.setText("")
self.current_num.setObjectName("current_num")
self.horizontalLayout_2.addWidget(self.current_num)
self.label_3 = QtWidgets.QLabel(self.widget_process)
self.label_3.setObjectName("label_3")
self.horizontalLayout_2.addWidget(self.label_3)
self.all_num = QtWidgets.QLabel(self.widget_process)
self.all_num.setText("")
self.all_num.setObjectName("all_num")
self.horizontalLayout_2.addWidget(self.all_num)
self.verticalLayout.addWidget(self.widget_process)
self.widget_2 = QtWidgets.QWidget(Dialog)
self.widget_2.setObjectName("widget_2")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.widget_2)
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout.setObjectName("horizontalLayout")
self.label = QtWidgets.QLabel(self.widget_2)
self.label.setStyleSheet("color: rgb(255, 0, 0);")
self.label.setObjectName("label")
self.horizontalLayout.addWidget(self.label)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.pushButton_cache = QtWidgets.QPushButton(self.widget_2)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/icons/icons/关闭_close-one.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.pushButton_cache.setIcon(icon)
self.pushButton_cache.setObjectName("pushButton_cache")
self.horizontalLayout.addWidget(self.pushButton_cache)
self.pushButton_apply = QtWidgets.QPushButton(self.widget_2)
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(":/icons/icons/校验_check-one.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.pushButton_apply.setIcon(icon1)
self.pushButton_apply.setObjectName("pushButton_apply")
self.horizontalLayout.addWidget(self.pushButton_apply)
self.verticalLayout.addWidget(self.widget_2)
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "ISAT to png converter"))
self.lineEdit_save_root.setPlaceholderText(_translate("Dialog", "png save root"))
self.pushButton_save_root.setText(_translate("Dialog", "Save root"))
self.checkBox_is_instance.setText(_translate("Dialog", "Is Instance"))
self.lineEdit_label_root.setPlaceholderText(_translate("Dialog", "ISAT annotations root"))
self.pushButton_label_root.setText(_translate("Dialog", "Label root"))
self.label_3.setAccessibleName(_translate("Dialog", "aaa"))
self.label_3.setText(_translate("Dialog", "/"))
self.label.setText(_translate("Dialog", "Convert ISAT annotations to png."))
self.pushButton_cache.setText(_translate("Dialog", "cache"))
self.pushButton_apply.setText(_translate("Dialog", "convert"))
import icons_rc

224
ui/convert_dialog.ui Normal file
View File

@ -0,0 +1,224 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="windowModality">
<enum>Qt::NonModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>450</width>
<height>175</height>
</rect>
</property>
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="windowTitle">
<string>ISAT to png converter</string>
</property>
<property name="sizeGripEnabled">
<bool>false</bool>
</property>
<property name="modal">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="3" column="0">
<widget class="QLineEdit" name="lineEdit_save_root">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>png save root</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="pushButton_save_root">
<property name="text">
<string>Save root</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="checkBox_is_instance">
<property name="toolTip">
<string/>
</property>
<property name="accessibleName">
<string/>
</property>
<property name="accessibleDescription">
<string/>
</property>
<property name="text">
<string>Is Instance</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLineEdit" name="lineEdit_label_root">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>ISAT annotations root</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pushButton_label_root">
<property name="text">
<string>Label root</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_process" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="current_num">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="accessibleName">
<string>aaa</string>
</property>
<property name="text">
<string>/</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="all_num">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="styleSheet">
<string notr="true">color: rgb(255, 0, 0);</string>
</property>
<property name="text">
<string>Convert ISAT annotations to png.</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_cache">
<property name="text">
<string>cache</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/icons/关闭_close-one.svg</normaloff>:/icons/icons/关闭_close-one.svg</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_apply">
<property name="text">
<string>convert</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/icons/校验_check-one.svg</normaloff>:/icons/icons/校验_check-one.svg</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../icons.qrc"/>
</resources>
<connections/>
</ui>

724
ui/en.ts Normal file
View File

@ -0,0 +1,724 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>Dialog</name>
<message>
<location filename="category_choice.py" line="119"/>
<source>category:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="category_choice.py" line="120"/>
<source>group:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="category_choice.py" line="121"/>
<source>group id</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="category_choice.py" line="122"/>
<source>note:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="category_choice.py" line="123"/>
<source>add extra note here</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="category_choice.py" line="125"/>
<source>is crowded</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="category_choice.py" line="124"/>
<source>layer:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="convert_dialog.py" line="115"/>
<source>cache</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="category_choice.py" line="127"/>
<source>apply</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="convert_dialog.py" line="106"/>
<source>ISAT to png converter</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="convert_dialog.py" line="107"/>
<source>png save root</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="convert_dialog.py" line="108"/>
<source>Save root</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="convert_dialog.py" line="110"/>
<source>ISAT annotations root</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="convert_dialog.py" line="111"/>
<source>Label root</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="convert_dialog.py" line="112"/>
<source>aaa</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="convert_dialog.py" line="113"/>
<source>/</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="convert_dialog.py" line="114"/>
<source>Convert ISAT annotations to png.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="convert_dialog.py" line="116"/>
<source>convert</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="242"/>
<source>help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="265"/>
<source>E</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="260"/>
<source>Del</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="245"/>
<source>S</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="250"/>
<source>Save annotation</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="247"/>
<source>T</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="259"/>
<source>Delete polygon</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="244"/>
<source>B</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="262"/>
<source>Next image</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="246"/>
<source>D</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="248"/>
<source>A</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="253"/>
<source>Bit map</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="254"/>
<source>Space</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="256"/>
<source>F</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="setting_dialog.py" line="93"/>
<source>Label</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="setting_dialog.py" line="98"/>
<source>Apply</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="setting_dialog.py" line="97"/>
<source>Cache</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="about_dialog.py" line="72"/>
<source>about</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="about_dialog.py" line="73"/>
<source>About</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="about_dialog.py" line="74"/>
<source>ISAT with Segment anything.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="about_dialog.py" line="75"/>
<source>ISAT Copyright (C) 2022 yatengLG.
http://www.yatenglg.cn/isat</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="convert_dialog.py" line="109"/>
<source>Is Instance</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="setting_dialog.py" line="92"/>
<source>Setting</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="setting_dialog.py" line="94"/>
<source>Add new label</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="setting_dialog.py" line="95"/>
<source>Import</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="setting_dialog.py" line="96"/>
<source>Export</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="243"/>
<source>Shortcut</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="249"/>
<source>Prior image</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="269"/>
<source>To top</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="258"/>
<source>To bottom</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="255"/>
<source>Zoom fit</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="252"/>
<source>Draw polygon</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="257"/>
<source>Segment anything</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="261"/>
<source>Q</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="263"/>
<source>Backspace</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="264"/>
<source>Z</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="266"/>
<source>Annotate finish</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="267"/>
<source>Annotate cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="268"/>
<source>Esc</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Form</name>
<message>
<location filename="label_dock.py" line="31"/>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="file_dock.py" line="54"/>
<source>/</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="info_dock.py" line="89"/>
<source>width :</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="info_dock.py" line="90"/>
<source>height:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="info_dock.py" line="91"/>
<source>depth :</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="info_dock.py" line="92"/>
<source>note:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="info_dock.py" line="93"/>
<source>add extra image note here</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="file_dock.py" line="52"/>
<source>Jump to the image. Input name or index.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="file_dock.py" line="53"/>
<source>Jump to the image.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MainWindow</name>
<message>
<location filename="MainWindow.py" line="317"/>
<source>ISAT</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="318"/>
<source>File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="319"/>
<source>View</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="320"/>
<source>Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="322"/>
<source>Tools</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="369"/>
<source>Edit</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="324"/>
<source>toolBar</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="325"/>
<source>Info</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="326"/>
<source>Labels</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="327"/>
<source>Files</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="330"/>
<source>Zoom in</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="332"/>
<source>Zoom out</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="335"/>
<source>Fit window</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="337"/>
<source>F</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="338"/>
<source>Setting</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="341"/>
<source>Exit</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="345"/>
<source>Save</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="347"/>
<source>S</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="349"/>
<source>Prev image</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="351"/>
<source>A</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="353"/>
<source>Next image</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="355"/>
<source>D</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="357"/>
<source>About</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="399"/>
<source>C</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="362"/>
<source>Delete</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="363"/>
<source>Delete polygon</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="365"/>
<source>Del</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="366"/>
<source>Bit map</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="368"/>
<source>Space</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="370"/>
<source>Edit polygon</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="395"/>
<source>E</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="372"/>
<source>To top</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="373"/>
<source>Move polygon to top layer</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="375"/>
<source>T</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="376"/>
<source>To bottom</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="377"/>
<source>Move polygon to bottom layer</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="379"/>
<source>B</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="380"/>
<source>Label converter</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="381"/>
<source>Convert annotations to png image.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="321"/>
<source>Laguage</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="328"/>
<source>Images dir</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="329"/>
<source>Open images dir.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="331"/>
<source>Zoom in.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="333"/>
<source>Zoom out.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="336"/>
<source>Fit window.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="339"/>
<source>Setting.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="342"/>
<source>Exit.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="343"/>
<source>Label dir</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="344"/>
<source>Open label dir.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="346"/>
<source>Save annotation.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="350"/>
<source>Prev image.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="354"/>
<source>Next image.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="356"/>
<source>Shortcut</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="359"/>
<source>Segment anything</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="360"/>
<source>Quick annotate using Segment anything.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="361"/>
<source>Q</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="364"/>
<source>Delete polygon.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="367"/>
<source>Show instance or segmeent state.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="371"/>
<source>Edit polygon attribute.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="374"/>
<source>Move polygon to top layer.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="378"/>
<source>Move polygon to bottom layer.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="382"/>
<source></source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="383"/>
<source>English</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="385"/>
<source>Backspace</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="386"/>
<source>Backspace.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="387"/>
<source>Z</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="388"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="389"/>
<source>Annotate canceled</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="390"/>
<source>Annotate canceled.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="391"/>
<source>Esc</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="392"/>
<source>Finish</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="393"/>
<source>Annotate finished</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="394"/>
<source>Annotate finished.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="396"/>
<source>Polygon</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="397"/>
<source>Draw polygon</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.py" line="398"/>
<source>Accurately annotate by drawing polygon. </source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

54
ui/file_dock.py Normal file
View File

@ -0,0 +1,54 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file '/home/super/PycharmProjects/ISAT/ui/file_dock.ui'
#
# Created by: PyQt5 UI code generator 5.15.7
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(264, 341)
self.verticalLayout = QtWidgets.QVBoxLayout(Form)
self.verticalLayout.setContentsMargins(9, 9, 9, 9)
self.verticalLayout.setSpacing(6)
self.verticalLayout.setObjectName("verticalLayout")
self.listWidget = QtWidgets.QListWidget(Form)
self.listWidget.setObjectName("listWidget")
self.verticalLayout.addWidget(self.listWidget)
self.widget_num = QtWidgets.QWidget(Form)
self.widget_num.setObjectName("widget_num")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.widget_num)
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout.setObjectName("horizontalLayout")
self.lineEdit_jump = QtWidgets.QLineEdit(self.widget_num)
self.lineEdit_jump.setObjectName("lineEdit_jump")
self.horizontalLayout.addWidget(self.lineEdit_jump)
self.label_current = QtWidgets.QLabel(self.widget_num)
self.label_current.setText("")
self.label_current.setObjectName("label_current")
self.horizontalLayout.addWidget(self.label_current)
self.label = QtWidgets.QLabel(self.widget_num)
self.label.setObjectName("label")
self.horizontalLayout.addWidget(self.label)
self.label_all = QtWidgets.QLabel(self.widget_num)
self.label_all.setText("")
self.label_all.setObjectName("label_all")
self.horizontalLayout.addWidget(self.label_all)
self.verticalLayout.addWidget(self.widget_num)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.lineEdit_jump.setToolTip(_translate("Form", "Jump to the image. Input name or index."))
self.lineEdit_jump.setPlaceholderText(_translate("Form", "Jump to the image."))
self.label.setText(_translate("Form", "/"))

88
ui/file_dock.ui Normal file
View File

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>264</width>
<height>341</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<widget class="QListWidget" name="listWidget"/>
</item>
<item>
<widget class="QWidget" name="widget_num" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="lineEdit_jump">
<property name="toolTip">
<string>Jump to the image. Input name or index.</string>
</property>
<property name="placeholderText">
<string>Jump to the image.</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_current">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>/</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_all">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

93
ui/info_dock.py Normal file
View File

@ -0,0 +1,93 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file '/home/super/PycharmProjects/ISAT/ui/info_dock.ui'
#
# Created by: PyQt5 UI code generator 5.15.7
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(347, 156)
Form.setMinimumSize(QtCore.QSize(0, 100))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
Form.setFont(font)
self.verticalLayout = QtWidgets.QVBoxLayout(Form)
self.verticalLayout.setObjectName("verticalLayout")
self.widget = QtWidgets.QWidget(Form)
self.widget.setObjectName("widget")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.widget)
self.horizontalLayout.setContentsMargins(9, 0, 9, 0)
self.horizontalLayout.setObjectName("horizontalLayout")
self.label = QtWidgets.QLabel(self.widget)
self.label.setMinimumSize(QtCore.QSize(0, 0))
self.label.setMaximumSize(QtCore.QSize(60, 16777215))
self.label.setObjectName("label")
self.horizontalLayout.addWidget(self.label)
self.label_width = QtWidgets.QLabel(self.widget)
self.label_width.setText("")
self.label_width.setObjectName("label_width")
self.horizontalLayout.addWidget(self.label_width)
self.verticalLayout.addWidget(self.widget)
self.widget_2 = QtWidgets.QWidget(Form)
self.widget_2.setObjectName("widget_2")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.widget_2)
self.horizontalLayout_2.setContentsMargins(9, 0, 9, 0)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.label_2 = QtWidgets.QLabel(self.widget_2)
self.label_2.setMinimumSize(QtCore.QSize(0, 0))
self.label_2.setMaximumSize(QtCore.QSize(60, 16777215))
self.label_2.setObjectName("label_2")
self.horizontalLayout_2.addWidget(self.label_2)
self.label_height = QtWidgets.QLabel(self.widget_2)
self.label_height.setText("")
self.label_height.setObjectName("label_height")
self.horizontalLayout_2.addWidget(self.label_height)
self.verticalLayout.addWidget(self.widget_2)
self.widget_4 = QtWidgets.QWidget(Form)
self.widget_4.setObjectName("widget_4")
self.horizontalLayout_4 = QtWidgets.QHBoxLayout(self.widget_4)
self.horizontalLayout_4.setContentsMargins(9, 0, 9, 0)
self.horizontalLayout_4.setObjectName("horizontalLayout_4")
self.label_3 = QtWidgets.QLabel(self.widget_4)
self.label_3.setMaximumSize(QtCore.QSize(60, 16777215))
self.label_3.setObjectName("label_3")
self.horizontalLayout_4.addWidget(self.label_3)
self.label_depth = QtWidgets.QLabel(self.widget_4)
self.label_depth.setText("")
self.label_depth.setObjectName("label_depth")
self.horizontalLayout_4.addWidget(self.label_depth)
self.verticalLayout.addWidget(self.widget_4)
self.widget_3 = QtWidgets.QWidget(Form)
self.widget_3.setObjectName("widget_3")
self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.widget_3)
self.horizontalLayout_3.setContentsMargins(9, 0, 9, 0)
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.label_5 = QtWidgets.QLabel(self.widget_3)
self.label_5.setObjectName("label_5")
self.horizontalLayout_3.addWidget(self.label_5)
self.lineEdit_note = QtWidgets.QLineEdit(self.widget_3)
self.lineEdit_note.setMinimumSize(QtCore.QSize(200, 0))
self.lineEdit_note.setObjectName("lineEdit_note")
self.horizontalLayout_3.addWidget(self.lineEdit_note)
self.verticalLayout.addWidget(self.widget_3)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.label.setText(_translate("Form", "width :"))
self.label_2.setText(_translate("Form", "height:"))
self.label_3.setText(_translate("Form", "depth :"))
self.label_5.setText(_translate("Form", "note:"))
self.lineEdit_note.setPlaceholderText(_translate("Form", "add extra image note here"))

197
ui/info_dock.ui Normal file
View File

@ -0,0 +1,197 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>347</width>
<height>156</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>100</height>
</size>
</property>
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>width :</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_width">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>height:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_height">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_4" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_3">
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>depth :</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_depth">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_3" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>note:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_note">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="placeholderText">
<string>add extra image note here</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

31
ui/label_dock.py Normal file
View File

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file '/home/super/PycharmProjects/ISAT/ui/label_dock.ui'
#
# Created by: PyQt5 UI code generator 5.15.7
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(250, 304)
self.verticalLayout = QtWidgets.QVBoxLayout(Form)
self.verticalLayout.setContentsMargins(2, 2, 2, 2)
self.verticalLayout.setSpacing(0)
self.verticalLayout.setObjectName("verticalLayout")
self.listWidget = QtWidgets.QListWidget(Form)
self.listWidget.setObjectName("listWidget")
self.verticalLayout.addWidget(self.listWidget)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))

39
ui/label_dock.ui Normal file
View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>250</width>
<height>304</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QListWidget" name="listWidget"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

99
ui/setting_dialog.py Normal file
View File

@ -0,0 +1,99 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file '/home/super/PycharmProjects/ISAT_with_segment_anything/ui/setting_dialog.ui'
#
# Created by: PyQt5 UI code generator 5.15.7
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(607, 369)
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
Dialog.setFont(font)
self.verticalLayout_2 = QtWidgets.QVBoxLayout(Dialog)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.widget = QtWidgets.QWidget(Dialog)
self.widget.setObjectName("widget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.widget)
self.verticalLayout.setObjectName("verticalLayout")
self.label = QtWidgets.QLabel(self.widget)
font = QtGui.QFont()
font.setPointSize(20)
self.label.setFont(font)
self.label.setObjectName("label")
self.verticalLayout.addWidget(self.label)
self.category_list_widget = QtWidgets.QListWidget(self.widget)
self.category_list_widget.setObjectName("category_list_widget")
self.verticalLayout.addWidget(self.category_list_widget)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.category_input = QtWidgets.QLineEdit(self.widget)
self.category_input.setObjectName("category_input")
self.horizontalLayout.addWidget(self.category_input)
self.color_button = QtWidgets.QToolButton(self.widget)
self.color_button.setStyleSheet("background-color: rgb(0, 255, 0);")
self.color_button.setText("")
self.color_button.setObjectName("color_button")
self.horizontalLayout.addWidget(self.color_button)
self.add_button = QtWidgets.QPushButton(self.widget)
self.add_button.setMinimumSize(QtCore.QSize(150, 0))
self.add_button.setSizeIncrement(QtCore.QSize(0, 0))
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/icons/icons/书签_bookmark-one.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.add_button.setIcon(icon)
self.add_button.setObjectName("add_button")
self.horizontalLayout.addWidget(self.add_button)
self.verticalLayout.addLayout(self.horizontalLayout)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.pushButton_import = QtWidgets.QPushButton(self.widget)
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(":/icons/icons/传入3_afferent-three.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.pushButton_import.setIcon(icon1)
self.pushButton_import.setObjectName("pushButton_import")
self.horizontalLayout_2.addWidget(self.pushButton_import)
self.pushButton_export = QtWidgets.QPushButton(self.widget)
icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(":/icons/icons/传出3_efferent-three.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.pushButton_export.setIcon(icon2)
self.pushButton_export.setObjectName("pushButton_export")
self.horizontalLayout_2.addWidget(self.pushButton_export)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem)
self.cache_button = QtWidgets.QPushButton(self.widget)
icon3 = QtGui.QIcon()
icon3.addPixmap(QtGui.QPixmap(":/icons/icons/关闭_close-one.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.cache_button.setIcon(icon3)
self.cache_button.setObjectName("cache_button")
self.horizontalLayout_2.addWidget(self.cache_button)
self.apply_button = QtWidgets.QPushButton(self.widget)
icon4 = QtGui.QIcon()
icon4.addPixmap(QtGui.QPixmap(":/icons/icons/校验_check-one.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.apply_button.setIcon(icon4)
self.apply_button.setObjectName("apply_button")
self.horizontalLayout_2.addWidget(self.apply_button)
self.verticalLayout.addLayout(self.horizontalLayout_2)
self.verticalLayout_2.addWidget(self.widget)
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Setting"))
self.label.setText(_translate("Dialog", "Label"))
self.add_button.setText(_translate("Dialog", "Add new label"))
self.pushButton_import.setText(_translate("Dialog", "Import"))
self.pushButton_export.setText(_translate("Dialog", "Export"))
self.cache_button.setText(_translate("Dialog", "Cache"))
self.apply_button.setText(_translate("Dialog", "Apply"))
import icons_rc

151
ui/setting_dialog.ui Normal file
View File

@ -0,0 +1,151 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>607</width>
<height>369</height>
</rect>
</property>
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="windowTitle">
<string>Setting</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>20</pointsize>
</font>
</property>
<property name="text">
<string>Label</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="category_list_widget"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="category_input"/>
</item>
<item>
<widget class="QToolButton" name="color_button">
<property name="styleSheet">
<string notr="true">background-color: rgb(0, 255, 0);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="add_button">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Add new label</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/icons/书签_bookmark-one.svg</normaloff>:/icons/icons/书签_bookmark-one.svg</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="pushButton_import">
<property name="text">
<string>Import</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/icons/传入3_afferent-three.svg</normaloff>:/icons/icons/传入3_afferent-three.svg</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_export">
<property name="text">
<string>Export</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/icons/传出3_efferent-three.svg</normaloff>:/icons/icons/传出3_efferent-three.svg</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="cache_button">
<property name="text">
<string>Cache</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/icons/关闭_close-one.svg</normaloff>:/icons/icons/关闭_close-one.svg</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="apply_button">
<property name="text">
<string>Apply</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/icons/校验_check-one.svg</normaloff>:/icons/icons/校验_check-one.svg</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../icons.qrc"/>
</resources>
<connections/>
</ui>

270
ui/shortcut_dialog.py Normal file
View File

@ -0,0 +1,270 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file '/home/super/PycharmProjects/ISAT_with_segment_anything/ui/shortcut_dialog.ui'
#
# Created by: PyQt5 UI code generator 5.15.7
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(600, 300)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(Dialog.sizePolicy().hasHeightForWidth())
Dialog.setSizePolicy(sizePolicy)
Dialog.setMinimumSize(QtCore.QSize(600, 300))
Dialog.setMaximumSize(QtCore.QSize(600, 300))
font = QtGui.QFont()
font.setKerning(True)
Dialog.setFont(font)
self.verticalLayout = QtWidgets.QVBoxLayout(Dialog)
self.verticalLayout.setObjectName("verticalLayout")
self.widget = QtWidgets.QWidget(Dialog)
self.widget.setMinimumSize(QtCore.QSize(0, 60))
self.widget.setMaximumSize(QtCore.QSize(16777215, 60))
self.widget.setObjectName("widget")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.widget)
self.horizontalLayout.setObjectName("horizontalLayout")
self.label = QtWidgets.QLabel(self.widget)
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(20)
font.setBold(False)
font.setItalic(False)
font.setWeight(50)
self.label.setFont(font)
self.label.setTextFormat(QtCore.Qt.AutoText)
self.label.setObjectName("label")
self.horizontalLayout.addWidget(self.label)
self.verticalLayout.addWidget(self.widget)
self.widget_2 = QtWidgets.QWidget(Dialog)
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(12)
self.widget_2.setFont(font)
self.widget_2.setObjectName("widget_2")
self.gridLayout = QtWidgets.QGridLayout(self.widget_2)
self.gridLayout.setObjectName("gridLayout")
self.label_20 = QtWidgets.QLabel(self.widget_2)
self.label_20.setMaximumSize(QtCore.QSize(80, 16777215))
font = QtGui.QFont()
font.setPointSize(12)
self.label_20.setFont(font)
self.label_20.setStyleSheet("color: rgb(133, 0, 0);")
self.label_20.setObjectName("label_20")
self.gridLayout.addWidget(self.label_20, 5, 3, 1, 1)
self.label_19 = QtWidgets.QLabel(self.widget_2)
self.label_19.setMaximumSize(QtCore.QSize(80, 16777215))
font = QtGui.QFont()
font.setPointSize(12)
self.label_19.setFont(font)
self.label_19.setStyleSheet("color: rgb(133, 0, 0);")
self.label_19.setObjectName("label_19")
self.gridLayout.addWidget(self.label_19, 4, 3, 1, 1)
self.label_17 = QtWidgets.QLabel(self.widget_2)
self.label_17.setMaximumSize(QtCore.QSize(80, 16777215))
font = QtGui.QFont()
font.setPointSize(12)
self.label_17.setFont(font)
self.label_17.setStyleSheet("color: rgb(133, 0, 0);")
self.label_17.setObjectName("label_17")
self.gridLayout.addWidget(self.label_17, 0, 3, 1, 1)
self.label_15 = QtWidgets.QLabel(self.widget_2)
self.label_15.setMaximumSize(QtCore.QSize(80, 16777215))
font = QtGui.QFont()
font.setPointSize(12)
self.label_15.setFont(font)
self.label_15.setStyleSheet("color: rgb(133, 0, 0);")
self.label_15.setObjectName("label_15")
self.gridLayout.addWidget(self.label_15, 5, 1, 1, 1)
self.label_7 = QtWidgets.QLabel(self.widget_2)
self.label_7.setMaximumSize(QtCore.QSize(80, 16777215))
font = QtGui.QFont()
font.setPointSize(12)
self.label_7.setFont(font)
self.label_7.setStyleSheet("color: rgb(133, 0, 0);")
self.label_7.setObjectName("label_7")
self.gridLayout.addWidget(self.label_7, 0, 1, 1, 1)
self.label_2 = QtWidgets.QLabel(self.widget_2)
font = QtGui.QFont()
font.setPointSize(12)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.gridLayout.addWidget(self.label_2, 0, 0, 1, 1)
self.label_10 = QtWidgets.QLabel(self.widget_2)
font = QtGui.QFont()
font.setPointSize(12)
self.label_10.setFont(font)
self.label_10.setObjectName("label_10")
self.gridLayout.addWidget(self.label_10, 4, 2, 1, 1)
self.label_18 = QtWidgets.QLabel(self.widget_2)
self.label_18.setMaximumSize(QtCore.QSize(80, 16777215))
font = QtGui.QFont()
font.setPointSize(12)
self.label_18.setFont(font)
self.label_18.setStyleSheet("color: rgb(133, 0, 0);")
self.label_18.setObjectName("label_18")
self.gridLayout.addWidget(self.label_18, 1, 3, 1, 1)
self.label_5 = QtWidgets.QLabel(self.widget_2)
font = QtGui.QFont()
font.setPointSize(12)
self.label_5.setFont(font)
self.label_5.setObjectName("label_5")
self.gridLayout.addWidget(self.label_5, 1, 2, 1, 1)
self.label_14 = QtWidgets.QLabel(self.widget_2)
font = QtGui.QFont()
font.setPointSize(12)
self.label_14.setFont(font)
self.label_14.setObjectName("label_14")
self.gridLayout.addWidget(self.label_14, 6, 0, 1, 1)
self.label_16 = QtWidgets.QLabel(self.widget_2)
self.label_16.setMaximumSize(QtCore.QSize(80, 16777215))
font = QtGui.QFont()
font.setPointSize(12)
self.label_16.setFont(font)
self.label_16.setStyleSheet("color: rgb(133, 0, 0);")
self.label_16.setObjectName("label_16")
self.gridLayout.addWidget(self.label_16, 6, 1, 1, 1)
self.label_11 = QtWidgets.QLabel(self.widget_2)
font = QtGui.QFont()
font.setPointSize(12)
self.label_11.setFont(font)
self.label_11.setObjectName("label_11")
self.gridLayout.addWidget(self.label_11, 6, 2, 1, 1)
self.label_21 = QtWidgets.QLabel(self.widget_2)
self.label_21.setMaximumSize(QtCore.QSize(80, 16777215))
font = QtGui.QFont()
font.setPointSize(12)
self.label_21.setFont(font)
self.label_21.setStyleSheet("color: rgb(133, 0, 0);")
self.label_21.setObjectName("label_21")
self.gridLayout.addWidget(self.label_21, 6, 3, 1, 1)
self.label_4 = QtWidgets.QLabel(self.widget_2)
font = QtGui.QFont()
font.setPointSize(12)
self.label_4.setFont(font)
self.label_4.setObjectName("label_4")
self.gridLayout.addWidget(self.label_4, 1, 0, 1, 1)
self.label_9 = QtWidgets.QLabel(self.widget_2)
font = QtGui.QFont()
font.setPointSize(12)
self.label_9.setFont(font)
self.label_9.setObjectName("label_9")
self.gridLayout.addWidget(self.label_9, 5, 2, 1, 1)
self.label_6 = QtWidgets.QLabel(self.widget_2)
font = QtGui.QFont()
font.setPointSize(12)
self.label_6.setFont(font)
self.label_6.setObjectName("label_6")
self.gridLayout.addWidget(self.label_6, 4, 0, 1, 1)
self.label_13 = QtWidgets.QLabel(self.widget_2)
self.label_13.setMaximumSize(QtCore.QSize(80, 16777215))
font = QtGui.QFont()
font.setPointSize(12)
self.label_13.setFont(font)
self.label_13.setStyleSheet("color: rgb(133, 0, 0);")
self.label_13.setObjectName("label_13")
self.gridLayout.addWidget(self.label_13, 4, 1, 1, 1)
self.label_12 = QtWidgets.QLabel(self.widget_2)
self.label_12.setMaximumSize(QtCore.QSize(80, 16777215))
font = QtGui.QFont()
font.setPointSize(12)
self.label_12.setFont(font)
self.label_12.setStyleSheet("color: rgb(133, 0, 0);")
self.label_12.setObjectName("label_12")
self.gridLayout.addWidget(self.label_12, 1, 1, 1, 1)
self.label_3 = QtWidgets.QLabel(self.widget_2)
font = QtGui.QFont()
font.setPointSize(12)
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.gridLayout.addWidget(self.label_3, 0, 2, 1, 1)
self.label_22 = QtWidgets.QLabel(self.widget_2)
font = QtGui.QFont()
font.setPointSize(12)
self.label_22.setFont(font)
self.label_22.setObjectName("label_22")
self.gridLayout.addWidget(self.label_22, 2, 0, 1, 1)
self.label_23 = QtWidgets.QLabel(self.widget_2)
font = QtGui.QFont()
font.setPointSize(12)
self.label_23.setFont(font)
self.label_23.setStyleSheet("color: rgb(133, 0, 0);")
self.label_23.setObjectName("label_23")
self.gridLayout.addWidget(self.label_23, 2, 1, 1, 1)
self.label_25 = QtWidgets.QLabel(self.widget_2)
font = QtGui.QFont()
font.setPointSize(12)
self.label_25.setFont(font)
self.label_25.setStyleSheet("color: rgb(133, 0, 0);")
self.label_25.setObjectName("label_25")
self.gridLayout.addWidget(self.label_25, 2, 3, 1, 1)
self.label_24 = QtWidgets.QLabel(self.widget_2)
font = QtGui.QFont()
font.setPointSize(12)
self.label_24.setFont(font)
self.label_24.setObjectName("label_24")
self.gridLayout.addWidget(self.label_24, 2, 2, 1, 1)
self.label_26 = QtWidgets.QLabel(self.widget_2)
font = QtGui.QFont()
font.setPointSize(12)
self.label_26.setFont(font)
self.label_26.setObjectName("label_26")
self.gridLayout.addWidget(self.label_26, 3, 0, 1, 1)
self.label_27 = QtWidgets.QLabel(self.widget_2)
font = QtGui.QFont()
font.setPointSize(12)
self.label_27.setFont(font)
self.label_27.setStyleSheet("color: rgb(133, 0, 0);")
self.label_27.setObjectName("label_27")
self.gridLayout.addWidget(self.label_27, 3, 1, 1, 1)
self.label_8 = QtWidgets.QLabel(self.widget_2)
font = QtGui.QFont()
font.setPointSize(12)
self.label_8.setFont(font)
self.label_8.setObjectName("label_8")
self.gridLayout.addWidget(self.label_8, 5, 0, 1, 1)
self.verticalLayout.addWidget(self.widget_2)
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "help"))
self.label.setText(_translate("Dialog", "Shortcut"))
self.label_20.setText(_translate("Dialog", "B"))
self.label_19.setText(_translate("Dialog", "S"))
self.label_17.setText(_translate("Dialog", "D"))
self.label_15.setText(_translate("Dialog", "T"))
self.label_7.setText(_translate("Dialog", "A"))
self.label_2.setText(_translate("Dialog", "Prior image"))
self.label_10.setText(_translate("Dialog", "Save annotation"))
self.label_18.setText(_translate("Dialog", "E"))
self.label_5.setText(_translate("Dialog", "Draw polygon"))
self.label_14.setText(_translate("Dialog", "Bit map"))
self.label_16.setText(_translate("Dialog", "Space"))
self.label_11.setText(_translate("Dialog", "Zoom fit"))
self.label_21.setText(_translate("Dialog", "F"))
self.label_4.setText(_translate("Dialog", "Segment anything"))
self.label_9.setText(_translate("Dialog", "To bottom"))
self.label_6.setText(_translate("Dialog", "Delete polygon"))
self.label_13.setText(_translate("Dialog", "Del"))
self.label_12.setText(_translate("Dialog", "Q"))
self.label_3.setText(_translate("Dialog", "Next image"))
self.label_22.setText(_translate("Dialog", "Backspace"))
self.label_23.setText(_translate("Dialog", "Z"))
self.label_25.setText(_translate("Dialog", "E"))
self.label_24.setText(_translate("Dialog", "Annotate finish"))
self.label_26.setText(_translate("Dialog", "Annotate cancel"))
self.label_27.setText(_translate("Dialog", "Esc"))
self.label_8.setText(_translate("Dialog", "To top"))
import icons_rc

506
ui/shortcut_dialog.ui Normal file
View File

@ -0,0 +1,506 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>300</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>600</width>
<height>300</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>300</height>
</size>
</property>
<property name="font">
<font>
<kerning>true</kerning>
</font>
</property>
<property name="windowTitle">
<string>help</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="widget" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>60</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>20</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Shortcut</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_2" native="true">
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>12</pointsize>
</font>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="5" column="3">
<widget class="QLabel" name="label_20">
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(133, 0, 0);</string>
</property>
<property name="text">
<string>B</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QLabel" name="label_19">
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(133, 0, 0);</string>
</property>
<property name="text">
<string>S</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_17">
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(133, 0, 0);</string>
</property>
<property name="text">
<string>D</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="label_15">
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(133, 0, 0);</string>
</property>
<property name="text">
<string>T</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_7">
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(133, 0, 0);</string>
</property>
<property name="text">
<string>A</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Prior image</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QLabel" name="label_10">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Save annotation</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="label_18">
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(133, 0, 0);</string>
</property>
<property name="text">
<string>E</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Draw polygon</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_14">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Bit map</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="label_16">
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(133, 0, 0);</string>
</property>
<property name="text">
<string>Space</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLabel" name="label_11">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Zoom fit</string>
</property>
</widget>
</item>
<item row="6" column="3">
<widget class="QLabel" name="label_21">
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(133, 0, 0);</string>
</property>
<property name="text">
<string>F</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Segment anything</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLabel" name="label_9">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>To bottom</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_6">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Delete polygon</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label_13">
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(133, 0, 0);</string>
</property>
<property name="text">
<string>Del</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_12">
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(133, 0, 0);</string>
</property>
<property name="text">
<string>Q</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Next image</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_22">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Backspace</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_23">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(133, 0, 0);</string>
</property>
<property name="text">
<string>Z</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="label_25">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(133, 0, 0);</string>
</property>
<property name="text">
<string>E</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_24">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Annotate finish</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_26">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Annotate cancel</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_27">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(133, 0, 0);</string>
</property>
<property name="text">
<string>Esc</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_8">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>To top</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../icons.qrc"/>
</resources>
<connections/>
</ui>

BIN
ui/zh_CN.qm Normal file

Binary file not shown.

904
ui/zh_CN.ts Normal file
View File

@ -0,0 +1,904 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN" sourcelanguage="en">
<context>
<name>Dialog</name>
<message>
<location filename="category_choice.py" line="119"/>
<source>category:</source>
<translation>:</translation>
</message>
<message>
<location filename="category_choice.py" line="120"/>
<source>group:</source>
<translation>:</translation>
</message>
<message>
<location filename="category_choice.py" line="121"/>
<source>group id</source>
<translation>id</translation>
</message>
<message>
<location filename="category_choice.py" line="122"/>
<source>note:</source>
<translation>:</translation>
</message>
<message>
<location filename="category_choice.py" line="123"/>
<source>add extra note here</source>
<translation></translation>
</message>
<message>
<location filename="category_choice.py" line="125"/>
<source>is crowded</source>
<translation></translation>
</message>
<message>
<location filename="category_choice.py" line="124"/>
<source>layer:</source>
<translation>:</translation>
</message>
<message>
<location filename="convert_dialog.py" line="115"/>
<source>cache</source>
<translation></translation>
</message>
<message>
<location filename="category_choice.py" line="127"/>
<source>apply</source>
<translation></translation>
</message>
<message>
<location filename="convert_dialog.py" line="106"/>
<source>ISAT to png converter</source>
<translation>ISAT标签文件转png</translation>
</message>
<message>
<location filename="convert_dialog.py" line="107"/>
<source>png save root</source>
<translation>png保存路径</translation>
</message>
<message>
<location filename="convert_dialog.py" line="108"/>
<source>Save root</source>
<translation></translation>
</message>
<message>
<location filename="convert_dialog.py" line="109"/>
<source>Is Instance</source>
<translation></translation>
</message>
<message>
<location filename="convert_dialog.py" line="110"/>
<source>ISAT annotations root</source>
<translation>ISAT标注文件路径</translation>
</message>
<message>
<location filename="convert_dialog.py" line="111"/>
<source>Label root</source>
<translation></translation>
</message>
<message>
<location filename="convert_dialog.py" line="112"/>
<source>aaa</source>
<translation></translation>
</message>
<message>
<location filename="convert_dialog.py" line="113"/>
<source>/</source>
<translation></translation>
</message>
<message>
<location filename="convert_dialog.py" line="114"/>
<source>Convert ISAT annotations to png.</source>
<translation>ISAT标注文件转换为png图片.</translation>
</message>
<message>
<location filename="convert_dialog.py" line="116"/>
<source>convert</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="242"/>
<source>help</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="487"/>
<source>ISAT</source>
<translation type="obsolete">ISAT </translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="488"/>
<source>Polygon</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="489"/>
<source>Move polygon to bottom</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="265"/>
<source>E</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="149"/>
<source>Create polygon</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="492"/>
<source>Move polygon to top</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="260"/>
<source>Del</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="245"/>
<source>S</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="250"/>
<source>Save annotation</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="247"/>
<source>T</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="259"/>
<source>Delete polygon</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="151"/>
<source>Edit polygon</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="244"/>
<source>B</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="501"/>
<source>File</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="262"/>
<source>Next image</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="246"/>
<source>D</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="504"/>
<source>Prev image</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="248"/>
<source>A</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="506"/>
<source>Open annotations dir</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="507"/>
<source>Open images dir</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="508"/>
<source>Open image</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="509"/>
<source>View</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="253"/>
<source>Bit map</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="254"/>
<source>Space</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="256"/>
<source>F</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="514"/>
<source>Zoom out</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="515"/>
<source>Fit window</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="517"/>
<source>Zoom in</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="518"/>
<source>Move image</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="519"/>
<source>Mouse(press left button) or ←↑→↓</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="setting_dialog.py" line="230"/>
<source>Display</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="setting_dialog.py" line="93"/>
<source>Label</source>
<translation></translation>
</message>
<message>
<location filename="setting_dialog.py" line="232"/>
<source>nohover size</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="setting_dialog.py" line="233"/>
<source>hover alpha</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="setting_dialog.py" line="234"/>
<source>Vertex</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="setting_dialog.py" line="231"/>
<source>hover size</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="setting_dialog.py" line="235"/>
<source>nohover alpha</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="setting_dialog.py" line="238"/>
<source>Add new category</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="setting_dialog.py" line="239"/>
<source>Add</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="setting_dialog.py" line="98"/>
<source>Apply</source>
<translation></translation>
</message>
<message>
<location filename="setting_dialog.py" line="97"/>
<source>Cache</source>
<translation></translation>
</message>
<message>
<location filename="setting_dialog.py" line="92"/>
<source>Setting</source>
<translation></translation>
</message>
<message>
<location filename="setting_dialog.py" line="95"/>
<source>Import</source>
<translation></translation>
</message>
<message>
<location filename="setting_dialog.py" line="96"/>
<source>Export</source>
<translation></translation>
</message>
<message>
<location filename="about_dialog.py" line="72"/>
<source>about</source>
<translation></translation>
</message>
<message>
<location filename="about_dialog.py" line="73"/>
<source>About</source>
<translation></translation>
</message>
<message>
<location filename="about_dialog.py" line="74"/>
<source>ISAT with Segment anything.</source>
<translation type="unfinished">ISAT集成Segment anything.</translation>
</message>
<message>
<location filename="about_dialog.py" line="75"/>
<source>ISAT Copyright (C) 2022 yatengLG.
http://www.yatenglg.cn/isat</source>
<translation></translation>
</message>
<message>
<location filename="setting_dialog.py" line="94"/>
<source>Add new label</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="243"/>
<source>Shortcut</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="249"/>
<source>Prior image</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="269"/>
<source>To top</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="258"/>
<source>To bottom</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="255"/>
<source>Zoom fit</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="252"/>
<source>Draw polygon</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="257"/>
<source>Segment anything</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="261"/>
<source>Q</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="263"/>
<source>Backspace</source>
<translation>退</translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="264"/>
<source>Z</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="266"/>
<source>Annotate finish</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="267"/>
<source>Annotate cancel</source>
<translation></translation>
</message>
<message>
<location filename="shortcut_dialog.py" line="268"/>
<source>Esc</source>
<translation></translation>
</message>
</context>
<context>
<name>Form</name>
<message>
<location filename="label_dock.py" line="31"/>
<source>Form</source>
<translation></translation>
</message>
<message>
<location filename="file_dock.py" line="54"/>
<source>/</source>
<translation></translation>
</message>
<message>
<location filename="info_dock.py" line="89"/>
<source>width :</source>
<translation>:</translation>
</message>
<message>
<location filename="info_dock.py" line="90"/>
<source>height:</source>
<translation>:</translation>
</message>
<message>
<location filename="info_dock.py" line="91"/>
<source>depth :</source>
<translation>:</translation>
</message>
<message>
<location filename="info_dock.py" line="92"/>
<source>note:</source>
<translation>:</translation>
</message>
<message>
<location filename="info_dock.py" line="93"/>
<source>add extra image note here</source>
<translation></translation>
</message>
<message>
<location filename="file_dock.py" line="52"/>
<source>Jump to the image. Input name or index.</source>
<translation>,.</translation>
</message>
<message>
<location filename="file_dock.py" line="53"/>
<source>Jump to the image.</source>
<translation>.</translation>
</message>
</context>
<context>
<name>MainWindow</name>
<message>
<location filename="MainWindow.py" line="317"/>
<source>ISAT</source>
<translation>ISAT </translation>
</message>
<message>
<location filename="MainWindow.py" line="318"/>
<source>File</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="319"/>
<source>View</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="320"/>
<source>Help</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="322"/>
<source>Tools</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="369"/>
<source>Edit</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="324"/>
<source>toolBar</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="325"/>
<source>Info</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="326"/>
<source>Labels</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="327"/>
<source>Files</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="261"/>
<source>Open image</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="MainWindow.py" line="262"/>
<source>Open images dir</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="MainWindow.py" line="330"/>
<source>Zoom in</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="332"/>
<source>Zoom out</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="335"/>
<source>Fit window</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="337"/>
<source>F</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="338"/>
<source>Setting</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="341"/>
<source>Exit</source>
<translation>退</translation>
</message>
<message>
<location filename="MainWindow.py" line="271"/>
<source>Open annotations dir</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="MainWindow.py" line="345"/>
<source>Save</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="347"/>
<source>S</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="274"/>
<source>Prev</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="MainWindow.py" line="349"/>
<source>Prev image</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="351"/>
<source>A</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="277"/>
<source>Next</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="MainWindow.py" line="353"/>
<source>Next image</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="355"/>
<source>D</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="357"/>
<source>About</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="327"/>
<source>Create</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="MainWindow.py" line="328"/>
<source>Create polygon</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="MainWindow.py" line="399"/>
<source>C</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="362"/>
<source>Delete</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="363"/>
<source>Delete polygon</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="365"/>
<source>Del</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="366"/>
<source>Bit map</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="368"/>
<source>Space</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="370"/>
<source>Edit polygon</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="395"/>
<source>E</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="372"/>
<source>To top</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="373"/>
<source>Move polygon to top layer</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="375"/>
<source>T</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="376"/>
<source>To bottom</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="377"/>
<source>Move polygon to bottom layer</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="379"/>
<source>B</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="380"/>
<source>Label converter</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="381"/>
<source>Convert annotations to png image.</source>
<translation>ISAT标注文件转换为png图片.</translation>
</message>
<message>
<location filename="MainWindow.py" line="321"/>
<source>Laguage</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="356"/>
<source>Shortcut</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="314"/>
<source>Chinese</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="MainWindow.py" line="383"/>
<source>English</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="382"/>
<source></source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="328"/>
<source>Images dir</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="329"/>
<source>Open images dir.</source>
<translation>.</translation>
</message>
<message>
<location filename="MainWindow.py" line="331"/>
<source>Zoom in.</source>
<translation>.</translation>
</message>
<message>
<location filename="MainWindow.py" line="333"/>
<source>Zoom out.</source>
<translation>.</translation>
</message>
<message>
<location filename="MainWindow.py" line="336"/>
<source>Fit window.</source>
<translation>.</translation>
</message>
<message>
<location filename="MainWindow.py" line="343"/>
<source>Label dir</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="344"/>
<source>Open label dir.</source>
<translation>.</translation>
</message>
<message>
<location filename="MainWindow.py" line="346"/>
<source>Save annotation.</source>
<translation>.</translation>
</message>
<message>
<location filename="MainWindow.py" line="317"/>
<source>Priro image</source>
<translation type="obsolete"></translation>
</message>
<message>
<location filename="MainWindow.py" line="319"/>
<source>Prior image.</source>
<translation type="obsolete">.</translation>
</message>
<message>
<location filename="MainWindow.py" line="354"/>
<source>Next image.</source>
<translation>.</translation>
</message>
<message>
<location filename="MainWindow.py" line="329"/>
<source>Draw polygon.</source>
<translation type="obsolete">.</translation>
</message>
<message>
<location filename="MainWindow.py" line="364"/>
<source>Delete polygon.</source>
<translation>.</translation>
</message>
<message>
<location filename="MainWindow.py" line="367"/>
<source>Show instance or segmeent state.</source>
<translation>.</translation>
</message>
<message>
<location filename="MainWindow.py" line="371"/>
<source>Edit polygon attribute.</source>
<translation>.</translation>
</message>
<message>
<location filename="MainWindow.py" line="374"/>
<source>Move polygon to top layer.</source>
<translation>.</translation>
</message>
<message>
<location filename="MainWindow.py" line="378"/>
<source>Move polygon to bottom layer.</source>
<translation>.</translation>
</message>
<message>
<location filename="MainWindow.py" line="339"/>
<source>Setting.</source>
<translation>.</translation>
</message>
<message>
<location filename="MainWindow.py" line="342"/>
<source>Exit.</source>
<translation>退.</translation>
</message>
<message>
<location filename="MainWindow.py" line="350"/>
<source>Prev image.</source>
<translation>.</translation>
</message>
<message>
<location filename="MainWindow.py" line="359"/>
<source>Segment anything</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="360"/>
<source>Quick annotate using Segment anything.</source>
<translation>使Segment anything进行快速标注.</translation>
</message>
<message>
<location filename="MainWindow.py" line="361"/>
<source>Q</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="385"/>
<source>Backspace</source>
<translation>退</translation>
</message>
<message>
<location filename="MainWindow.py" line="386"/>
<source>Backspace.</source>
<translation>退.</translation>
</message>
<message>
<location filename="MainWindow.py" line="387"/>
<source>Z</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="388"/>
<source>Cancel</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="389"/>
<source>Annotate canceled</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="390"/>
<source>Annotate canceled.</source>
<translation>.</translation>
</message>
<message>
<location filename="MainWindow.py" line="391"/>
<source>Esc</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="392"/>
<source>Finish</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="393"/>
<source>Annotate finished</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="394"/>
<source>Annotate finished.</source>
<translation>.</translation>
</message>
<message>
<location filename="MainWindow.py" line="396"/>
<source>Polygon</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="397"/>
<source>Draw polygon</source>
<translation></translation>
</message>
<message>
<location filename="MainWindow.py" line="398"/>
<source>Accurately annotate by drawing polygon. </source>
<translation>,. </translation>
</message>
</context>
</TS>

11
widgets/about_dialog.py Normal file
View File

@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# @Author : LG
from PyQt5 import QtWidgets, QtCore, QtGui
from ui.about_dialog import Ui_Dialog
class AboutDialog(QtWidgets.QDialog, Ui_Dialog):
def __init__(self, parent):
super(AboutDialog, self).__init__(parent)
self.setupUi(self)
self.setWindowModality(QtCore.Qt.WindowModality.WindowModal)

432
widgets/canvas.py Normal file
View File

@ -0,0 +1,432 @@
# -*- coding: utf-8 -*-
# @Author : LG
from PyQt5 import QtWidgets, QtGui, QtCore
from enum import Enum
from widgets.polygon import Polygon
from configs import STATUSMode, CLICKMode, DRAWMode
from PIL import Image
import numpy as np
import cv2
class AnnotationScene(QtWidgets.QGraphicsScene):
def __init__(self, mainwindow):
super(AnnotationScene, self).__init__()
self.mainwindow = mainwindow
self.image_item:QtWidgets.QGraphicsPixmapItem = None
self.image_data = None
self.current_graph:Polygon = None
self.mode = STATUSMode.VIEW
self.click = CLICKMode.POSITIVE
self.draw_mode = DRAWMode.SEGMENTANYTHING # 默认使用segment anything进行快速标注
self.click_points = []
self.click_points_mode = []
self.masks:np.ndarray = None
self.top_layer = 1
self.guide_line_x:QtWidgets.QGraphicsLineItem = None
self.guide_line_y:QtWidgets.QGraphicsLineItem = None
def load_image(self, image_path:str):
self.clear()
self.image_data = np.array(Image.open(image_path))
if self.mainwindow.use_segment_anything:
self.mainwindow.segany.reset_image()
if self.image_data.ndim == 3 and self.image_data.shape[-1] == 3:
self.mainwindow.segany.set_image(self.image_data)
elif self.image_data.ndim == 2 and image_path.endswith('.png'):
# 单通道图标签图
pass
else:
QtWidgets.QMessageBox.warning(self.mainwindow, 'Warning', 'Segment anything only support 3 channel rgb image.')
self.image_item = QtWidgets.QGraphicsPixmapItem()
self.image_item.setZValue(0)
self.addItem(self.image_item)
self.mask_item = QtWidgets.QGraphicsPixmapItem()
self.mask_item.setZValue(1)
self.addItem(self.mask_item)
self.image_item.setPixmap(QtGui.QPixmap(image_path))
self.setSceneRect(self.image_item.boundingRect())
self.change_mode_to_view()
def change_mode_to_create(self):
if self.image_item is None:
return
self.mode = STATUSMode.CREATE
self.image_item.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.CrossCursor))
self.mainwindow.actionPrev.setEnabled(False)
self.mainwindow.actionNext.setEnabled(False)
self.mainwindow.actionSegment_anything.setEnabled(False)
self.mainwindow.actionPolygon.setEnabled(False)
self.mainwindow.actionBackspace.setEnabled(True)
self.mainwindow.actionFinish.setEnabled(True)
self.mainwindow.actionCancel.setEnabled(True)
self.mainwindow.actionTo_top.setEnabled(False)
self.mainwindow.actionTo_bottom.setEnabled(False)
self.mainwindow.actionEdit.setEnabled(False)
self.mainwindow.actionDelete.setEnabled(False)
self.mainwindow.actionSave.setEnabled(False)
def change_mode_to_view(self):
self.mode = STATUSMode.VIEW
self.image_item.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.ArrowCursor))
self.mainwindow.actionPrev.setEnabled(True)
self.mainwindow.actionNext.setEnabled(True)
self.mainwindow.actionSegment_anything.setEnabled(self.mainwindow.use_segment_anything)
self.mainwindow.actionPolygon.setEnabled(True)
self.mainwindow.actionBackspace.setEnabled(False)
self.mainwindow.actionFinish.setEnabled(False)
self.mainwindow.actionCancel.setEnabled(False)
self.mainwindow.actionTo_top.setEnabled(False)
self.mainwindow.actionTo_bottom.setEnabled(False)
self.mainwindow.actionEdit.setEnabled(False)
self.mainwindow.actionDelete.setEnabled(False)
self.mainwindow.actionSave.setEnabled(True)
def change_mode_to_edit(self):
self.mode = STATUSMode.EDIT
self.image_item.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.CrossCursor))
self.mainwindow.actionPrev.setEnabled(False)
self.mainwindow.actionNext.setEnabled(False)
self.mainwindow.actionSegment_anything.setEnabled(False)
self.mainwindow.actionPolygon.setEnabled(False)
self.mainwindow.actionBackspace.setEnabled(False)
self.mainwindow.actionFinish.setEnabled(False)
self.mainwindow.actionCancel.setEnabled(False)
self.mainwindow.actionTo_top.setEnabled(True)
self.mainwindow.actionTo_bottom.setEnabled(True)
self.mainwindow.actionEdit.setEnabled(True)
self.mainwindow.actionDelete.setEnabled(True)
self.mainwindow.actionSave.setEnabled(True)
def change_click_to_positive(self):
self.click = CLICKMode.POSITIVE
def change_click_to_negative(self):
self.click = CLICKMode.NEGATIVE
def start_segment_anything(self):
self.draw_mode = DRAWMode.SEGMENTANYTHING
self.start_draw()
def start_draw_polygon(self):
self.draw_mode = DRAWMode.POLYGON
self.start_draw()
def start_draw(self):
# 只有view模式时才能切换create模式
if self.mode != STATUSMode.VIEW:
return
# 否则,切换到绘图模式
self.change_mode_to_create()
# 绘图模式
if self.mode == STATUSMode.CREATE:
self.current_graph = Polygon()
self.addItem(self.current_graph)
def finish_draw(self):
if self.current_graph is None:
return
self.change_mode_to_view()
if self.draw_mode == DRAWMode.SEGMENTANYTHING:
# mask to polygon
# --------------
if self.masks is not None:
masks = self.masks
masks = masks.astype('uint8') * 255
h, w = masks.shape[-2:]
masks = masks.reshape(h, w)
contours, _ = cv2.findContours(masks, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_TC89_KCOS)
# 这里取轮廓点数最多的(可能返回多个轮廓)
contour = contours[0]
for cont in contours:
if len(cont) > len(contour):
contour = cont
for point in contour:
x, y = point[0]
self.current_graph.addPoint(QtCore.QPointF(x, y))
elif self.draw_mode == DRAWMode.POLYGON:
if len(self.current_graph.points) < 1:
return
# 移除鼠标移动点
# self.current_graph.removePoint(len(self.current_graph.points) - 1)
# 单点,删除
if len(self.current_graph.points) < 2:
self.current_graph.delete()
self.removeItem(self.current_graph)
self.change_mode_to_view()
return
# 两点,默认矩形
if len(self.current_graph.points) == 2:
first_point = self.current_graph.points[0]
last_point = self.current_graph.points[-1]
self.current_graph.removePoint(len(self.current_graph.points) - 1)
self.current_graph.addPoint(QtCore.QPointF(first_point.x(), last_point.y()))
self.current_graph.addPoint(last_point)
self.current_graph.addPoint(QtCore.QPointF(last_point.x(), first_point.y()))
# 选择类别
self.mainwindow.category_choice_widget.load_cfg()
self.mainwindow.category_choice_widget.show()
# mask清空
self.click_points.clear()
self.click_points_mode.clear()
self.update_mask()
def cancel_draw(self):
if self.current_graph is None:
return
self.current_graph.delete() # 清除所有路径
self.removeItem(self.current_graph)
self.current_graph = None
self.change_mode_to_view()
self.click_points.clear()
self.click_points_mode.clear()
self.update_mask()
def delete_selected_graph(self):
deleted_layer = None
for item in self.selectedItems():
if item in self.mainwindow.polygons:
self.mainwindow.polygons.remove(item)
item.delete()
self.removeItem(item)
deleted_layer = item.zValue()
del item
if deleted_layer is not None:
for p in self.mainwindow.polygons:
if p.zValue() > deleted_layer:
p.setZValue(p.zValue() - 1)
self.mainwindow.labels_dock_widget.update_listwidget()
def edit_polygon(self):
selectd_items = self.selectedItems()
if len(selectd_items) < 1:
return
item = selectd_items[0]
if not item:
return
self.mainwindow.category_edit_widget.polygon = item
self.mainwindow.category_edit_widget.load_cfg()
self.mainwindow.category_edit_widget.show()
def move_polygon_to_top(self):
selectd_items = self.selectedItems()
if len(selectd_items) < 1:
return
current_polygon = selectd_items[0]
max_layer = len(self.mainwindow.polygons)
current_layer = current_polygon.zValue()
for p in self.mainwindow.polygons:
if p.zValue() > current_layer:
p.setZValue(p.zValue() - 1)
current_polygon.setZValue(max_layer)
for vertex in current_polygon.vertexs:
vertex.setZValue(max_layer)
self.mainwindow.set_saved_state(False)
def move_polygon_to_bottom(self):
selectd_items = self.selectedItems()
if len(selectd_items) < 1:
return
current_polygon = selectd_items[0]
if current_polygon is not None:
current_layer = current_polygon.zValue()
for p in self.mainwindow.polygons:
if p.zValue() < current_layer:
p.setZValue(p.zValue() + 1)
current_polygon.setZValue(1)
for vertex in current_polygon.vertexs:
vertex.setZValue(1)
self.mainwindow.set_saved_state(False)
def mousePressEvent(self, event: 'QtWidgets.QGraphicsSceneMouseEvent'):
if self.mode == STATUSMode.CREATE:
sceneX, sceneY = event.scenePos().x(), event.scenePos().y()
sceneX = 0 if sceneX < 0 else sceneX
sceneX = self.width() if sceneX > self.width() else sceneX
sceneY = 0 if sceneY < 0 else sceneY
sceneY = self.height() if sceneY > self.height() else sceneY
if event.button() == QtCore.Qt.MouseButton.LeftButton:
if self.draw_mode == DRAWMode.SEGMENTANYTHING:
self.click_points.append([sceneX, sceneY])
self.click_points_mode.append(1)
elif self.draw_mode == DRAWMode.POLYGON:
# 移除随鼠标移动的点
self.current_graph.removePoint(len(self.current_graph.points) - 1)
# 添加当前点
self.current_graph.addPoint(QtCore.QPointF(sceneX, sceneY))
# 添加随鼠标移动的点
self.current_graph.addPoint(QtCore.QPointF(sceneX, sceneY))
else:
raise ValueError('The draw mode named {} not supported.')
if event.button() == QtCore.Qt.MouseButton.RightButton:
if self.draw_mode == DRAWMode.SEGMENTANYTHING:
self.click_points.append([sceneX, sceneY])
self.click_points_mode.append(0)
elif self.draw_mode == DRAWMode.POLYGON:
pass
else:
raise ValueError('The draw mode named {} not supported.')
if self.draw_mode == DRAWMode.SEGMENTANYTHING:
self.update_mask()
super(AnnotationScene, self).mousePressEvent(event)
def mouseMoveEvent(self, event: 'QtWidgets.QGraphicsSceneMouseEvent'):
# 辅助线
if self.guide_line_x is not None and self.guide_line_y is not None:
if self.guide_line_x in self.items():
self.removeItem(self.guide_line_x)
if self.guide_line_y in self.items():
self.removeItem(self.guide_line_y)
self.guide_line_x = None
self.guide_line_y = None
pos = event.scenePos()
if pos.x() < 0: pos.setX(0)
if pos.x() > self.width(): pos.setX(self.width())
if pos.y() < 0: pos.setY(0)
if pos.y() > self.height(): pos.setY(self.height())
# 限制在图片范围内
if self.mode == STATUSMode.CREATE:
if self.draw_mode == DRAWMode.POLYGON:
# 随鼠标位置实时更新多边形
self.current_graph.movePoint(len(self.current_graph.points)-1, pos)
# 辅助线
if self.guide_line_x is None and self.width()>0 and self.height()>0:
self.guide_line_x = QtWidgets.QGraphicsLineItem(QtCore.QLineF(pos.x(), 0, pos.x(), self.height()))
self.guide_line_x.setZValue(1)
self.addItem(self.guide_line_x)
if self.guide_line_y is None and self.width()>0 and self.height()>0:
self.guide_line_y = QtWidgets.QGraphicsLineItem(QtCore.QLineF(0, pos.y(), self.width(), pos.y()))
self.guide_line_y.setZValue(1)
self.addItem(self.guide_line_y)
# 状态栏,显示当前坐标
if self.image_data is not None:
x, y = round(pos.x()), round(pos.y())
self.mainwindow.labelCoordinates.setText('({}, {}) [{}]'.format(x, y, self.image_data[y-1][x-1]))
super(AnnotationScene, self).mouseMoveEvent(event)
def update_mask(self):
if not self.mainwindow.use_segment_anything:
return
if not (self.image_data.ndim == 3 and self.image_data.shape[-1] == 3):
return
if len(self.click_points) > 0 and len(self.click_points_mode) > 0:
masks = self.mainwindow.segany.predict(self.click_points, self.click_points_mode)
self.masks = masks
color = np.array([0, 0, 255])
h, w = masks.shape[-2:]
mask_image = masks.reshape(h, w, 1) * color.reshape(1, 1, -1)
mask_image = mask_image.astype("uint8")
mask_image = cv2.cvtColor(mask_image, cv2.COLOR_BGR2RGB)
mask_image = cv2.addWeighted(self.image_data, 0.5, mask_image, 0.9, 0)
mask_image = QtGui.QImage(mask_image[:], mask_image.shape[1], mask_image.shape[0], mask_image.shape[1] * 3,
QtGui.QImage.Format_RGB888)
mask_pixmap = QtGui.QPixmap(mask_image)
self.mask_item.setPixmap(mask_pixmap)
else:
mask_image = np.zeros(self.image_data.shape, dtype=np.uint8)
mask_image = cv2.addWeighted(self.image_data, 1, mask_image, 0, 0)
mask_image = QtGui.QImage(mask_image[:], mask_image.shape[1], mask_image.shape[0], mask_image.shape[1] * 3,
QtGui.QImage.Format_RGB888)
mask_pixmap = QtGui.QPixmap(mask_image)
self.mask_item.setPixmap(mask_pixmap)
def backspace(self):
if self.mode != STATUSMode.CREATE:
return
# 返回上一步操作
if self.draw_mode == DRAWMode.SEGMENTANYTHING:
if len(self.click_points) > 0:
self.click_points.pop()
if len(self.click_points_mode) > 0:
self.click_points_mode.pop()
self.update_mask()
elif self.draw_mode == DRAWMode.POLYGON:
if len(self.current_graph.points) < 2:
return
# 移除随鼠标移动的点
self.current_graph.removePoint(len(self.current_graph.points) - 2)
class AnnotationView(QtWidgets.QGraphicsView):
def __init__(self, parent=None):
super(AnnotationView, self).__init__(parent)
self.setMouseTracking(True)
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
self.setDragMode(QtWidgets.QGraphicsView.DragMode.ScrollHandDrag)
self.factor = 1.2
def wheelEvent(self, event: QtGui.QWheelEvent):
angel = event.angleDelta()
angelX, angelY = angel.x(), angel.y()
point = event.pos() # 当前鼠标位置
if angelY > 0:
self.zoom(self.factor, point)
else:
self.zoom(1 / self.factor, point)
def zoom_in(self):
self.zoom(self.factor)
def zoom_out(self):
self.zoom(1/self.factor)
def zoomfit(self):
self.fitInView(0, 0, self.scene().width(), self.scene().height(), QtCore.Qt.AspectRatioMode.KeepAspectRatio)
def zoom(self, factor, point=None):
mouse_old = self.mapToScene(point) if point is not None else None
# 缩放比例
pix_widget = self.transform().scale(factor, factor).mapRect(QtCore.QRectF(0, 0, 1, 1)).width()
if pix_widget > 3 or pix_widget < 0.01:
return
self.scale(factor, factor)
if point is not None:
mouse_now = self.mapToScene(point)
center_now = self.mapToScene(self.viewport().width() // 2, self.viewport().height() // 2)
center_new = mouse_old - mouse_now + center_now
self.centerOn(center_new)

View File

@ -0,0 +1,105 @@
# -*- coding: utf-8 -*-
# @Author : LG
from ui.category_choice import Ui_Dialog
from PyQt5 import QtWidgets, QtGui, QtCore
from configs import load_config, CONFIG_FILE, DEFAULT_CONFIG_FILE
import os
class CategoryChoiceDialog(QtWidgets.QDialog, Ui_Dialog):
def __init__(self, parent, mainwindow, scene):
super(CategoryChoiceDialog, self).__init__(parent)
self.setupUi(self)
self.mainwindow = mainwindow
self.scene = scene
self.lineEdit_group.setValidator(QtGui.QIntValidator(0, 1000))
self.listWidget.itemClicked.connect(self.get_category)
self.pushButton_apply.clicked.connect(self.apply)
self.pushButton_cache.clicked.connect(self.cache)
self.setWindowModality(QtCore.Qt.WindowModality.WindowModal)
def load_cfg(self):
self.listWidget.clear()
labels = self.mainwindow.cfg.get('label', [])
for label in labels:
name = label.get('name', 'UNKNOW')
color = label.get('color', '#000000')
item = QtWidgets.QListWidgetItem()
item.setSizeHint(QtCore.QSize(200, 30))
widget = QtWidgets.QWidget()
layout = QtWidgets.QHBoxLayout()
layout.setContentsMargins(9, 1, 9, 1)
label_category = QtWidgets.QLabel()
label_category.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
label_category.setText(name)
label_category.setObjectName('label_category')
label_color = QtWidgets.QLabel()
label_color.setFixedWidth(10)
label_color.setStyleSheet("background-color: {};".format(color))
label_color.setObjectName('label_color')
layout.addWidget(label_color)
layout.addWidget(label_category)
widget.setLayout(layout)
self.listWidget.addItem(item)
self.listWidget.setItemWidget(item, widget)
self.lineEdit_group.clear()
self.lineEdit_category.clear()
self.checkBox_iscrowded.setCheckState(False)
self.label_layer.setText('{}'.format(len(self.mainwindow.polygons)+1))
if self.listWidget.count() == 0:
QtWidgets.QMessageBox.warning(self, 'Warning', 'Please set categorys before tagging.')
def get_category(self, item):
widget = self.listWidget.itemWidget(item)
label_category = widget.findChild(QtWidgets.QLabel, 'label_category')
self.lineEdit_category.setText(label_category.text())
self.lineEdit_category.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
def apply(self):
category = self.lineEdit_category.text()
group = self.lineEdit_group.text()
is_crowd = int(self.checkBox_iscrowded.isChecked())
note = self.lineEdit_note.text()
if not category:
QtWidgets.QMessageBox.warning(self, 'Warning', 'Please select one category before submitting.')
return
# 设置polygon 属性
self.scene.current_graph.set_drawed(category, group, is_crowd, note,
QtGui.QColor(self.mainwindow.category_color_dict[category]), self.scene.top_layer)
# 添加新polygon
self.mainwindow.polygons.append(self.scene.current_graph)
# 设置为最高图层
self.scene.current_graph.setZValue(len(self.mainwindow.polygons))
for vertex in self.scene.current_graph.vertexs:
vertex.setZValue(len(self.mainwindow.polygons))
self.mainwindow.labels_dock_widget.update_listwidget()
self.scene.current_graph = None
self.scene.change_mode_to_view()
self.close()
def cache(self):
self.scene.cancel_draw()
self.close()
def closeEvent(self, a0: QtGui.QCloseEvent):
self.cache()
def reject(self):
self.cache()

View File

@ -0,0 +1,116 @@
# -*- coding: utf-8 -*-
# @Author : LG
from ui.category_choice import Ui_Dialog
from PyQt5 import QtWidgets, QtGui, QtCore
from configs import load_config, CONFIG_FILE, DEFAULT_CONFIG_FILE
import os
class CategoryEditDialog(QtWidgets.QDialog, Ui_Dialog):
def __init__(self, parent, mainwindow, scene):
super(CategoryEditDialog, self).__init__(parent)
self.setupUi(self)
self.mainwindow = mainwindow
self.scene = scene
self.polygon = None
self.lineEdit_group.setValidator(QtGui.QIntValidator(0,1000))
self.listWidget.itemClicked.connect(self.get_category)
self.pushButton_apply.clicked.connect(self.apply)
self.pushButton_cache.clicked.connect(self.cache)
self.setWindowModality(QtCore.Qt.WindowModality.WindowModal)
def load_cfg(self):
self.listWidget.clear()
labels = self.mainwindow.cfg.get('label', [])
for label in labels:
name = label.get('name', 'UNKNOW')
color = label.get('color', '#000000')
# item = QtWidgets.QListWidgetItem()
# item.setText(name)
# item.setTextAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
# self.listWidget.addItem(item)
item = QtWidgets.QListWidgetItem()
item.setSizeHint(QtCore.QSize(200, 30))
widget = QtWidgets.QWidget()
layout = QtWidgets.QHBoxLayout()
layout.setContentsMargins(9, 1, 9, 1)
label_category = QtWidgets.QLabel()
label_category.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
label_category.setText(name)
label_category.setObjectName('label_category')
label_color = QtWidgets.QLabel()
label_color.setFixedWidth(10)
label_color.setStyleSheet("background-color: {};".format(color))
label_color.setObjectName('label_color')
layout.addWidget(label_color)
layout.addWidget(label_category)
widget.setLayout(layout)
self.listWidget.addItem(item)
self.listWidget.setItemWidget(item, widget)
if self.polygon is not None and self.polygon.category == name:
self.listWidget.setCurrentItem(item)
if self.polygon is None:
self.lineEdit_group.clear()
self.lineEdit_category.clear()
self.checkBox_iscrowded.setCheckState(False)
self.lineEdit_note.clear()
self.label_layer.setText('{}'.format(''))
else:
self.lineEdit_category.setText('{}'.format(self.polygon.category))
self.lineEdit_category.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.lineEdit_group.setText('{}'.format(self.polygon.group))
iscrowd = QtCore.Qt.CheckState.Checked if self.polygon.iscrowd == 1 else QtCore.Qt.CheckState.Unchecked
self.checkBox_iscrowded.setCheckState(iscrowd)
self.lineEdit_note.setText('{}'.format(self.polygon.note))
self.label_layer.setText('{}'.format(self.polygon.zValue()))
if self.listWidget.count() == 0:
QtWidgets.QMessageBox.warning(self, 'Warning', 'Please set categorys before tagging.')
def get_category(self, item):
widget = self.listWidget.itemWidget(item)
label_category = widget.findChild(QtWidgets.QLabel, 'label_category')
self.lineEdit_category.setText(label_category.text())
self.lineEdit_category.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
def apply(self):
category = self.lineEdit_category.text()
group = self.lineEdit_group.text()
is_crowd = int(self.checkBox_iscrowded.isChecked())
note = self.lineEdit_note.text()
if not category:
QtWidgets.QMessageBox.warning(self, 'Warning', 'Please select one category before submitting.')
return
# 设置polygon 属性
self.polygon.set_drawed(category, group, is_crowd, note,
QtGui.QColor(self.mainwindow.category_color_dict.get(category, '#000000')))
self.mainwindow.labels_dock_widget.update_listwidget()
self.polygon = None
self.scene.change_mode_to_view()
self.close()
def cache(self):
self.scene.cancel_draw()
self.close()
def closeEvent(self, a0: QtGui.QCloseEvent):
self.cache()
def reject(self):
self.cache()

86
widgets/converter.py Normal file
View File

@ -0,0 +1,86 @@
# -*- coding: utf-8 -*-
# @Author : LG
from PyQt5 import QtWidgets, QtCore, QtGui
from ui.convert_dialog import Ui_Dialog
from tools.label_convert import Converter
import os
class ConvertDialog(QtWidgets.QDialog, Ui_Dialog):
def __init__(self, parent, mainwindow):
super(ConvertDialog, self).__init__(parent)
self.setupUi(self)
self.mainwindow = mainwindow
self.label_root = None
self.save_root = None
self.pause = False
self.setWindowModality(QtCore.Qt.WindowModality.WindowModal)
self.init_connect()
def reset_gui(self):
self.widget_process.setVisible(False)
self.lineEdit_label_root.clear()
self.lineEdit_save_root.clear()
def _label_root(self):
dir = QtWidgets.QFileDialog.getExistingDirectory(self)
if dir:
self.label_root = dir
self.lineEdit_label_root.setText(dir)
else:
self.lineEdit_label_root.clear()
def _save_root(self):
dir = QtWidgets.QFileDialog.getExistingDirectory(self)
if dir:
self.save_root = dir
self.lineEdit_save_root.setText(dir)
else:
self.lineEdit_save_root.clear()
def cache(self):
self.pause = True
self.close()
def apply(self):
self.pause = False
if self.label_root is None or self.save_root is None:
return
# 语义分割,保存类别文件
if not self.checkBox_is_instance.isChecked():
with open(os.path.join(self.save_root, 'classesition.txt'), 'w') as f:
for index, label in enumerate(self.mainwindow.cfg.get('label', [])):
f.write('{} {}\n'.format(label.get('name'), index))
converter = Converter(self.mainwindow.cfg, self.checkBox_is_instance.isChecked())
jsons = [f for f in os.listdir(self.label_root) if f.endswith('.json')]
self.pushButton_label_root.setEnabled(False)
self.pushButton_save_root.setEnabled(False)
self.checkBox_is_instance.setEnabled(False)
self.widget_process.setVisible(True)
self.progressBar.setMaximum(len(jsons))
self.all_num.setText('{}'.format(len(jsons)))
for index, json in enumerate(jsons):
if self.pause:
break
label_path = os.path.join(self.label_root, json)
save_path = os.path.join(self.save_root, json[:-5]+'.png')
converter.convert(label_path, save_path)
self.progressBar.setValue(index+1)
self.current_num.setText('{}'.format(index+1))
self.pushButton_label_root.setEnabled(True)
self.pushButton_save_root.setEnabled(True)
self.checkBox_is_instance.setEnabled(True)
def init_connect(self):
self.pushButton_label_root.clicked.connect(self._label_root)
self.pushButton_save_root.clicked.connect(self._save_root)
self.pushButton_apply.clicked.connect(self.apply)
self.pushButton_cache.clicked.connect(self.cache)

View File

@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
# @Author : LG
from PyQt5 import QtWidgets, QtCore, QtGui
from ui.file_dock import Ui_Form
import os
class FilesDockWidget(QtWidgets.QWidget, Ui_Form):
def __init__(self, mainwindow):
super(FilesDockWidget, self).__init__()
self.setupUi(self)
self.mainwindow = mainwindow
self.listWidget.clicked.connect(self.listwidget_doubleclick)
self.lineEdit_jump.returnPressed.connect(self.mainwindow.jump_to)
def update_widget(self):
self.listWidget.clear()
if self.mainwindow.files_list is None:
return
for file_path in self.mainwindow.files_list:
_, file_name = os.path.split(file_path)
item = QtWidgets.QListWidgetItem()
item.setSizeHint(QtCore.QSize(200, 30))
item.setText(file_name)
self.listWidget.addItem(item)
self.label_all.setText('{}'.format(len(self.mainwindow.files_list)))
def set_select(self, row):
self.listWidget.setCurrentRow(row)
def listwidget_doubleclick(self):
row = self.listWidget.currentRow()
self.mainwindow.show_image(row)

View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# @Author : LG
from PyQt5 import QtWidgets, QtCore, QtGui
from ui.info_dock import Ui_Form
class InfoDockWidget(QtWidgets.QWidget, Ui_Form):
def __init__(self, mainwindow):
super(InfoDockWidget, self).__init__()
self.setupUi(self)
self.mainwindow = mainwindow
self.lineEdit_note.textChanged.connect(self.note_changed)
def note_changed(self):
if self.mainwindow.load_finished:
self.mainwindow.set_saved_state(False)
def update_widget(self):
if self.mainwindow.current_label is not None:
self.label_width.setText('{}'.format(self.mainwindow.current_label.width))
self.label_height.setText('{}'.format(self.mainwindow.current_label.height))
self.label_depth.setText('{}'.format(self.mainwindow.current_label.depth))
self.lineEdit_note.setText(self.mainwindow.current_label.note)

View File

@ -0,0 +1,104 @@
# -*- coding: utf-8 -*-
# @Author : LG
from PyQt5 import QtWidgets, QtCore, QtGui
from ui.label_dock import Ui_Form
import functools
class LabelsDockWidget(QtWidgets.QWidget, Ui_Form):
def __init__(self, mainwindow):
super(LabelsDockWidget, self).__init__()
self.setupUi(self)
self.mainwindow = mainwindow
self.polygon_item_dict = {}
self.listWidget.itemSelectionChanged.connect(self.set_polygon_selected)
self.listWidget.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu)
self.listWidget.customContextMenuRequested.connect(
self.right_button_menu)
def right_button_menu(self, point):
self.mainwindow.right_button_menu.exec_(self.listWidget.mapToGlobal(point))
def generate_item_and_itemwidget(self, polygon):
color = self.mainwindow.category_color_dict.get(polygon.category, '#000000')
item = QtWidgets.QListWidgetItem()
item.setSizeHint(QtCore.QSize(200, 30))
item_widget = QtWidgets.QWidget()
layout = QtWidgets.QHBoxLayout()
layout.setContentsMargins(9, 1, 9, 1)
check_box = QtWidgets.QCheckBox()
check_box.setFixedWidth(20)
check_box.setChecked(polygon.isVisible())
check_box.stateChanged.connect(functools.partial(self.set_polygon_show, polygon))
layout.addWidget(check_box)
label_color = QtWidgets.QLabel()
label_color.setFixedWidth(10)
label_color.setStyleSheet("background-color: {};".format(color))
layout.addWidget(label_color)
category = QtWidgets.QLabel(polygon.category)
group = QtWidgets.QLabel('{}'.format(polygon.group))
note = QtWidgets.QLabel('{}'.format(polygon.note))
label_iscrowd = QtWidgets.QLabel()
label_iscrowd.setFixedWidth(3)
if polygon.iscrowd == 1:
label_iscrowd.setStyleSheet("background-color: {};".format('#000000'))
layout.addWidget(category)
layout.addWidget(group)
layout.addWidget(note)
layout.addWidget(label_iscrowd, alignment=QtCore.Qt.AlignmentFlag.AlignRight)
item_widget.setLayout(layout)
return item, item_widget
def update_listwidget(self):
self.listWidget.clear()
self.polygon_item_dict.clear()
for polygon in self.mainwindow.polygons:
item, item_widget = self.generate_item_and_itemwidget(polygon)
self.listWidget.addItem(item)
self.listWidget.setItemWidget(item, item_widget)
self.polygon_item_dict[polygon] = item
if self.mainwindow.load_finished:
self.mainwindow.set_saved_state(False)
def set_selected(self, polygon):
item = self.polygon_item_dict[polygon]
if polygon.isSelected():
if not item.isSelected():
item.setSelected(True)
if not polygon.isSelected():
if item.isSelected():
item.setSelected(False)
def set_polygon_selected(self):
items = self.listWidget.selectedItems()
have_selected = True if items else False
if have_selected:
self.mainwindow.scene.change_mode_to_edit()
else:
self.mainwindow.scene.change_mode_to_view()
for index, polygon in enumerate(self.mainwindow.polygons):
if self.polygon_item_dict[polygon] in items:
if not polygon.isSelected():
polygon.setSelected(True)
else:
if polygon.isSelected():
polygon.setSelected(False)
def set_polygon_show(self, polygon):
for vertex in polygon.vertexs:
vertex.setVisible(self.sender().checkState())
polygon.setVisible(self.sender().checkState())

476
widgets/mainwindow.py Normal file
View File

@ -0,0 +1,476 @@
# -*- coding: utf-8 -*-
# @Author : LG
from PyQt5 import QtWidgets, QtCore, QtGui
from ui.MainWindow import Ui_MainWindow
from widgets.setting_dialog import SettingDialog
from widgets.category_choice_dialog import CategoryChoiceDialog
from widgets.category_edit_dialog import CategoryEditDialog
from widgets.labels_dock_widget import LabelsDockWidget
from widgets.files_dock_widget import FilesDockWidget
from widgets.info_dock_widget import InfoDockWidget
from widgets.right_button_menu import RightButtonMenu
from widgets.shortcut_dialog import ShortcutDialog
from widgets.about_dialog import AboutDialog
from widgets.converter import ConvertDialog
from widgets.canvas import AnnotationScene, AnnotationView
from configs import STATUSMode, MAPMode, load_config, save_config, CONFIG_FILE, DEFAULT_CONFIG_FILE
from annotation import Object, Annotation
from widgets.polygon import Polygon
import os
from PIL import Image
import imgviz
from segment_any.segment_any import SegAny
import icons_rc
class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.setupUi(self)
self.init_ui()
self.image_root: str = None
self.label_root:str = None
self.files_list: list = []
self.current_index = None
self.current_file_index: int = None
self.config_file = CONFIG_FILE if os.path.exists(CONFIG_FILE) else DEFAULT_CONFIG_FILE
self.saved = True
self.load_finished = False
self.polygons:list = []
self.png_palette = None # 图像拥有调色盘说明是单通道的标注png文件
self.instance_cmap = imgviz.label_colormap()
self.map_mode = MAPMode.LABEL
# 标注目标
self.current_label:Annotation = None
self.reload_cfg()
self.init_connect()
self.reset_action()
self.init_segment_anything()
def init_segment_anything(self):
if os.path.exists('./segment_any/sam_vit_h_4b8939.pth'):
self.statusbar.showMessage('Find the checkpoint named {}.'.format('sam_vit_h_4b8939.pth'))
self.segany = SegAny('./segment_any/sam_vit_h_4b8939.pth')
self.use_segment_anything = True
elif os.path.exists('./segment_any/sam_vit_l_0b3195.pth'):
self.statusbar.showMessage('Find the checkpoint named {}.'.format('sam_vit_l_0b3195.pth'))
self.segany = SegAny('./segment_any/sam_vit_l_0b3195.pth')
self.use_segment_anything = True
elif os.path.exists('./segment_any/sam_vit_b_01ec64.pth'):
self.statusbar.showMessage('Find the checkpoint named {}.'.format('sam_vit_b_01ec64.pth'))
self.segany = SegAny('./segment_any/sam_vit_b_01ec64.pth')
self.use_segment_anything = True
self.statusbar.showMessage()
else:
QtWidgets.QMessageBox.warning(self, 'Warning', 'The checkpoint of [Segment anything] not existed. If you want use quick annotate, please download from {}'.format('https://github.com/facebookresearch/segment-anything#model-checkpoints'))
self.use_segment_anything = False
def init_ui(self):
self.setting_dialog = SettingDialog(parent=self, mainwindow=self)
self.labels_dock_widget = LabelsDockWidget(mainwindow=self)
self.labels_dock.setWidget(self.labels_dock_widget)
self.files_dock_widget = FilesDockWidget(mainwindow=self)
self.files_dock.setWidget(self.files_dock_widget)
self.info_dock_widget = InfoDockWidget(mainwindow=self)
self.info_dock.setWidget(self.info_dock_widget)
self.scene = AnnotationScene(mainwindow=self)
self.category_choice_widget = CategoryChoiceDialog(self, mainwindow=self, scene=self.scene)
self.category_edit_widget = CategoryEditDialog(self, self, self.scene)
self.convert_dialog = ConvertDialog(self, mainwindow=self)
self.view = AnnotationView(parent=self)
self.view.setScene(self.scene)
self.setCentralWidget(self.view)
self.right_button_menu = RightButtonMenu(mainwindow=self)
self.right_button_menu.addAction(self.actionEdit)
self.right_button_menu.addAction(self.actionTo_top)
self.right_button_menu.addAction(self.actionTo_bottom)
self.shortcut_dialog = ShortcutDialog(self)
self.about_dialog = AboutDialog(self)
self.labelCoordinates = QtWidgets.QLabel('')
self.statusbar.addPermanentWidget(self.labelCoordinates)
self.trans = QtCore.QTranslator()
def translate(self, language='zh'):
if language == 'zh':
self.trans.load('ui/zh_CN')
else:
self.trans.load('ui/en')
self.actionChinese.setChecked(language=='zh')
self.actionEnglish.setChecked(language=='en')
_app = QtWidgets.QApplication.instance()
_app.installTranslator(self.trans)
self.retranslateUi(self)
self.info_dock_widget.retranslateUi(self.info_dock_widget)
self.labels_dock_widget.retranslateUi(self.labels_dock_widget)
self.files_dock_widget.retranslateUi(self.files_dock_widget)
self.category_choice_widget.retranslateUi(self.category_choice_widget)
self.category_edit_widget.retranslateUi(self.category_edit_widget)
self.setting_dialog.retranslateUi(self.setting_dialog)
self.about_dialog.retranslateUi(self.about_dialog)
self.shortcut_dialog.retranslateUi(self.shortcut_dialog)
self.convert_dialog.retranslateUi(self.convert_dialog)
def translate_to_chinese(self):
self.translate('zh')
self.cfg['language'] = 'zh'
def translate_to_english(self):
self.translate('en')
self.cfg['language'] = 'en'
def reload_cfg(self):
self.cfg = load_config(self.config_file)
label_dict_list = self.cfg.get('label', [])
d = {}
for label_dict in label_dict_list:
category = label_dict.get('name', 'unknow')
color = label_dict.get('color', '#000000')
d[category] = color
self.category_color_dict = d
if self.current_index is not None:
self.show_image(self.current_index)
language = self.cfg.get('language', 'en')
self.translate(language)
def set_saved_state(self, is_saved:bool):
self.saved = is_saved
if self.files_list is not None and self.current_index is not None:
if is_saved:
self.setWindowTitle(self.current_label.label_path)
else:
self.setWindowTitle('*{}'.format(self.current_label.label_path))
def open_dir(self):
dir = QtWidgets.QFileDialog.getExistingDirectory(self)
if dir:
self.files_list.clear()
self.files_dock_widget.listWidget.clear()
files = []
suffixs = tuple(['{}'.format(fmt.data().decode('ascii').lower()) for fmt in QtGui.QImageReader.supportedImageFormats()])
for f in os.listdir(dir):
if f.lower().endswith(suffixs):
# f = os.path.join(dir, f)
files.append(f)
files = sorted(files)
self.files_list = files
self.files_dock_widget.update_widget()
self.current_index = 0
self.image_root = dir
self.actionOpen_dir.setStatusTip("Image root: {}".format(self.image_root))
if self.label_root is None:
self.label_root = dir
self.actionSave_dir.setStatusTip("Label root: {}".format(self.label_root))
self.show_image(self.current_index)
def save_dir(self):
dir = QtWidgets.QFileDialog.getExistingDirectory(self)
if dir:
self.label_root = dir
self.actionSave_dir.setStatusTip("Label root: {}".format(self.label_root))
# 刷新图片
if self.current_index is not None:
self.show_image(self.current_index)
def save(self):
if self.current_label is None:
return
self.current_label.objects.clear()
for polygon in self.polygons:
object = polygon.to_object()
self.current_label.objects.append(object)
self.current_label.note = self.info_dock_widget.lineEdit_note.text()
self.current_label.save_annotation()
self.set_saved_state(True)
def show_image(self, index:int):
self.reset_action()
self.current_label = None
self.load_finished = False
self.saved = True
if not -1 < index < len(self.files_list):
self.scene.clear()
self.scene.setSceneRect(QtCore.QRectF())
return
try:
self.polygons.clear()
self.labels_dock_widget.listWidget.clear()
self.scene.cancel_draw()
file_path = os.path.join(self.image_root, self.files_list[index])
image_data = Image.open(file_path)
self.png_palette = image_data.getpalette()
if self.png_palette is not None:
self.statusbar.showMessage('This is a label file.')
self.actionSegment_anything.setEnabled(False)
self.actionPolygon.setEnabled(False)
self.actionSave.setEnabled(False)
self.actionBit_map.setEnabled(False)
else:
self.actionSegment_anything.setEnabled(self.use_segment_anything)
self.actionPolygon.setEnabled(True)
self.actionSave.setEnabled(True)
self.actionBit_map.setEnabled(True)
self.scene.load_image(file_path)
self.view.zoomfit()
# load label
if self.png_palette is None:
_, name = os.path.split(file_path)
label_path = os.path.join(self.label_root, '.'.join(name.split('.')[:-1]) + '.json')
self.current_label = Annotation(file_path, label_path)
# 载入数据
self.current_label.load_annotation()
for object in self.current_label.objects:
polygon = Polygon()
self.scene.addItem(polygon)
polygon.load_object(object)
self.polygons.append(polygon)
if self.current_label is not None:
self.setWindowTitle('{}'.format(self.current_label.label_path))
else:
self.setWindowTitle('{}'.format(file_path))
self.labels_dock_widget.update_listwidget()
self.info_dock_widget.update_widget()
self.files_dock_widget.set_select(index)
self.current_index = index
self.files_dock_widget.label_current.setText('{}'.format(self.current_index+1))
self.load_finished = True
except Exception as e:
print(e)
finally:
if self.current_index > 0:
self.actionPrev.setEnabled(True)
else:
self.actionPrev.setEnabled(False)
if self.current_index < len(self.files_list) - 1:
self.actionNext.setEnabled(True)
else:
self.actionNext.setEnabled(False)
def prev_image(self):
if self.scene.mode != STATUSMode.VIEW:
return
if self.current_index is None:
return
if not self.saved:
result = QtWidgets.QMessageBox.question(self, 'Warning', 'Proceed without saved?', QtWidgets.QMessageBox.StandardButton.Yes|QtWidgets.QMessageBox.StandardButton.No, QtWidgets.QMessageBox.StandardButton.No)
if result == QtWidgets.QMessageBox.StandardButton.No:
return
self.current_index = self.current_index - 1
if self.current_index < 0:
self.current_index = 0
QtWidgets.QMessageBox.warning(self, 'Warning', 'This is the first picture.')
else:
self.show_image(self.current_index)
def next_image(self):
if self.scene.mode != STATUSMode.VIEW:
return
if self.current_index is None:
return
if not self.saved:
result = QtWidgets.QMessageBox.question(self, 'Warning', 'Proceed without saved?', QtWidgets.QMessageBox.StandardButton.Yes|QtWidgets.QMessageBox.StandardButton.No, QtWidgets.QMessageBox.StandardButton.No)
if result == QtWidgets.QMessageBox.StandardButton.No:
return
self.current_index = self.current_index + 1
if self.current_index > len(self.files_list)-1:
self.current_index = len(self.files_list)-1
QtWidgets.QMessageBox.warning(self, 'Warning', 'This is the last picture.')
else:
self.show_image(self.current_index)
def jump_to(self):
index = self.files_dock_widget.lineEdit_jump.text()
if index:
if not index.isdigit():
if index in self.files_list:
index = self.files_list.index(index)+1
else:
QtWidgets.QMessageBox.warning(self, 'Warning', 'Don`t exist image named: {}'.format(index))
self.files_dock_widget.lineEdit_jump.clear()
return
index = int(index)-1
if 0 <= index < len(self.files_list):
self.show_image(index)
self.files_dock_widget.lineEdit_jump.clear()
else:
QtWidgets.QMessageBox.warning(self, 'Warning', 'Index must be in [1, {}].'.format(len(self.files_list)))
self.files_dock_widget.lineEdit_jump.clear()
self.files_dock_widget.lineEdit_jump.clearFocus()
return
def cancel_draw(self):
self.scene.cancel_draw()
def setting(self):
self.setting_dialog.load_cfg()
self.setting_dialog.show()
def add_new_object(self, category, group, segmentation, area, layer, bbox):
if self.current_label is None:
return
object = Object(category=category, group=group, segmentation=segmentation, area=area, layer=layer, bbox=bbox)
self.current_label.objects.append(object)
def delete_object(self, index:int):
if 0 <= index < len(self.current_label.objects):
del self.current_label.objects[index]
def change_bit_map(self):
if self.scene.mode == STATUSMode.CREATE:
self.scene.cancel_draw()
if self.map_mode == MAPMode.LABEL:
# to semantic
for polygon in self.polygons:
polygon.setEnabled(False)
for vertex in polygon.vertexs:
vertex.setVisible(False)
polygon.change_color(QtGui.QColor(self.category_color_dict.get(polygon.category, '#000000')))
polygon.color.setAlpha(255)
polygon.setBrush(polygon.color)
self.labels_dock_widget.listWidget.setEnabled(False)
self.actionSegment_anything.setEnabled(False)
self.actionPolygon.setEnabled(False)
self.map_mode = MAPMode.SEMANTIC
semantic_icon = QtGui.QIcon()
semantic_icon.addPixmap(QtGui.QPixmap(":/icon/icons/semantic.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionBit_map.setIcon(semantic_icon)
elif self.map_mode == MAPMode.SEMANTIC:
# to instance
for polygon in self.polygons:
polygon.setEnabled(False)
for vertex in polygon.vertexs:
vertex.setVisible(False)
if polygon.group != '':
rgb = self.instance_cmap[int(polygon.group)]
else:
rgb = self.instance_cmap[0]
polygon.change_color(QtGui.QColor(rgb[0], rgb[1], rgb[2], 255))
polygon.color.setAlpha(255)
polygon.setBrush(polygon.color)
self.labels_dock_widget.listWidget.setEnabled(False)
self.actionSegment_anything.setEnabled(False)
self.actionPolygon.setEnabled(False)
self.map_mode = MAPMode.INSTANCE
instance_icon = QtGui.QIcon()
instance_icon.addPixmap(QtGui.QPixmap(":/icon/icons/instance.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionBit_map.setIcon(instance_icon)
elif self.map_mode == MAPMode.INSTANCE:
# to label
for polygon in self.polygons:
polygon.setEnabled(True)
for vertex in polygon.vertexs:
# vertex.setEnabled(True)
vertex.setVisible(polygon.isVisible())
polygon.change_color(QtGui.QColor(self.category_color_dict.get(polygon.category, '#000000')))
polygon.color.setAlpha(polygon.nohover_alpha)
polygon.setBrush(polygon.color)
self.labels_dock_widget.listWidget.setEnabled(True)
self.actionSegment_anything.setEnabled(self.use_segment_anything)
self.actionPolygon.setEnabled(True)
self.map_mode = MAPMode.LABEL
label_icon = QtGui.QIcon()
label_icon.addPixmap(QtGui.QPixmap(":/icon/icons/照片_pic.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionBit_map.setIcon(label_icon)
else:
pass
def label_converter(self):
self.convert_dialog.reset_gui()
self.convert_dialog.show()
def help(self):
self.shortcut_dialog.show()
def about(self):
self.about_dialog.show()
def save_cfg(self, config_file):
save_config(self.cfg, config_file)
def exit(self):
self.save_cfg(self.config_file)
self.close()
def closeEvent(self, a0: QtGui.QCloseEvent):
self.exit()
def init_connect(self):
self.actionOpen_dir.triggered.connect(self.open_dir)
self.actionSave_dir.triggered.connect(self.save_dir)
self.actionPrev.triggered.connect(self.prev_image)
self.actionNext.triggered.connect(self.next_image)
self.actionSetting.triggered.connect(self.setting)
self.actionExit.triggered.connect(self.exit)
self.actionSegment_anything.triggered.connect(self.scene.start_segment_anything)
self.actionPolygon.triggered.connect(self.scene.start_draw_polygon)
self.actionCancel.triggered.connect(self.scene.cancel_draw)
self.actionBackspace.triggered.connect(self.scene.backspace)
self.actionFinish.triggered.connect(self.scene.finish_draw)
self.actionEdit.triggered.connect(self.scene.edit_polygon)
self.actionDelete.triggered.connect(self.scene.delete_selected_graph)
self.actionSave.triggered.connect(self.save)
self.actionTo_top.triggered.connect(self.scene.move_polygon_to_top)
self.actionTo_bottom.triggered.connect(self.scene.move_polygon_to_bottom)
self.actionZoom_in.triggered.connect(self.view.zoom_in)
self.actionZoom_out.triggered.connect(self.view.zoom_out)
self.actionFit_wiondow.triggered.connect(self.view.zoomfit)
self.actionBit_map.triggered.connect(self.change_bit_map)
self.actionConverter.triggered.connect(self.label_converter)
self.actionShortcut.triggered.connect(self.help)
self.actionAbout.triggered.connect(self.about)
self.actionChinese.triggered.connect(self.translate_to_chinese)
self.actionEnglish.triggered.connect(self.translate_to_english)
self.labels_dock_widget.listWidget.doubleClicked.connect(self.scene.edit_polygon)
def reset_action(self):
self.actionPrev.setEnabled(False)
self.actionNext.setEnabled(False)
self.actionSegment_anything.setEnabled(False)
self.actionPolygon.setEnabled(False)
self.actionEdit.setEnabled(False)
self.actionDelete.setEnabled(False)
self.actionSave.setEnabled(False)
self.actionTo_top.setEnabled(False)
self.actionTo_bottom.setEnabled(False)
self.actionBit_map.setChecked(False)
self.actionBit_map.setEnabled(False)

244
widgets/polygon.py Normal file
View File

@ -0,0 +1,244 @@
# -*- coding: utf-8 -*-
# @Author : LG
from PyQt5 import QtCore, QtWidgets, QtGui
from annotation import Object
import typing
class Vertex(QtWidgets.QGraphicsPathItem):
def __init__(self, polygon, index, color):
super(Vertex, self).__init__()
self.polygon = polygon
self.index = index
self.color = color
self.hover_size = 3
self.nohover_size = 2
self.line_width = 0
self.nohover = QtGui.QPainterPath()
self.nohover.addEllipse(QtCore.QRectF(-self.nohover_size//2, -self.nohover_size//2, self.nohover_size, self.nohover_size))
self.hover = QtGui.QPainterPath()
self.hover.addEllipse(QtCore.QRectF(-self.hover_size//2, -self.hover_size//2, self.hover_size, self.hover_size))
self.setPath(self.nohover)
self.setBrush(self.color)
self.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.PointingHandCursor))
self.setPen(QtGui.QPen(self.color, self.line_width))
self.setFlag(QtWidgets.QGraphicsItem.GraphicsItemFlag.ItemIsSelectable, True)
self.setFlag(QtWidgets.QGraphicsItem.GraphicsItemFlag.ItemIsMovable, True)
self.setFlag(QtWidgets.QGraphicsItem.GraphicsItemFlag.ItemSendsGeometryChanges, True)
self.setAcceptHoverEvents(True)
self.setZValue(1e5)
def itemChange(self, change: 'QtWidgets.QGraphicsItem.GraphicsItemChange', value: typing.Any):
if change == QtWidgets.QGraphicsItem.GraphicsItemChange.ItemPositionChange and self.isEnabled():
# 限制顶点移动到图外
if value.x() < 0:
value.setX(0)
if value.x() > self.scene().width():
value.setX(self.scene().width())
if value.y() < 0:
value.setY(0)
if value.y() > self.scene().height():
value.setY(self.scene().height())
self.polygon.movePoint(self.index, value)
return super(Vertex, self).itemChange(change, value)
def hoverEnterEvent(self, event: 'QGraphicsSceneHoverEvent'):
self.setPath(self.hover)
super(Vertex, self).hoverEnterEvent(event)
def hoverLeaveEvent(self, event: 'QGraphicsSceneHoverEvent'):
self.setPath(self.nohover)
super(Vertex, self).hoverLeaveEvent(event)
class Polygon(QtWidgets.QGraphicsPolygonItem):
def __init__(self):
super(Polygon, self).__init__(parent=None)
self.line_width = 0
self.hover_alpha = 150
self.nohover_alpha = 80
self.points = []
self.vertexs = []
self.category = ''
self.group = 0
self.iscrowd = 0
self.note = ''
self.rxmin, self.rxmax, self.rymin, self.rymax = 0, 0, 0, 0 # 用于绘画完成后记录多边形的各边界此处与points对应
self.color = QtGui.QColor('#ff0000')
self.is_drawing = True
self.setPen(QtGui.QPen(self.color, self.line_width))
self.setBrush(QtGui.QBrush(self.color, QtCore.Qt.BrushStyle.FDiagPattern))
self.setAcceptHoverEvents(True)
self.setFlag(QtWidgets.QGraphicsItem.GraphicsItemFlag.ItemIsSelectable, True)
self.setFlag(QtWidgets.QGraphicsItem.GraphicsItemFlag.ItemIsMovable, True)
self.setFlag(QtWidgets.QGraphicsItem.GraphicsItemFlag.ItemSendsGeometryChanges, True)
self.setZValue(1e5)
def addPoint(self, point):
self.points.append(point)
vertex = Vertex(self, len(self.points)-1, self.color)
# 添加路径点
self.scene().addItem(vertex)
self.vertexs.append(vertex)
vertex.setPos(point)
def movePoint(self, index, point):
if not 0 <= index < len(self.points):
return
self.points[index] = self.mapFromScene(point)
self.redraw()
if self.scene().mainwindow.load_finished and not self.is_drawing:
self.scene().mainwindow.set_saved_state(False)
def removePoint(self, index):
if not self.points:
return
self.points.pop(index)
vertex = self.vertexs.pop(index)
self.scene().removeItem(vertex)
del vertex
self.redraw()
def delete(self):
self.points.clear()
while self.vertexs:
vertex = self.vertexs.pop()
self.scene().removeItem(vertex)
del vertex
def moveVertex(self, index, point):
if not 0 <= index < len(self.vertexs):
return
vertex = self.vertexs[index]
vertex.setEnabled(False)
vertex.setPos(point)
vertex.setEnabled(True)
def itemChange(self, change: 'QGraphicsItem.GraphicsItemChange', value: typing.Any):
if change == QtWidgets.QGraphicsItem.GraphicsItemChange.ItemSelectedHasChanged and not self.is_drawing: # 选中改变
if self.isSelected():
color = QtGui.QColor('#00A0FF')
color.setAlpha(self.hover_alpha)
self.setBrush(color)
else:
self.color.setAlpha(self.nohover_alpha)
self.setBrush(self.color)
self.scene().mainwindow.labels_dock_widget.set_selected(self) # 更新label面板
if change == QtWidgets.QGraphicsItem.GraphicsItemChange.ItemPositionChange: # ItemPositionHasChanged
bias = value
l, t, b, r = self.boundingRect().left(), self.boundingRect().top(), self.boundingRect().bottom(), self.boundingRect().right()
if l + bias.x() < 0: bias.setX(-l)
if r + bias.x() > self.scene().width(): bias.setX(self.scene().width()-r)
if t + bias.y() < 0: bias.setY(-t)
if b + bias.y() > self.scene().height(): bias.setY(self.scene().height()-b)
for index, point in enumerate(self.points):
self.moveVertex(index, point+bias)
if self.scene().mainwindow.load_finished and not self.is_drawing:
self.scene().mainwindow.set_saved_state(False)
return super(Polygon, self).itemChange(change, value)
def hoverEnterEvent(self, event: 'QGraphicsSceneHoverEvent'):
if not self.is_drawing:
self.color.setAlpha(self.hover_alpha)
self.setBrush(self.color)
super(Polygon, self).hoverEnterEvent(event)
def hoverLeaveEvent(self, event: 'QGraphicsSceneHoverEvent'):
if not self.is_drawing:
self.color.setAlpha(self.nohover_alpha)
self.setBrush(self.color)
super(Polygon, self).hoverEnterEvent(event)
def mouseDoubleClickEvent(self, event: 'QGraphicsSceneMouseEvent'):
if event.button() == QtCore.Qt.MouseButton.LeftButton:
self.scene().mainwindow.category_edit_widget.polygon = self
self.scene().mainwindow.category_edit_widget.load_cfg()
self.scene().mainwindow.category_edit_widget.show()
def redraw(self):
if len(self.points) < 1:
return
xs = [p.x() for p in self.points]
ys = [p.y() for p in self.points]
self.rxmin, self.rymin, self.rxmax, self.rymax = min(xs), min(ys), max(xs), max(ys)
self.setPolygon(QtGui.QPolygonF(self.points))
def change_color(self, color):
self.color = color
self.color.setAlpha(self.nohover_alpha)
self.setPen(QtGui.QPen(self.color, self.line_width))
self.setBrush(self.color)
for vertex in self.vertexs:
vertex_color = self.color
vertex_color.setAlpha(255)
vertex.setPen(QtGui.QPen(vertex_color, self.line_width))
vertex.setBrush(vertex_color)
def set_drawed(self, category, group, iscrowd, note, color:QtGui.QColor, layer=None):
self.is_drawing = False
self.category = category
self.group = group
self.iscrowd = iscrowd
self.note = note
self.color = color
self.color.setAlpha(self.nohover_alpha)
self.setPen(QtGui.QPen(self.color, self.line_width))
self.setBrush(self.color)
if layer is not None:
self.setZValue(layer)
for vertex in self.vertexs:
vertex_color = self.color
vertex_color.setAlpha(255)
vertex.setPen(QtGui.QPen(vertex_color, self.line_width))
vertex.setBrush(vertex_color)
if layer is not None:
vertex.setZValue(layer)
def calculate_area(self):
area = 0
num_points = len(self.points)
for i in range(num_points):
p1 = self.points[i]
p2 = self.points[(i + 1) % num_points]
d = p1.x() * p2.y() - p2.x() * p1.y()
area += d
return abs(area) / 2
def load_object(self, object):
segmentation = object.segmentation
for x, y in segmentation:
point = QtCore.QPointF(x, y)
self.addPoint(point)
color = self.scene().mainwindow.category_color_dict.get(object.category, '#000000')
self.set_drawed(object.category, object.group, object.iscrowd, object.note, QtGui.QColor(color), object.layer) # ...
def to_object(self):
if self.is_drawing:
return None
segmentation = []
for point in self.points:
point = point + self.pos()
segmentation.append((round(point.x()), round(point.y())))
xmin = self.boundingRect().x() + self.pos().x()
ymin = self.boundingRect().y() + self.pos().y()
xmax = xmin + self.boundingRect().width()
ymax = ymin + self.boundingRect().height()
object = Object(self.category, group=self.group, segmentation=segmentation,
area=self.calculate_area(), layer=self.zValue(), bbox=(xmin, ymin, xmax, ymax), iscrowd=self.iscrowd, note=self.note)
return object

11
widgets/process_dialog.py Normal file
View File

@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# @Author : LG
from ui.process_dialog import Ui_Dialog
from PyQt5 import QtGui, QtWidgets, QtCore
class PorcessDialog(QtWidgets.QDialog, Ui_Dialog):
def __init__(self, parent):
super(PorcessDialog, self).__init__(parent)
self.setupUi(self)

View File

@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# @Author : LG
from PyQt5 import QtWidgets
class RightButtonMenu(QtWidgets.QMenu):
def __init__(self, mainwindow):
super(RightButtonMenu, self).__init__()
self.mainwindow = mainwindow

132
widgets/setting_dialog.py Normal file
View File

@ -0,0 +1,132 @@
# -*- coding: utf-8 -*-
# @Author : LG
from PyQt5 import QtWidgets, QtCore, QtGui
from ui.setting_dialog import Ui_Dialog
from configs import *
import os
class SettingDialog(QtWidgets.QDialog, Ui_Dialog):
def __init__(self, parent, mainwindow):
super(SettingDialog, self).__init__(parent)
self.mainwindow = mainwindow
self.setupUi(self)
self.setWindowModality(QtCore.Qt.WindowModality.WindowModal)
self.init_connect()
def get_item_and_widget(self, category, color: str):
item = QtWidgets.QListWidgetItem()
item.setSizeHint(QtCore.QSize(200, 40))
widget = QtWidgets.QWidget()
layout = QtWidgets.QHBoxLayout()
category_label = QtWidgets.QLabel()
category_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
category_label.setText(category)
category_label.setObjectName('category')
# 颜色
color_button = QtWidgets.QPushButton()
color_button.setStyleSheet('QWidget {background-color: %s}' % color)
color_button.setFixedWidth(50)
color_button.clicked.connect(self.edit_category_item_color)
color_button.setObjectName('color')
# 删除
delete_button = QtWidgets.QPushButton()
delete_button.setText('delete')
delete_button.setFixedWidth(80)
delete_button.clicked.connect(self.remove_category_item)
if category == '__background__':
color_button.setEnabled(False)
delete_button.setEnabled(False)
layout.addWidget(category_label)
layout.addWidget(color_button)
layout.addWidget(delete_button)
widget.setLayout(layout)
return item, widget
def edit_category_item_color(self):
button = self.sender()
color = QtWidgets.QColorDialog.getColor()
if color.isValid():
button.setStyleSheet('QWidget {background-color: %s}' % (color.name()))
def remove_category_item(self):
button = self.sender()
row = self.category_list_widget.indexAt(button.parent().pos()).row()
self.category_list_widget.takeItem(row)
def load_cfg(self):
cfg = load_config(self.mainwindow.config_file)
self.category_list_widget.clear()
labels = cfg.get('label', [])
labels_key = [l.get('name') for l in labels]
if '__background__' not in labels_key:
print(labels)
labels.insert(0, {'name': '__background__', 'color': '#000000'})
if labels is not None:
for label in labels:
item, item_widget = self.get_item_and_widget(label.get('name', ''), color=label.get('color', '#00ff00'))
self.category_list_widget.addItem(item)
self.category_list_widget.setItemWidget(item, item_widget)
def add_new_category(self):
category = self.category_input.text()
color = self.color_button.palette().button().color().name()
if category:
item, item_widget = self.get_item_and_widget(category, color)
self.category_list_widget.addItem(item)
self.category_list_widget.setItemWidget(item, item_widget)
self.category_input.clear()
def choice_color(self):
color = QtWidgets.QColorDialog.getColor()
if color.isValid():
self.color_button.setStyleSheet('QWidget {background-color: %s}' % color.name())
def import_cfg(self):
file, _ = QtWidgets.QFileDialog.getOpenFileName(self, filter='Yaml File(*.yaml)')
if file:
self.mainwindow.config_file = file
self.mainwindow.actionSetting.setStatusTip("Config yaml: {}".format(file))
self.mainwindow.reload_cfg()
self.load_cfg()
def export_cfg(self):
file, _ = QtWidgets.QFileDialog.getSaveFileName(self, filter='Yaml File(*.yaml)')
if not file.endswith('.yaml'):
file += '.yaml'
if file:
self.mainwindow.save_cfg(file)
self.load_cfg()
def apply(self):
cfg = {}
cfg['label'] = []
for index in range(self.category_list_widget.count()):
item = self.category_list_widget.item(index)
widget = self.category_list_widget.itemWidget(item)
category_label = widget.findChild(QtWidgets.QLabel, 'category')
color_button = widget.findChild(QtWidgets.QPushButton, 'color')
cfg['label'].append(
{'name': category_label.text(), 'color': color_button.palette().button().color().name()})
save_config(cfg, self.mainwindow.config_file)
self.mainwindow.reload_cfg()
self.close()
def cache(self):
self.close()
def init_connect(self):
self.add_button.clicked.connect(self.add_new_category)
self.apply_button.clicked.connect(self.apply)
self.cache_button.clicked.connect(self.cache)
self.color_button.clicked.connect(self.choice_color)
self.pushButton_import.clicked.connect(self.import_cfg)
self.pushButton_export.clicked.connect(self.export_cfg)

View File

@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# @Author : LG
from ui.shortcut_dialog import Ui_Dialog
from PyQt5 import QtGui, QtCore, QtWidgets
class ShortcutDialog(QtWidgets.QDialog, Ui_Dialog):
def __init__(self, parent):
super(ShortcutDialog, self).__init__(parent)
self.setupUi(self)
self.setWindowModality(QtCore.Qt.WindowModality.WindowModal)