OpenCVのGrabCut()を利用したセマンティックセグメンテーション向けアノテーションツール(Annotation tool using GrabCut() of OpenCV. It can be used to create datasets for semantic segmentation.)

Overview

[Japanese/English]

GrabCut-Annotation-Tool

GrabCut-Annotation-Tool.mp4

OpenCVのGrabCut()を利用したアノテーションツールです。
セマンティックセグメンテーション向けのデータセット作成にご使用いただけます。
※GrabCutのアルゴリズムの都合上、境界がはっきりしているデータのアノテーションに向いています。

Requirement

  • opencv-python 4.5.2.54 or later
  • Pillow 7.2.0 or later
  • PySimpleGUI 4.32.1 or later

Directory

│  app.py
│  config.json
│  
├─core
│  │  gui.py
│  └─util.py
│          
├─input
│      
└─output
    ├─image
    └─annotation

app.py, core/gui.py, core/util.py

ソースコードです。

input

アノテーション対象の画像ファイルを格納するディレクトリです。

output

アノテーション結果を保存するディレクトリです。

  • image:リサイズした画像が格納されます
  • annotation:アノテーション結果が格納されます
    ※パレットモードのPNG形式で保存

Usage

次のコマンドで起動してください。

python app.py

起動時には以下オプションが指定可能です。

  • --input
    入力画像格納パス
    デフォルト:input
  • --output_image
    アノテーション結果(画像)の格納パス
    デフォルト:output/image
  • --output_annotation
    アノテーション結果(セグメンテーション画像)の格納パス
    デフォルト:output/annotation
  • --config
    ロードするコンフィグファイル
    デフォルト:config.json

Using GrabCut-Annotation-Tool

ファイル選択

ファイル一覧をクリックすることでアノテーション対象を切り替えることが出来ます。
ショートカットキー ↑、p:上のファイルへ ↓、n:下のファイルへ

初期ROI指定

「Select ROI」と表示されている時にマウス右ドラッグで初期ROIを指定できます。


ドラッグ終了後、GrabCut処理が行われます。


領域が選択されます。


後景指定

マウス右ドラッグで後景の指定が出来ます。




前景指定

「Manually label background」のチェックを外すことで前景指定に切り替えることが出来ます
ショートカットキー Ctrl


マウス右ドラッグで前景の指定が出来ます。




クラスID切り替え

Class IDのチェックボックスを押すことでクラスIDを切り替えることが出来ます。
一桁のIDはショートカットキーでの切り替えも可能です。
ショートカットキー 0-9


クラスID切り替え後はROI指定を行う必要があります。




自動保存

リサイズ画像とアノテーション画像はGrabCut処理毎に自動保存されます。


自動保存をしたくない場合は「Auto save」のチェックを外してください。
自動保存以外で保存したい場合は、キーボード「s」を押してください。


その他設定


  • Mask alpha:画像のマスク重畳表示の濃淡具合
  • Iteration:GrabCutアルゴリズムのイテレーション回数
  • Draw thickness:前景/後景指定時の線の太さ
  • Output width:出力画像の横幅
  • Output height:出力画像の縦幅

ToDo

  • メモリリーク対策
  • ROI選択時に左上→右下ドラッグ以外も可能にする
  • クラスIDをショートカットキーで選択した際にROI選択表示にする

Author

