Skip to content

Conversation

@InconsolableCellist
Copy link

Many environments (like mine) have my ML environment and Krita client on separate computers. This update now has the server save all images locally and then respond to remote requests to fetch/save images/masks, allowing for the plugin to run remotely.

@InconsolableCellist
Copy link
Author

b3b5fbb also fixes inpainting

samsartor added a commit to samsartor/stable-diffusion-krita-plugin that referenced this pull request Sep 19, 2022
Copy link
Owner

@sddebz sddebz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello and thank you for this PR. This is definitely a good feature. The only problem I have with this request is that it seems you removed some lines from krita_diff.py and krita_diff_ui.py. Once this issue is solved I'll merge it.

@InconsolableCellist
Copy link
Author

I had to resolve merge conflicts and it looks like some code got accidentally removed. I believe I've added it all back now, and changed the constant MODE_SD_UPSCALE from 3 to 2

@sddebz
Copy link
Owner

sddebz commented Sep 20, 2022

So thank you for fixes. I looked at the PR again and I see that it doesn't really work in my Krita. I think the problem is it tries to import requests library. Until now I only used standard python library and Krita's libs. Right now I'm not sure how to proceed. I don't want to force users to do some manual steps like installing request lib in pykrita folder or globally. At the same time I don't see how to easly replace requests with urllib.request for this scenario.

So in short, I can't really merge it now because it requires requests library. Maybe you will be able to find a way to remove this depencency or provide a clear and easy way to install missing dependencies for Krita.

@sddebz
Copy link
Owner

sddebz commented Sep 20, 2022

To he honest, I was already working on adding remote server support. I was going to just send file as base64 string in json. I think if we don't find a good solution here, I'll be able to add this feature next weekend. But I'll be happy to merge your version if we make sure it will work for everyone.

@InconsolableCellist
Copy link
Author

InconsolableCellist commented Sep 20, 2022

Oh true, because Krita uses its own Python env you have to copy or link your system libs to Krita.

E.g., on Linux:

cp -R /usr/lib/python3/dist-packages/urllib3 ~/.local/share/krita/pykrita/
cp -R /usr/lib/python3/dist-packages/six.py ~/.local/share/krita/pykrita/
cp -R /usr/lib/python3/dist-packages/chardet ~/.local/share/krita/pykrita/
cp -R /usr/lib/python3/dist-packages/certifi ~/.local/share/krita/pykrita/
cp -R /usr/lib/python3/dist-packages/idna ~/.local/share/krita/pykrita/
cp -R /usr/lib/python3/dist-packages/requests ~/.local/share/krita/pykrita/

I had tried to use just urllib whatever the default lib is, but it doesn't seem to handle file transfers very well. You could do it with base64, that would make for a neater install at least.

In that case you could replace /saveimg on the server with one that accepts base64 in the body, it should be as easy as changing line 325 in krita_diff.py to something like this:

with open(path, "rb") as image_file:
    encoded_string = base64.b64encode(image_file.read())
urllib.request.urlopen(url, encoded_string)

I didn't test that though, but it's a good idea to workaround the lib issue.

I think the fix in 7d9a15d for inpainting is good too.

What me to try base64 encoding as an alternative?

@sddebz
Copy link
Owner

sddebz commented Sep 20, 2022

Well, I would say just let me fix it. I'll have time to do it on saturday.

@InconsolableCellist
Copy link
Author

Any progress on this? My changes still work; I've been using them daily.

@sddebz
Copy link
Owner

sddebz commented Oct 2, 2022

I'm sorry. Due to funny actions of my president, I'm currently unable to finish this work. I hope I will be able to look at it this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants