Skip to content

Krita plugin which adds selection tools to mask objects with a single click, or by drawing a bounding box.

License

Notifications You must be signed in to change notification settings

Acly/krita-ai-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Krita Segmentation Tools

Plugin which adds selection tools to mask objects in your image with a single click, or by drawing a bounding box.

Select Segment from Point

Click on things to select them!

SegmentFromPoint.mp4

Select Segment from Box

Draw a box around things to select them!

SegmentFromBox.mp4

Precise mode

Select "Precise" in Tool options to get better quality masks. Depending on hardware the operation can take several seconds. This model typically extracts all foreground objects in the area, rather than one specific object that is contained entirely in the box.

precise-mode

Installation

The current version of the plugin is built for Krita 5.2.9. 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.

Hints:

  • The default installation folder is C:\Program Files\Krita (x64)
  • Copy/extract the contents of the ZIP directly, don't make a separate folder

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.9-x86_64.appimage --appimage-extract
tar -xf krita_segmentation_plugin-linux-x64-1.1.0.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

GPU support

Disclaimer: untested, and maybe not worth the hassle.

To use the GPU backend on Linux you need:

  • An NVIDIA GPU for CUDA support
  • CUDA Toolkit 12.x installed
  • cuDNN 9.x installed
  • CUDA Toolkit and cuDNN libraries must be in LD_LIBRARY_PATH

Alternative Models

For your own experiments only, not officially supported.

Precise mode

List of alternative model downloads

To use a different model, find the model folder and replace one or more of the models there (recommended to make a backup!)

  • Models are located in share/krita/ai_models/segmentation.
  • Models must be .onnx files.

Files to add or replace:

  • birefnet_cpu.onnx - preferred when using CPU backend
  • birefnet_gpu.onnx - preferred when using GPU backend
  • birefnet_hr_cpu.onnx - preferred when using high resolutions (~2K)
  • birefnet_hr_gpu.onnx - preferred when using high resolutions (~2K)

If a sepcific model doesn't exist, the other ones are used as fallback. So you only really need one of them.

Tip

On older GPUs it might make sense to delete the birefnet_gpu.onnx file for better performance.

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

About

Krita plugin which adds selection tools to mask objects with a single click, or by drawing a bounding box.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •