How acly/krita-ai-tools works
Main Components
• Segmentation Plugin Module: Represent the segmentation directory as the core of the plugin’s implementation. This module is subdivided into several components:
– SegmentationToolPlugin: The interface layer that connects the tool with Krita’s plugin API.
– SegmentationToolHelper: Provides support functionality for the segmentation tools.
– SegmentationToolShared: Contains code shared between different tools.
– Tools:
• SelectSegmentFromPointTool – Implements the “click to select” functionality.
• Resources and Configuration:
– JSON configuration file (kritatoolsegmentation.json) that likely describes tool properties and integration metadata.
• Build and Installation Scripts:
– CMakeLists.txt files (top-level for integration with Krita, and one inside the segmentation folder for building the plugin components).
– Installation scripts (“scripts/install-krita-with-segmentation.sh”) for patching Krita on Linux.
• External Dependencies and Models:
– External segmentation models (e.g., BiRefNet, Segment Anything Model, MobileSAM) that are downloaded/selected from the models directory in Krita’s asset location.
– GPU/CPU inference requirements and dependencies like CUDA, cuDNN in the Linux instructions.
Out Relationships and Interactions
• Within the segmentation module, create separate nodes for the user tools (point tool, rectangle tool) and indicate that both utilize common/shared classes (SegmentationToolHelper and SegmentationToolShared).
• A node for deployment/installation which involves build (CMake) and installation scripts that patch Krita.
Architectural Patterns and Design Principles
• Modular design pattern: the segmentation functionality is split into distinct components (helpers, shared code, individual tool implementations).
• Integration pattern: the plugin is built as an add-on alongside Krita via the CMake build process, meaning it seamlessly augments Krita’s existing architecture.
• Extensibility: configuration files (JSON and QRC) and potential for alternative segmentation models pave the way for future enhancements or substitutions of algorithms.
Technologies, Frameworks, and Libraries
• CMake – for building the plugin as part of Krita.
• Qt – inferred by the presence of .qrc files for resources.
• External AI models: references to Segment Anything, MobileSAM, BiRefNet, and an inference implementation (dlimgedit).
• CUDA/cuDNN – for GPU acceleration (as mentioned in the README for Linux GPU support).