Awesome
Krita Segmentation Tools
Plugin which adds selection tools to mask objects in your image with a single click, or by drawing a bounding box.
<h2><img src="media/tool_segmentation_point.png"> Select Segment from Point</h2>Click on things to select them!
https://github.com/Acly/krita-ai-tools/assets/6485914/71fe2bb4-9b00-4eab-b6b7-4e9aa50d2511
<h2><img src="media/tool_segmentation_rect.png"> Select Segment from Box</h2>Draw a box around things to select them!
https://github.com/Acly/krita-ai-tools/assets/6485914/38d92925-3146-4489-a2ea-a1d3aa57c72c
Limitations
Object detection works quite well in both photos and artwork. As a solution for masking the rough shape of distinct objects and regions it is usually much quicker than lasso tool, and more flexible than contiguous selection tool ("magic wand"). Computation is instantanious for medium resolution on recent hardware (especially GPU), for high resolutions there is a noticeable delay.
The generated masks are binary masks, and typically not pixel-perfect, especially for large resolutions (the mask is always an upscale from 1024x1024). It might be possible to improve with tiling, or a subsequent alpha-matte step.
Installation
The current version of the plugin is built for Krita 5.2.0 and has been confirmed to also work for Krita 5.2.2. Using it with other versions may lead to crashes.
You can download the latest version of the plugin from the releases page.
Windows
Download the plugin and unpack the ZIP archive into your Krita installation folder. Then run Krita.
Linux
You can use this script to download and patch Krita with the plugin. It also creates a shortcut to run it.
To do it manually, get the Krita AppImage from the official source and extract it. This should result in a folder squashfs-root
. Download the plugin tar.gz
and extract it into that folder. Then run Krita. See the commands below for some environment variables that are needed to run outside the image.
./krita-5.2.0-x86_64.appimage --appimage-extract
tar -xf krita_segmentation_plugin-linux-x64-1.0.2.tar.gz -C squashfs-root/
APPDIR=/squashfs-root APPIMAGE=1 ./squashfs-root/AppRun
Arch Linux
Arch users can use the PKGBUILD
on the AUR, or with yay
or paru
:
yay -S krita-ai-tools
# or
paru -S krita-ai-tools
Building
The plugin has to be built as part of Krita, see Building Krita from Source.
After GIT checkout, clone this repository into the plugins folder:
cd krita/plugins
git clone https://github.com/Acly/krita-ai-tools.git
Next modify the CMakeLists.txt
in the same folder (krita/plugins
) by appending the following line:
add_subdirectory( krita-ai-tools )
Now build and install Krita as usual according to official instructions, and the plugin will be built alongside.
Technology
Object detection uses the Segment Anything Model, a deep neural network developed by Meta AI. To get interactive performance on local hardware, an optimized version of the model (MobileSAM) is integrated using the dlimgedit library.