Interpause / auto-sd-krita

AUTOMATIC1111 webUI + Krita Plugin with superb Inpainting
MIT License
88 stars 4 forks source link

not currently working? #49

Closed Norgus closed 1 year ago

Norgus commented 1 year ago

I set it up using git before, so I started off by opening a git console in the plugin dir, doing 'git pull' to update. I also switched my auto1111 repo using 'git switch --detach krita/master' which worked once I stashed my webui-user.bat away. However, on launching krita and trying either txt2img or img2img I get an error, an example of which I have pasted below:

JSONDecodeError
Python 3.8.1: C:\Program Files\Krita (x64)\bin\krita.exe
Sat Oct 29 14:37:21 2022

A problem occurred in a Python script.  Here is the sequence of
function calls leading up to the error, in the order they occurred.

 C:\Users\norgu\AppData\Roaming\krita\pykrita\krita_diff\pages\txt2img.py in <lambda>()
   41         self.highres.cfg_connect()
   42         self.highres.toggled.connect(toggle_highres)
   43         toggle_highres(self.highres.isChecked())
   44 
   45         self.btn.released.connect(lambda: script.action_txt2img())
self undefined
global script = <krita_diff.script.Script object>
script.action_txt2img = <bound method Script.action_txt2img of <krita_diff.script.Script object>>

 C:\Users\norgu\AppData\Roaming\krita\pykrita\krita_diff\script.py in action_txt2img(self=<krita_diff.script.Script object>)
  269             return
  270         self.adjust_selection()
  271         self.apply_txt2img()
  272 
  273     def action_img2img(self):
self = <krita_diff.script.Script object>
self.apply_txt2img = <bound method Script.apply_txt2img of <krita_diff.script.Script object>>

 C:\Users\norgu\AppData\Roaming\krita\pykrita\krita_diff\script.py in apply_txt2img(self=<krita_diff.script.Script object>)
  173             self.status_changed.emit(STATE_TXT2IMG)
  174 
  175         self.client.post_txt2img(
  176             cb, self.width, self.height, self.selection is not None
  177         )
