Krita plugin: Third-party python package vs Local Server

Hi!

I am developing a custom pluging for Krita that process images on MacOS. I am currently separately writing a python script that uses models like SAM and GroundingDINO to process images through the HuggingFace python package (transformer).

I am having some trouble connecting that script to Krita. Ideally, I want to be able take input from Krita, process those inputs with my script, and send the output back to Krita. After doing some searches online, it seems like Krita has its built-in python environment that makes it difficult to install third-party pacakges like numpy and transformer? Like from this thread: use of external pip libraries in Python plugins

Alternatively, I see that the popular AI Difussion plugin for Krita has a setup where they launch a local server and have the server process image with AI models and send the results back to Krita. This seems like a flexible route where I don’t have to worry too much about trying to install python packages into Krita.

I am an experienced developer but I am still quite new to developing for Krita, so any thoughts on these two approaches would be greatly appreciated (if you have any sample code/tutorial that would be even better)!

1 Like

Hi @jama1017

The AI link has been removed due to forum restrictions.

No AI guideline
  1. This forum does not promote or want to be associated with AI image-generating tools or plugins or any image generated with AI technology as it is today. This forum is not the place to promote or showcase AI technology. And since the legality or ethical implications of current AI technology is not yet clear we do not want to host or give space to any of the content that promotes AI use. Users are free to debate about AI in the dedicated off topic thread but when adding images generated by AI please note that we do not understand the copyright implications of those images so the post might get removed.

Source: Krita-Artists Terms of Service, Content Standards

Thanks! Sorry about that. I am new to this forum. The link was mainly to demonstrate a project where a local server has been set up. Didn’t mean to promote its AI functionalities

1 Like

No worries.

Perhaps you should check the repos of these AI tools you mentioned and see how they did it. My guess is that they simply connect to a socket that belongs to their server, or maybe simple http requests. This should be possible with Krita’s python version without any issues.