高橋かずひと(https://twitter.com/KzhtTkhs)

License

GrabCut-Annotation-Tool is under Apache-2.0 License.

サンプル画像はフリー素材ぱくたそ様の写真を利用しています。

You might also like...
IJON is an annotation mechanism that analysts can use to guide fuzzers such as AFL.
IJON is an annotation mechanism that analysts can use to guide fuzzers such as AFL.

IJON SPACE EXPLORER IJON is an annotation mechanism that analysts can use to guide fuzzers such as AFL. Using only a small (usually one line) annotati

Mae segmentation - Reproduction of semantic segmentation using masked autoencoder (mae)

ADE20k Semantic segmentation with MAE Getting started Install the mmsegmentation

Object detection using yolo-tiny model and opencv used as backend
Object detection using yolo-tiny model and opencv used as backend

Object detection Algorithm used : Yolo algorithm Backend : opencv Library required: opencv = 4.5.4-dev' Quick Overview about structure 1) main.py Load

Learning Pixel-level Semantic Affinity with Image-level Supervision for Weakly Supervised Semantic Segmentation, CVPR 2018
Learning Pixel-level Semantic Affinity with Image-level Supervision for Weakly Supervised Semantic Segmentation, CVPR 2018

Learning Pixel-level Semantic Affinity with Image-level Supervision This code is deprecated. Please see https://github.com/jiwoon-ahn/irn instead. Int

A embed able annotation tool for end to end cross document co-reference
A embed able annotation tool for end to end cross document co-reference

CoRefi CoRefi is an emebedable web component and stand alone suite for exaughstive Within Document and Cross Document Coreference Anntoation. For a de

A graphical Semi-automatic annotation tool based on labelImg and Yolov5
A graphical Semi-automatic annotation tool based on labelImg and Yolov5

💕YOLOV5 semi-automatic annotation tool (Based on labelImg)

Open source annotation tool for machine learning practitioners.
Open source annotation tool for machine learning practitioners.

doccano doccano is an open source text annotation tool for humans. It provides annotation features for text classification, sequence labeling and sequ

ObjectDrawer-ToolBox: a graphical image annotation tool to generate ground plane masks for a 3D object reconstruction system
ObjectDrawer-ToolBox: a graphical image annotation tool to generate ground plane masks for a 3D object reconstruction system

ObjectDrawer-ToolBox is a graphical image annotation tool to generate ground plane masks for a 3D object reconstruction system, Object Drawer.

performing moving objects segmentation using image processing techniques with opencv and numpy
performing moving objects segmentation using image processing techniques with opencv and numpy

Moving Objects Segmentation On this project I tried to perform moving objects segmentation using background subtraction technique. the introduced meth

Comments
  • Memory leak in PySimpleGUI Graph.

    Memory leak in PySimpleGUI Graph.

    core/gui.py

    You need to clear the canvas before using draw_image(). Otherwise, canvases will continue to be added and memory leaks will occur.

            self._window['-IMAGE ORIGINAL-'].draw_image(
                data=bytes_image,
                location=(0, imaga_height),
            )
    

    You need to call delete_figure() as follows:

            if self._graph_image_id is not None:
                self._window['-IMAGE ORIGINAL-'].delete_figure(self._graph_image_id)
    
            self._graph_image_id = self._window['-IMAGE ORIGINAL-'].draw_image(
                data=bytes_image,
                location=(0, imaga_height),
            )
    
    opened by Kazuhito00 1
  • WOW!  What an amazing program!

    WOW! What an amazing program!

    I stumbled onto your project the other day and had to look, multiple times, to see that it is a PySimpleGUI-based program. Very nicely done! Thanks for the great screenshots in your readme. I'm sure visitors are enjoying the show as much as I have.

    opened by PySimpleGUI 1
Releases(v0.1.3)
Owner
KazuhitoTakahashi
KazuhitoTakahashi
PyTorch Implementation of "Non-Autoregressive Neural Machine Translation"

Non-Autoregressive Transformer Code release for Non-Autoregressive Neural Machine Translation by Jiatao Gu, James Bradbury, Caiming Xiong, Victor O.K.

Salesforce 261 Nov 12, 2022
Official code of paper: MovingFashion: a Benchmark for the Video-to-Shop Challenge

SEAM Match-RCNN Official code of MovingFashion: a Benchmark for the Video-to-Shop Challenge paper Installation Requirements: Pytorch 1.5.1 or more rec

HumaticsLAB 31 Oct 10, 2022
Code for the KDD 2021 paper 'Filtration Curves for Graph Representation'

Filtration Curves for Graph Representation This repository provides the code from the KDD'21 paper Filtration Curves for Graph Representation. Depende

Machine Learning and Computational Biology Lab 16 Oct 16, 2022
Multimodal Descriptions of Social Concepts: Automatic Modeling and Detection of (Highly Abstract) Social Concepts evoked by Art Images

MUSCO - Multimodal Descriptions of Social Concepts Automatic Modeling of (Highly Abstract) Social Concepts evoked by Art Images This project aims to i

0 Aug 22, 2021
Companion code for the paper Theoretical characterization of uncertainty in high-dimensional linear classification

Companion code for the paper Theoretical characterization of uncertainty in high-dimensional linear classification Usage The required packages are lis

0 Feb 07, 2022
The source code for 'Noisy-Labeled NER with Confidence Estimation' accepted by NAACL 2021

Kun Liu*, Yao Fu*, Chuanqi Tan, Mosha Chen, Ningyu Zhang, Songfang Huang, Sheng Gao. Noisy-Labeled NER with Confidence Estimation. NAACL 2021. [arxiv]

30 Nov 12, 2022
A modified version of DeepMind's Alphafold2 to divide CPU part (MSA and template searching) and GPU part (prediction model)

ParallelFold Author: Bozitao Zhong This is a modified version of DeepMind's Alphafold2 to divide CPU part (MSA and template searching) and GPU part (p

Bozitao Zhong 77 Dec 22, 2022
Config files for my GitHub profile.

Canalyst Candas Data Science Library Name Canalyst Candas Description Built by a former PM / analyst to give anyone with a little bit of Python knowle

Canalyst Candas 13 Jun 24, 2022
Transfer-Learn is an open-source and well-documented library for Transfer Learning.

Transfer-Learn is an open-source and well-documented library for Transfer Learning. It is based on pure PyTorch with high performance and friendly API. Our code is pythonic, and the design is consist

THUML @ Tsinghua University 2.2k Jan 03, 2023
Source code for our paper "Molecular Mechanics-Driven Graph Neural Network with Multiplex Graph for Molecular Structures"

Molecular Mechanics-Driven Graph Neural Network with Multiplex Graph for Molecular Structures Code for the Multiplex Molecular Graph Neural Network (M

shzhang 59 Dec 10, 2022
Latent Network Models to Account for Noisy, Multiply-Reported Social Network Data

VIMuRe Latent Network Models to Account for Noisy, Multiply-Reported Social Network Data. If you use this code please cite this article (preprint). De

6 Dec 15, 2022
YOLOv7 - Framework Beyond Detection

🔥🔥🔥🔥 YOLO with Transformers and Instance Segmentation, with TensorRT acceleration! 🔥🔥🔥

JinTian 3k Jan 01, 2023
Indices Matter: Learning to Index for Deep Image Matting

IndexNet Matting This repository includes the official implementation of IndexNet Matting for deep image matting, presented in our paper: Indices Matt

Hao Lu 357 Nov 26, 2022
PyTorch implementation of our paper: Decoupling and Recoupling Spatiotemporal Representation for RGB-D-based Motion Recognition

Decoupling and Recoupling Spatiotemporal Representation for RGB-D-based Motion Recognition, arxiv This is a PyTorch implementation of our paper. 1. Re

DamoCV 11 Nov 19, 2022
Official PyTorch Implementation of GAN-Supervised Dense Visual Alignment

GAN-Supervised Dense Visual Alignment — Official PyTorch Implementation Paper | Project Page | Video This repo contains training, evaluation and visua

944 Jan 07, 2023
Conceptual 12M is a dataset containing (image-URL, caption) pairs collected for vision-and-language pre-training.

Conceptual 12M We introduce the Conceptual 12M (CC12M), a dataset with ~12 million image-text pairs meant to be used for vision-and-language pre-train

Google Research Datasets 226 Dec 07, 2022
Tensorflow implementation of Character-Aware Neural Language Models.

Character-Aware Neural Language Models Tensorflow implementation of Character-Aware Neural Language Models. The original code of author can be found h

Taehoon Kim 751 Dec 26, 2022
Bounding Wasserstein distance with couplings

BoundWasserstein These scripts reproduce the results of the article Bounding Wasserstein distance with couplings by Niloy Biswas and Lester Mackey. ar

Niloy Biswas 1 Jan 11, 2022
Project code for weakly supervised 3D object detectors using wide-baseline multi-view traffic camera data: WIBAM.

WIBAM (Work in progress) Weakly Supervised Training of Monocular 3D Object Detectors Using Wide Baseline Multi-view Traffic Camera Data 3D object dete

Matthew Howe 10 Aug 24, 2022
Simple object detection app with streamlit

object-detection-app Simple object detection app with streamlit. Upload an image and perform object detection. Adjust the confidence threshold to see

Robin Cole 68 Jan 02, 2023