My first Krita plugin! I added two tools which allow to easily select distinct objects in the image. It doesn’t always work perfectly, but is often suprisingly spot on. Also the result masks are not super precise for now, but this could be improved. I think automated alpha-matte masks is also possible to add. Feedback is appreciated.
How does it work? It uses a slim version of an image segmentation AI trained by Meta on a whole lot of images they licensed.
It can run on CPU (default) or GPU (but only really practical on windows). It’s very responsive on decent hardware. On older machines with large resolutions it might take a few seconds.
How to try it out? This is a plugin library (no python):
Windows: Extract the plugin ZIP into the Krita folder. Run Krita.
Linux: Easiest way is to download the .appimage, make it executable and run it.
Is this safe? As safe as any other (python or c++) plugin. So basically not very safe at all.
But it’s quite easy nowadays to try out things in a VM or sandbox. For example, using firejail on Linux:
I used it, it has great features, both new tools are fast, and the results are also good.
How about adding it to the krita ontology? I heard it’s an Apache 2.0 license.
The box tool can support more types of box selection methods like the “close and fill tool”.
Automatic segmentation of layer content: Detect the content in the layer, copy the layers and use transparency masks separately to make them independent
I had a WIP code which enables extracting objects by changing selection after making a base selection, but thing is that there haven’t been much support for it and I was forced to abandon it entirely because I couldn’t build Krita any more. Maybe at least a working prototype can open up minds about this. It’s the only thing I miss from other software besides a few filters.
This is insanely useful and should totally be in the Krita main branch, in this form or another. But still, in there for everyone. The results in my painting are pretty damn good. Not perfect but save me many minutes compared to doing all the selections 100% by hand.
Thank you so much for sharing! I think this will save me some time coloring in Krita since that’s the only issue I’m having… I really love Krita, but it’s missing some tools that I miss having in Photoshop and SAI so this plugin is nice to have on hand. It’s greatly appreciated!
This incredibly useful tool is kind of hard to install for Linux users so I just finished a shell script that will take the latest stable build of Krita and combine it with Acly’s tool for easier deployment:
To use the script; copy it and ctrl-shift-v to past it into terminal.
To install Krita with the object/segmentation selection tools:
echo "Installing Krita to ~/.Applications/Krita (hidden in your home directory)"
INSTALL_DIR=~/.Applications/Krita
mkdir -p "$INSTALL_DIR"
cd "$INSTALL_DIR"
echo "Getting the latest download for Krita and Segmentation Tools"
BASE_KRITA_URL="https://binary-factory.kde.org/job/Krita_Stable_Appimage_Build/lastSuccessfulBuild/artifact/"
KRITA_PAGE=$(curl -s $BASE_KRITA_URL)
LATEST_KRITA_APPIMAGE=$(echo "$KRITA_PAGE" | grep -o 'krita-.*\.appimage"' | head -1 | sed 's/"$//')
LATEST_PLUGIN=$(curl -s https://api.github.com/repos/Acly/krita-ai-tools/releases/latest | grep browser_download_url | grep tar.gz | cut -d '"' -f 4)
echo "Checking to see if your version of Krita is up to date?"
if [ ! -f "$LATEST_KRITA_APPIMAGE" ]; then
echo "Downloading new Krita"
wget -O "$LATEST_KRITA_APPIMAGE" "${BASE_KRITA_URL}${LATEST_KRITA_APPIMAGE}"
chmod +x "$LATEST_KRITA_APPIMAGE"
"./$LATEST_KRITA_APPIMAGE" --appimage-extract
else
echo "Latest Krita is already installed; moving on."
fi
echo "Updating the desktop file with correct paths"
EXTRACTED_DESKTOP_FILE="$INSTALL_DIR/squashfs-root/org.kde.krita.desktop"
ICON_PATH="$INSTALL_DIR/squashfs-root/krita.png"
if [ -f "$EXTRACTED_DESKTOP_FILE" ]; then
echo "Pointing shortcut to Krita and tools"
sed -i 's|^Exec=.*|Exec=env APPDIR='$INSTALL_DIR'/squashfs-root APPIMAGE=1 '$INSTALL_DIR'/squashfs-root/AppRun %U|' "$EXTRACTED_DESKTOP_FILE"
sed -i 's|^Icon=.*|Icon='$ICON_PATH'|' "$EXTRACTED_DESKTOP_FILE"
cp "$EXTRACTED_DESKTOP_FILE" ~/.local/share/applications/
else
echo "Extracted desktop file not found, it could have been moved."
fi
echo "Checking if segmentation plugin is outdated"
if [ ! -f "$(basename "$LATEST_PLUGIN")" ]; then
echo "Downloading new plugin"
wget -O "$(basename "$LATEST_PLUGIN")" "$LATEST_PLUGIN"
tar -xf "$(basename "$LATEST_PLUGIN")" -C squashfs-root/
else
echo "Latest segmentation plugin is already installed."
fi
echo "DONE! Installed Krita with Segmentation tools built in."
echo "For more info go here: https://github.com/Acly/krita-ai-tools"
The script will check whether you have the latest version; as it will keep the download files to check against to help you avoid unnecessary downloads. If you’re outdated, it will grab the latest Krita AppImage and plugin Tar; extracting the app image and then the tar into the extracted folder. Next the script grabs a copy of the included desktop file and modifies it to execute krita at the same time as the third party technology.
Meaning after you run this script; Krita and segmentation tools are installed and you can find it in the application list and pin the new Krita icon to your panel for easy access.
I also included a script to properly uninstall all associated data, and you even have the option of keeping your resource folder:
To uninstall:
# Ask for confirmation to uninstall Krita
read -p "Really, uninstall Krita? [Y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
# Define directories and files
INSTALL_DIR=~/.Applications/Krita
DESKTOP_FILE=~/.local/share/applications/org.kde.krita.desktop
RESOURCE_DIR=~/.local/share/krita
LOG_FILES=(~/.local/share/krita.log ~/.local/share/krita-sysinfo.log)
# Ask whether to remove all related resources and log files
echo "Uninstall all related resources and log files? [Y/N]"
read -p "" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
# Full Uninstall: Remove Krita, resource folders, and log files
rm -rf "$INSTALL_DIR" "$DESKTOP_FILE" "$RESOURCE_DIR" "${LOG_FILES[@]}"
echo "Full uninstall completed, including resources and log files."
else
# Standard Uninstall: Remove Krita and desktop file, preserve resources and logs
rm -rf "$INSTALL_DIR" "$DESKTOP_FILE"
echo "Uninstall completed, resources and log files preserved."
fi
else
echo "Uninstall aborted."
fi
It took me 4-6 long days to figure out how to make it; hope someone finds it useful!
However I would not have completed it without the help of @Michelist for pointing me to the right command for getting latest Krita stable from repo.
I hope this saves you time on assembling your favourite art tools.
You did not follow the plugin’s installation instructions. Depending on your OS they differ, go to GitHub and read them up if it is not described in this topic.
I am having an issue with the plugin. When using the new bounding box tool provided by this plugin, for example after drawing a bounding box for object selection, the Krita will crash when trying to select any other tool, like brushes or what have you. Has anyone else experienced this issue?
This is correct and can be found out reading the extensive description on GitHub. The most user-friendly plugin is the Windows version, for Linux you have to use @Acly’s AppImage or unpack the original Krita AppImage and follow the instructions on GitHub, a macOS version does not exist.
Another user currently tries to compile a version of Krita with this plugin implemented for macOS.
If the user was successful I can’t tell, after asking for information he wasn’t seen again:
Which only is half of the answer, but anyway, you are using a version of Krita that is not tested with the plugin, the only version known working is the 5.2.0, this may be the issue. So you can try it with the portable version 5.2.0 for Windows or the respective AppImage for Linux, both can be found here:
For any further help, you have to hope that @Acly will come back to this topic or, what will probably be the more effective way to reach @Acly, you report your issue on the GitHub Issue reporting site of this project. But even there you have to specify which operating system you are using in order to receive support.
The latest version of the plugin has been working for all Krita 5.2.x releases so far, including 5.2.6. I will try to edit the information in the OP since it’s quite outdated and also links to an older release (but it doesn’t look like I can?).
I vaguely remember that a crash like that was a problem at some point, so if you are not using the latest release (currently 1.0.2) make sure to upgrade.
If you still encounter the crash create an issue on GitHub and include as much info as you can (OS/Krita/Plugin versions, what you were doing exactly, crash dumps). Can’t promise much unless I can reproduce it.