Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新增缩放,过滤,隐藏提示,保存白背景功能,修复已知问题 #7

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
72 changes: 60 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
# segment_anything_gui



## 使用方法

这是一个类似PS的抠图工具,支持cpu和英伟达gpu。推荐opencv-python版本4.5.5.64(4.x大概都能跑)

使用方法

0.打开程序文件,修改配置

```
input_dir = r'G:\xiaowu-pic\133_select_new'
output_dir = r'G:\xiaowu-pic\133_new_segment'
skip_dir = r'G:\xiaowu-pic\133_done' # 需要跳动的文件(可以放原文件,也可以放程序输出的文件)
crop_mode = False # 是否裁剪到最小范围
# alpha_channel = True # alpha_channel是否保留透明通道
save_background_img = True # 是否同步生成白背景图片
```

1.将待抠图的图片放到input文件夹中,然后启动程序。

https://github.com/facebookresearch/segment-anything
Expand All @@ -13,20 +28,29 @@ https://github.com/facebookresearch/segment-anything

在图像上左键单击选择前景点(绿色),右键单击选择背景点(红色)。

按下a或d键切换到上一张或下一张图片。按下空格键清除所有选点和mask。按下q键删除最后一个选点。
按下`a`或d``键切换到上一张或下一张图片。按下空格键清除所有选点和mask。按下q键删除最后一个选点。

按下s键保存抠图结果(如果有生成过Mask的话)。
按下`s`键保存抠图结果(如果有生成过Mask的话)。

按下 `+`或`-`放大或缩小窗口

按下`e`键隐藏提示信息


3.Mask选取模式:

按下w键使用模型进行预测,进入Mask选取模式。
按下`w`键使用模型进行预测,进入Mask选取模式。

在Mask选取模式下,可以按下`a`和`d`键切换不同的Mask。

按下`s`键保存抠图结果。

在Mask选取模式下,可以按下a和d键切换不同的Mask。
按下`w`键返回选点模式,下次模型将会在此mask基础上进行预测

按下s键保存抠图结果。
按下 `+`或`-`放大或缩小窗口

按下`e`键隐藏提示信息

按下w键返回选点模式,下次模型将会在此mask基础上进行预测

4.返回选点模式,迭代优化选点

Expand All @@ -37,13 +61,29 @@ https://github.com/facebookresearch/segment-anything
程序将在output文件夹中生成抠好的图片,新切割出来图片的文件名会自增。


---
## **也可以直接将seg5.py文件复制到segment_anything项目下使用**
## **You can also directly copy the seg5.py file to the segment_anything project for use**
---



Segment-Anything-GUI

This is a Photoshop-like image segmentation and extraction tool, supporting both CPU and NVIDIA GPU. It is recommended to use the OpenCV-Python version 4.5.5.64 (4.x should also work).

How to Use

Open the program file and modify the configuration
```
input_dir = r'G:\xiaowu-pic\133_select_new'
output_dir = r'G:\xiaowu-pic\133_new_segment'
skip_dir = r'G:\xiaowu-pic\133_done' # Files that need to be jumped (you can put the original file or the file output by the program)
crop_mode = False # Whether to crop to the minimum range
# alpha_channel = True # Whether alpha_channel retains the transparent channel
save_background_img = True # Whether to generate white background images simultaneously
```

Place the images to be segmented into the input folder, then run the program.

Point selection mode (one by one, multiple points at once may have average results):
Expand All @@ -52,23 +92,31 @@ Left-click on the image to select foreground points (green).

Right-click to select background points (red).

Press the a or d key to switch to the previous or next image.
Press the `a` or `d` key to switch to the previous or next image.

Press the spacebar to clear all selected points and masks.

Press the q key to delete the last selected point.
Press the `q` key to delete the last selected point.

Press the s key to save the segmentation result (if a mask has been generated).
Press the `s` key to save the segmentation result (if a mask has been generated).

Press `+` or `-` to zoom in or out of the window

Press the `e` key to hide the prompt message

Mask selection mode:

Press the w key to use the model for prediction and enter the mask selection mode.
Press the `w` key to use the model for prediction and enter the mask selection mode.

In the mask selection mode, you can press the a and d keys to switch between different masks.

Press the s key to save the segmentation result.
Press the `s` key to save the segmentation result.

Press the `w` key to return to point selection mode. The model will predict based on this mask the next time.

Press `+` or `-` to zoom in or out of the window

Press the w key to return to point selection mode. The model will predict based on this mask the next time.
Press the `e` key to hide the prompt message

Return to point selection mode to iteratively optimize selected points:

Expand Down
Loading