self = <krita_diff.script.Script object>
self.client = <krita_diff.client.Client object>
self.client.post_txt2img = <bound method Client.post_txt2img of <krita_diff.client.Client object>>
cb = <function Script.apply_txt2img.<locals>.cb>
self.width = 512
self.height = 512
self.selection = None

 C:\Users\norgu\AppData\Roaming\krita\pykrita\krita_diff\client.py in post_txt2img(self=<krita_diff.client.Client object>, cb=<function Script.apply_txt2img.<locals>.cb>, width=512, height=512, has_selection=False)
  236             )
  237             ext_name = self.cfg("txt2img_script", str)
  238             ext_args = get_ext_args(self.ext_cfg, "scripts_txt2img", ext_name)
  239             params.update(self.get_common_params(has_selection))
  240             params.update(
ext_args undefined
global get_ext_args = <function get_ext_args>
self = <krita_diff.client.Client object>
self.ext_cfg = <krita_diff.config.Config object>
ext_name = 'None'

 C:\Users\norgu\AppData\Roaming\krita\pykrita\krita_diff\utils.py in get_ext_args(ext_cfg=<krita_diff.config.Config object>, ext_type='scripts_txt2img', ext_name='None')
   27 def get_ext_args(ext_cfg: Config, ext_type: str, ext_name: str):
   28     """Get args for script in positional list form."""
   29     meta = json.loads(ext_cfg(get_ext_key(ext_type, ext_name)))
   30     args = []
   31     for i, o in enumerate(meta):
meta undefined
global json = <module 'json' from 'C:\\Program Files\\Krita (x64)\\python\\python38.zip\\json\\__init__.pyc'>
json.loads = <function loads>
ext_cfg = <krita_diff.config.Config object>
global get_ext_key = <function get_ext_key>
ext_type = 'scripts_txt2img'
ext_name = 'None'

 C:\Program Files\Krita (x64)\json\__init__.py in loads(s='', cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw={})

 C:\Program Files\Krita (x64)\json\decoder.py in decode(self=<json.decoder.JSONDecoder object>, s='', _w=<built-in method match of re.Pattern object>)

 C:\Program Files\Krita (x64)\json\decoder.py in raw_decode(self=<json.decoder.JSONDecoder object>, s='', idx=0)

JSONDecodeError: Expecting value: line 1 column 1 (char 0)
    __cause__ = None
    __class__ = <class 'json.decoder.JSONDecodeError'>
    __context__ = StopIteration(0)
    __delattr__ = <method-wrapper '__delattr__' of JSONDecodeError object>
    __dict__ = {'colno': 1, 'doc': '', 'lineno': 1, 'msg': 'Expecting value', 'pos': 0}
    __dir__ = <built-in method __dir__ of JSONDecodeError object>
    __doc__ = None
    __eq__ = <method-wrapper '__eq__' of JSONDecodeError object>
    __format__ = <built-in method __format__ of JSONDecodeError object>
    __ge__ = <method-wrapper '__ge__' of JSONDecodeError object>
    __getattribute__ = <method-wrapper '__getattribute__' of JSONDecodeError object>
    __gt__ = <method-wrapper '__gt__' of JSONDecodeError object>
    __hash__ = <method-wrapper '__hash__' of JSONDecodeError object>
    __init__ = <bound method JSONDecodeError.__init__ of JSONDe...ror('Expecting value: line 1 column 1 (char 0)')>
    __init_subclass__ = <built-in method __init_subclass__ of type object>
    __le__ = <method-wrapper '__le__' of JSONDecodeError object>
    __lt__ = <method-wrapper '__lt__' of JSONDecodeError object>
    __module__ = 'json.decoder'
    __ne__ = <method-wrapper '__ne__' of JSONDecodeError object>
    __new__ = <built-in method __new__ of type object>
    __reduce__ = <bound method JSONDecodeError.__reduce__ of JSON...ror('Expecting value: line 1 column 1 (char 0)')>
    __reduce_ex__ = <built-in method __reduce_ex__ of JSONDecodeError object>
    __repr__ = <method-wrapper '__repr__' of JSONDecodeError object>
    __setattr__ = <method-wrapper '__setattr__' of JSONDecodeError object>
    __setstate__ = <built-in method __setstate__ of JSONDecodeError object>
    __sizeof__ = <built-in method __sizeof__ of JSONDecodeError object>
    __str__ = <method-wrapper '__str__' of JSONDecodeError object>
    __subclasshook__ = <built-in method __subclasshook__ of type object>
    __suppress_context__ = True
    __traceback__ = <traceback object>
    __weakref__ = None
    args = ('Expecting value: line 1 column 1 (char 0)',)
    colno = 1
    doc = ''
    lineno = 1
    msg = 'Expecting value'
    pos = 0
    with_traceback = <built-in method with_traceback of JSONDecodeError object>

The above is a description of an error in a Python program.  Here is
the original traceback:

Traceback (most recent call last):
  File "C:\Users\norgu\AppData\Roaming\krita\pykrita\krita_diff\pages\txt2img.py", line 45, in <lambda>
    self.btn.released.connect(lambda: script.action_txt2img())
  File "C:\Users\norgu\AppData\Roaming\krita\pykrita\krita_diff\script.py", line 271, in action_txt2img
    self.apply_txt2img()
  File "C:\Users\norgu\AppData\Roaming\krita\pykrita\krita_diff\script.py", line 175, in apply_txt2img
    self.client.post_txt2img(
  File "C:\Users\norgu\AppData\Roaming\krita\pykrita\krita_diff\client.py", line 238, in post_txt2img
    ext_args = get_ext_args(self.ext_cfg, "scripts_txt2img", ext_name)
  File "C:\Users\norgu\AppData\Roaming\krita\pykrita\krita_diff\utils.py", line 29, in get_ext_args
    meta = json.loads(ext_cfg(get_ext_key(ext_type, ext_name)))
  File "json\__init__.py", line 357, in loads
  File "json\decoder.py", line 337, in decode
  File "json\decoder.py", line 355, in raw_decode
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Interpause commented 1 year ago

This seems due to me exposing AUTO's script API. Error occurs in the logic for loading cached metadata for scripts. JSON error indicates the metadata is empty rather than corrupted. Probably means the script dropdown has a value outside of the options available.

Try clicking the "(Experimental) Scripts" and selecting an option (i.e. "None"). When I am finished with my work, I will just have it reset to the default of None if the metadata is invalid.

Norgus commented 1 year ago

I'm going from memory but I don't think so, I remember testing the web interface and generating one image there, then pressing the button in Krita didn't add anything to the server log. I used my own webui-user.bat and had to remove --api and --vae-path (I don't think it liked vae-ft-mse-840000-ema-pruned.ckpt) I still had --listen and --xformers enabled.

I might just wait until the automatic1111 API matures and you adopt it, this seems like a headache. (having to switch between being up to date and branched & fiddle with my startup batch each time seems tedious)

On Sun, 30 Oct 2022, 11:51 John-Henry Lim, @.***> wrote:

Was there any error in the server console?

— Reply to this email directly, view it on GitHub https://github.com/Interpause/auto-sd-krita/issues/49#issuecomment-1296233434, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA7XGB2J3ZWZYCBURCXOG3WFZOL3ANCNFSM6AAAAAARRZPC2I . You are receiving this because you authored the thread.Message ID: @.***>

Interpause commented 1 year ago

Actually, in the short term, I am looking at using the extensions API instead.

I right now have a feeling the API maturing would take quite a while longer, and probably will never support some of the features I want unless I start making pull requests I currently don't have time for...

For example, it probably is no one's priority right now to implement calling scripts or changing shared settings in the official API. I would do it myself, but there's no tracking issue to coordinate these changes, and I simply don't have time for the next week or so.

EDIT: oh i stand corrected, the official API supports changing settings already. Just that it doesn't work for things that require reloading (i.e. models). Still rewriting to use the official API is going to take quite a lot of time. At that point, it probably is better to wait for someone to create a better plugin using the official API.

https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/4005 might be very useful if it gets merged and works correctly.

I am going to update my tracking issue on this: https://github.com/Interpause/auto-sd-krita/issues/24

bamarillo commented 1 year ago

Just a heads-up. My PR was closed but you can extend the API using https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/3982