修复第一次点击sam无法标注的问题
This commit is contained in:
parent
f4b994d30b
commit
3c5e85df23
60
README.md
60
README.md
@ -1,4 +1,5 @@
|
|||||||
# ISAT with segment anything
|
# ISAT with segment anything
|
||||||
|
|
||||||
# 交互式半自动图像分割标注工具
|
# 交互式半自动图像分割标注工具
|
||||||
|
|
||||||

|

|
||||||
@ -17,6 +18,7 @@
|
|||||||
Demo Video:[youtube](https://www.youtube.com/watch?v=yLdZCPmX-Bc)
|
Demo Video:[youtube](https://www.youtube.com/watch?v=yLdZCPmX-Bc)
|
||||||
|
|
||||||
# 特点
|
# 特点
|
||||||
|
|
||||||
- 支持基于SAM的**交互式半自动标注**。
|
- 支持基于SAM的**交互式半自动标注**。
|
||||||
- 支持**手动标注**多边形。
|
- 支持**手动标注**多边形。
|
||||||
- 支持标注**二次修改**。
|
- 支持标注**二次修改**。
|
||||||
@ -25,52 +27,60 @@ Demo Video:[youtube](https://www.youtube.com/watch?v=yLdZCPmX-Bc)
|
|||||||
- 更多功能详见[功能说明](./docs/功能说明.md)
|
- 更多功能详见[功能说明](./docs/功能说明.md)
|
||||||
|
|
||||||
# 安装
|
# 安装
|
||||||
|
|
||||||
## 1. 源码运行
|
## 1. 源码运行
|
||||||
|
|
||||||
### (1) 创建虚拟环境
|
### (1) 创建虚拟环境
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
conda create -n ISAT_with_segment_anything python==3.8
|
conda create -n ISAT_with_segment_anything python==3.8
|
||||||
conda activate ISAT_with_segment_anything
|
conda activate ISAT_with_segment_anything
|
||||||
```
|
```
|
||||||
|
|
||||||
### (2) 安装ISAT_with_segment_anything
|
### (2) 安装ISAT_with_segment_anything
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
git clone https://github.com/yatengLG/ISAT_with_segment_anything.git
|
git clone https://github.com/yatengLG/ISAT_with_segment_anything.git
|
||||||
cd ISAT_with_segment_anything
|
cd ISAT_with_segment_anything
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
### (3) 下载Segment anything预训练模型
|
### (3) 下载Segment anything预训练模型
|
||||||
|
|
||||||
下载预训练模型,并将模型存放于ISAT_with_segment_anything/segment_any目录下
|
下载预训练模型,并将模型存放于ISAT_with_segment_anything/segment_any目录下
|
||||||
|
|
||||||
当前支持的模型有[SAM](https://github.com/facebookresearch/segment-anything)系列,[sam-hq](https://github.com/SysCV/sam-hq)系列,[MobileSAM](https://github.com/ChaoningZhang/MobileSAM)系列。
|
当前支持的模型有[SAM](https://github.com/facebookresearch/segment-anything)系列,[sam-hq](https://github.com/SysCV/sam-hq)系列,[MobileSAM](https://github.com/ChaoningZhang/MobileSAM)系列。
|
||||||
|
|
||||||
| 系列 | 预训练模型 | 显存占用 | 文件大小 |
|
| 系列 | 预训练模型 | 显存占用 | 文件大小 |
|
||||||
|----|----|----|----|
|
| ---------- | ------------------------------------------------------------------------------------------ | -------- | -------- |
|
||||||
| SAM | [sam_vit_h_4b8939.pth](https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth) | 7305M | 2.6G |
|
| SAM | [sam_vit_h_4b8939.pth](https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth) | 7305M | 2.6G |
|
||||||
| | [sam_vit_l_0b3195.pth](https://dl.fbaipublicfiles.com/segment_anything/sam_vit_l_0b3195.pth) | 5855M | 2.6G |
|
| | [sam_vit_l_0b3195.pth](https://dl.fbaipublicfiles.com/segment_anything/sam_vit_l_0b3195.pth) | 5855M | 2.6G |
|
||||||
| | [sam_vit_b_01ec64.pth](https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth) | 4149M | 375M |
|
| | [sam_vit_b_01ec64.pth](https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth) | 4149M | 375M |
|
||||||
| sam-hq | [sam_hq_vit_h.pth](https://huggingface.co/lkeab/hq-sam/blob/main/sam_hq_vit_h.pth) | 7393M | 2.6G |
|
| sam-hq | [sam_hq_vit_h.pth](https://huggingface.co/lkeab/hq-sam/blob/main/sam_hq_vit_h.pth) | 7393M | 2.6G |
|
||||||
| | [sam_hq_vit_l.pth](https://huggingface.co/lkeab/hq-sam/blob/main/sam_hq_vit_l.pth) | 5939M | 1.3G |
|
| | [sam_hq_vit_l.pth](https://huggingface.co/lkeab/hq-sam/blob/main/sam_hq_vit_l.pth) | 5939M | 1.3G |
|
||||||
| | [sam_hq_vit_b.pth](https://huggingface.co/lkeab/hq-sam/blob/main/sam_hq_vit_b.pth) | 4207M | 379M |
|
| | [sam_hq_vit_b.pth](https://huggingface.co/lkeab/hq-sam/blob/main/sam_hq_vit_b.pth) | 4207M | 379M |
|
||||||
| | [sam_hq_vit_tiny.pth](https://huggingface.co/lkeab/hq-sam/blob/main/sam_hq_vit_tiny.pth) | 1463M | 43M |
|
| | [sam_hq_vit_tiny.pth](https://huggingface.co/lkeab/hq-sam/blob/main/sam_hq_vit_tiny.pth) | 1463M | 43M |
|
||||||
| mobile-sam | [mobile_sam.pt](https://github.com/ChaoningZhang/MobileSAM/blob/master/weights/mobile_sam.pt)| 1375M | 40M |
|
| mobile-sam | [mobile_sam.pt](https://github.com/ChaoningZhang/MobileSAM/blob/master/weights/mobile_sam.pt) | 1375M | 40M |
|
||||||
|
|
||||||
下载好模型后,通过SAM-下拉列表,选择要用的模型。(切换模型需要一定时间,切换h模型大概需要5秒左右,视硬件情况而定。)
|
下载好模型后,通过SAM-下拉列表,选择要用的模型。(切换模型需要一定时间,切换h模型大概需要5秒左右,视硬件情况而定。)
|
||||||
|
|
||||||
### (4) 运行软件
|
### (4) 运行软件
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
python main.py
|
python main.py
|
||||||
```
|
```
|
||||||
|
|
||||||
## 2. windows下exe运行
|
## 2. windows下exe运行
|
||||||
|
|
||||||
### (1) 下载打包好的exe文件
|
### (1) 下载打包好的exe文件
|
||||||
|
|
||||||
需下载三个.zip文件,总体大小2.7G,解压缩后4.9G。
|
需下载三个.zip文件,总体大小2.7G,解压缩后4.9G。
|
||||||
|
|
||||||
打开ISAT_with_segment_anything文件夹,双击main.exe运行。
|
打开ISAT_with_segment_anything文件夹,双击main.exe运行。
|
||||||
|
|
||||||
| | 下载链接 |
|
| | 下载链接 |
|
||||||
|--------|-----------------------------------------------------------|
|
| -------- | ------------------------------------------------------------------ |
|
||||||
| 百度网盘 | 链接:https://pan.baidu.com/s/1vD19PzvIT1QAJrAkSVFfhg 提取码:ISAT |
|
| 百度网盘 | 链接:https://pan.baidu.com/s/1vD19PzvIT1QAJrAkSVFfhg 提取码:ISAT |
|
||||||
|
|
||||||
### (2) 下载Segment anything预训练模型
|
### (2) 下载Segment anything预训练模型
|
||||||
|
|
||||||
@ -80,9 +90,25 @@ python main.py
|
|||||||
|
|
||||||
下载地址同上[下载预训练模型](https://github.com/yatengLG/ISAT_with_segment_anything/#3-下载segment-anything预训练模型)
|
下载地址同上[下载预训练模型](https://github.com/yatengLG/ISAT_with_segment_anything/#3-下载segment-anything预训练模型)
|
||||||
|
|
||||||
|
## 3. nuitka打包说明
|
||||||
|
|
||||||
|
经过在windows11上的测试,合适的环境之一为:
|
||||||
|
|
||||||
|
```
|
||||||
|
python=3.7.10
|
||||||
|
numpy=1.20.1
|
||||||
|
torch=1.10.0+cu102 或任意cpu版本的torch
|
||||||
|
```
|
||||||
|
|
||||||
|
其它库按需安装即可,未发现冲突情况
|
||||||
|
|
||||||
|
|
||||||
# 使用
|
# 使用
|
||||||
|
|
||||||
软件具体功能可查看:[功能说明](./docs/功能说明.md)
|
软件具体功能可查看:[功能说明](./docs/功能说明.md)
|
||||||
|
|
||||||
## 1.标注
|
## 1.标注
|
||||||
|
|
||||||
```text
|
```text
|
||||||
1. 软件左侧选择类别(工具栏-文件-设置中,进行类别添加或修改)
|
1. 软件左侧选择类别(工具栏-文件-设置中,进行类别添加或修改)
|
||||||
2. 开始标注
|
2. 开始标注
|
||||||
@ -99,7 +125,9 @@ python main.py
|
|||||||
3. 点击工具栏[标注完成]按钮,完成标注(快捷键E)。
|
3. 点击工具栏[标注完成]按钮,完成标注(快捷键E)。
|
||||||
4. 点击工具栏[保存]按钮(快捷键S),写入json文件。
|
4. 点击工具栏[保存]按钮(快捷键S),写入json文件。
|
||||||
```
|
```
|
||||||
|
|
||||||
## 2.修改
|
## 2.修改
|
||||||
|
|
||||||
```text
|
```text
|
||||||
1. 多边形修改
|
1. 多边形修改
|
||||||
拖拽多边形顶点,修改多边形形状。
|
拖拽多边形顶点,修改多边形形状。
|
||||||
@ -111,7 +139,9 @@ python main.py
|
|||||||
4. 删除目标
|
4. 删除目标
|
||||||
选定目标,点击工具栏[删除]按钮(快捷键DEL),删除选定目标。
|
选定目标,点击工具栏[删除]按钮(快捷键DEL),删除选定目标。
|
||||||
```
|
```
|
||||||
|
|
||||||
## 3.查看
|
## 3.查看
|
||||||
|
|
||||||
```text
|
```text
|
||||||
1. 结果预览
|
1. 结果预览
|
||||||
点击工具栏[位图]按钮(快捷键SPACE),预览标注结果。
|
点击工具栏[位图]按钮(快捷键SPACE),预览标注结果。
|
||||||
@ -125,9 +155,12 @@ python main.py
|
|||||||
半自动标注时,会调暗背景,凸显mask。
|
半自动标注时,会调暗背景,凸显mask。
|
||||||
通过工具栏[mask alpha]数值条,调整背景与mask混合比例。
|
通过工具栏[mask alpha]数值条,调整背景与mask混合比例。
|
||||||
```
|
```
|
||||||
|
|
||||||
## 4.数据转换
|
## 4.数据转换
|
||||||
|
|
||||||
本软件用json文件保存标注结果。
|
本软件用json文件保存标注结果。
|
||||||
使用时,可以手动解析json文件,或转换为其他数据格式。
|
使用时,可以手动解析json文件,或转换为其他数据格式。
|
||||||
|
|
||||||
```text
|
```text
|
||||||
软件内置了转换工具
|
软件内置了转换工具
|
||||||
1. ISAT转VOC
|
1. ISAT转VOC
|
||||||
@ -141,6 +174,7 @@ python main.py
|
|||||||
```
|
```
|
||||||
|
|
||||||
# 引用
|
# 引用
|
||||||
|
|
||||||
```text
|
```text
|
||||||
@misc{ISAT with segment anything,
|
@misc{ISAT with segment anything,
|
||||||
title={{ISAT with segment anything}: Image segmentation annotation tool with segment anything},
|
title={{ISAT with segment anything}: Image segmentation annotation tool with segment anything},
|
||||||
|
BIN
icons/logo.ico
Normal file
BIN
icons/logo.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 209 KiB |
2212
icons_rc.py
Normal file
2212
icons_rc.py
Normal file
File diff suppressed because it is too large
Load Diff
1
main.py
1
main.py
@ -6,7 +6,6 @@ from PyQt5 import QtWidgets
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
os.environ['SAM_ANN_BASE_DIR'] = os.path.dirname(os.path.abspath(__file__))
|
os.environ['SAM_ANN_BASE_DIR'] = os.path.dirname(os.path.abspath(__file__))
|
||||||
sys.path.insert(0, os.path.join(os.environ['SAM_ANN_BASE_DIR'], 'lib'))
|
|
||||||
from sam_ann import MainWindow
|
from sam_ann import MainWindow
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
imgviz==1.2.6
|
imgviz==1.2.6
|
||||||
mahotas==1.4.13
|
mahotas==1.4.13
|
||||||
numpy==1.24.3
|
numpy==1.24.3
|
||||||
opencv_python_headless==4.5.3.56
|
opencv_python==4.5.3.56
|
||||||
Pillow==9.2.0
|
Pillow==9.2.0
|
||||||
PyQt5==5.15.7
|
PyQt5==5.15.7
|
||||||
PyYAML==6.0
|
PyYAML==6.0
|
||||||
torch==1.8.1
|
|
||||||
torchvision==0.9.1
|
|
||||||
pycocotools
|
pycocotools
|
||||||
timm
|
|
@ -20,6 +20,6 @@ label:
|
|||||||
name: cake
|
name: cake
|
||||||
- color: '#5c3566'
|
- color: '#5c3566'
|
||||||
name: fence
|
name: fence
|
||||||
language: en
|
language: zh
|
||||||
mask_alpha: 0.7
|
mask_alpha: 0.7
|
||||||
vertex_size: 2
|
vertex_size: 2
|
||||||
|
@ -130,7 +130,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||||||
self.statusbar.showMessage("Segment anything only use the 3 dim with shape {} .".format(image_data.shape))
|
self.statusbar.showMessage("Segment anything only use the 3 dim with shape {} .".format(image_data.shape))
|
||||||
else:
|
else:
|
||||||
self.statusbar.showMessage("Segment anything don't support the image with shape {} .".format(image_data.shape))
|
self.statusbar.showMessage("Segment anything don't support the image with shape {} .".format(image_data.shape))
|
||||||
|
self.image_changed = False
|
||||||
self.show_image(self.current_index)
|
self.show_image(self.current_index)
|
||||||
# if self.current_index is not None:
|
# if self.current_index is not None:
|
||||||
# self.image_changed = False
|
# self.image_changed = False
|
||||||
@ -360,6 +360,14 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||||||
return
|
return
|
||||||
if not self.image_changed:
|
if not self.image_changed:
|
||||||
self.scene.cancel_draw()
|
self.scene.cancel_draw()
|
||||||
|
self.actionSegment_anything.setEnabled(self.use_segment_anything)
|
||||||
|
self.actionPolygon.setEnabled(True)
|
||||||
|
self.actionSave.setEnabled(True)
|
||||||
|
self.actionBit_map.setEnabled(True)
|
||||||
|
self.actionBackspace.setEnabled(True)
|
||||||
|
self.actionFinish.setEnabled(True)
|
||||||
|
self.actionCancel.setEnabled(True)
|
||||||
|
self.actionVisible.setEnabled(True)
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
self.scene.cancel_draw()
|
self.scene.cancel_draw()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user