• Stars
    star
    319
  • Rank 130,729 (Top 3 %)
  • Language
    Python
  • Created over 1 year ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple static web-based mask drawer, supporting semantic segmentation and video segmentation with interactive Segment Anything Model 2 (SAM2).

SegDrawer

Simple static web-based mask drawer, supporting semantic drawing with interactive Segment Anything Model (SAM) and Video Segmentation Propagation with XMem.

  • Video Segmentation with XMem
original video
first frame
segmentation
VideoSeg
  • Interactive segmentation
Interactive segmentation
Revert during interactive seg.

Tools

From top to bottom

  • Clear image
  • Drawer
  • SAM point-segmenter with interactive functionality (Need backend)
  • SAM rect-segmenter (Need backend)
  • SAM Seg-Everything (Need backend)
  • Undo
  • Eraser
  • Download
  • VideoSeg (Need backend)

After Seg-Everything, the downloaded files would include .zip file, which contains all cut-offs.

For Video Segmentation, according to XMem, an initial segmentation map is needed, which can be easily achieved with SAM. You can upload a video just as uploading an image, then draw a segmentation on it, after which you can click the final button of VideoSeg to upload it to the server and wait for the automatic download of video seg result.

Note: you may not want to draw the segmentation map manually with the tool Drawer (Same problem holds for Eraser), which leads to non-single color paints especially on the edge as shown below. This is not good for XMem video segmentation. For more details please refer to the original paper. Using SAM for segmenting is preferable.

For Interactive Segmentation

  1. How to start
    • Click magic wand button (the curso becomes cross)
  2. How to use
    • Postive prompt by single left click
    • Negative prompt by single right click
    • The behavior of revert button will change, which removes the latest interactive prompt
  3. How to end
    • Click the magic wand button once again (the curso becomes normal). Note: it's actually safe to click any other button while in interactive mode.
    • The latest mask will save to the mask collections
    • The behavior of revert button will be turned back

Run Locally

If you don't need SAM for segmentation, just open segDrawer.html and use tools except SAM segmenter.

If you use SAM segmenter, do following steps (CPU can be time-consuming)

wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_l_0b3195.pth
wget -P ./XMem/saves/ https://github.com/hkchengrex/XMem/releases/download/v1.0/XMem.pth
  • Install the dependencies
pip install -r requirements.txt
  • Launch backend
python server.py
  • Go to Browser
http://127.0.0.1:7860

For configuring CPU/GPU and model, just change the code in server.py

sam_checkpoint = "sam_vit_l_0b3195.pth" # "sam_vit_l_0b3195.pth" or "sam_vit_h_4b8939.pth"
model_type = "vit_l" # "vit_l" or "vit_h"
device = "cuda" # "cuda" if torch.cuda.is_available() else "cpu"

Colab Tutorial

Follow this Colab example, or run on Colab. Need to register a ngrok account and copy your token to replace "{your_token}".

More Repositories

1

MachineLearningPlayground

Implementation of basic mathematical pattern recognition/machine learning techniques for fun
Jupyter Notebook
90
star
2

Digital-Image-Processing

中国农业大学数字图像处理实验:基于Python语言的数字图像处理程序,包含工具栏。主要功能包括:灰度变换(n值化、线性化、非线性化);绘制RGB直方图;两幅任意大小、通道图像相加;均值滤波和中值滤波;Sobel算子锐化;集成人脸识别API如face_recognition库、虹软SDK、face++、paddlehub库
Python
25
star
3

DetectWeb

中国农业大学毕业实习项目:病虫害检测,类别有苹果、樱桃、玉米、葡萄、桃子、胡椒、土豆、番茄等
HTML
22
star
4

Compiling-Principle-PL0-Expanding

中国农业大学编译原理大作业,PL/0语言扩展(包括I/O、浮点、for循环、数组、复合运算、过程传参、注释、乱序声明、exit等),以及基于editplus的IDE配置
C
16
star
5

Computer-Graphics

中国农业大学计算机图形学完整代码和报告,欢迎参考学习
C++
10
star
6

AI_TryOn_mini

An AI try-on application for generating photos with AI character wearing the same clothes as the one in the input photo.
Python
10
star
7

LaboratoryAnimalHousing

该系统由中国农业大学-计算机科学与技术2017级-软件工程“实验动物房管理”小组开发实现,提供的功能是:后勤管理(ZLJ)、动物健康管理(FYX)、环境管控(LYL)、动物繁育管理(LYL&LZL)、动物饲养管理(WLW)、福利喂养(YT);旨在帮助实验动物房下管理员和职工完成日常工作事务处理和记录。
JavaScript
7
star
8

WheatDetectionApp

Java
5
star
9

Android_Opencv_JNI_ImgProcessing

C++
3
star
10

pythonGadget

用python写的有的没的
Jupyter Notebook
3
star
11

LeetCode-Record

A record for coding practice on leetcode
C++
2
star
12

YOLOv1_tensorflow

2016年You Only Look Once(YOLO)实现,包含所有源码注释并解决一些原作者编码中的bug,供源码学习交流使用
Python
2
star
13

SOTA-Prototypes

Simplifyied prototypes of SOTAs. (PyTorch)
Jupyter Notebook
1
star
14

Embedded-Hardware-Development-SelfTeaching

1
star
15

TheUniverseOnline

An application based on ReactJS for exploring the universe, mainly the Earth for now.
JavaScript
1
star
16

lujiazho.github.io

HTML
1
star
17

Android-based_Fashion_Dection_in_real_time

deep learning based fashion attributes detection and deployment on Android
Jupyter Notebook
1
star
18

MRI2CT_beta

Python
1
star