Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This plugin is not working in https://github.com/vladmandic/automatic #144

Open
spreck opened this issue Apr 28, 2023 · 6 comments
Open
Labels
bug-compat Version compatibility bug

Comments

@spreck
Copy link

spreck commented Apr 28, 2023

Describe the bug
The extension worked in automatic 1111, but that project hasn't seen any updates in a month and so it was recommended to switch to vladmandic's fork which is not abandoned.

However that fork has --api always on and it is not included as part of the webui.bat file or when calling the command as a command line argument. There have been issues with using openOutpaint due to this, vladmandic/automatic#282, and I suspect something similar is going on with this.

This is a great extension and it would be awesome to be able to use it without needing to have to use a stale project to run it. I'm sure that vlad would like to see it work as well.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'https://github.com/vladmandic/automatic'
  2. Install automatic from that fork
  3. Add, https://github.com/Interpause/auto-sd-paint-ext/ to extensions, extension installs, restart server and UI
  4. Tab is not displayed in automatic web ui. Krita plugin shows "Network error: Not Found", and then when I try to run a module it says "Cannot reach backend!". However

Screenshots
This is the error in Krita, I started automatic and then waited for it to
image

image

Then when I quit Krita I see this Script error window with a 'Cannot reach backed!' message that I have to close about 5 or 6 times:
image

RuntimeError
Python 3.8.1: C:\Program Files\Krita (x64)\bin\krita.exe
Fri Apr 28 10:24:34 2023

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\guy\AppData\Roaming\krita\pykrita\krita_diff\pages\upscale.py in <lambda>(s='Cannot reach backend!')
   56     def cfg_connect(self):
   57         self.upscaler_layout.cfg_connect()
   58         self.downscale_first.cfg_connect()
   59         self.btn.released.connect(lambda: script.action_simple_upscale())
   60         script.status_changed.connect(lambda s: self.status_bar.set_status(s))
global script = <krita_diff.script.Script object>
script.status_changed = <bound PYQT_SIGNAL status_changed of Script object>
script.status_changed.connect = <built-in method connect of PyQt5.QtCore.pyqtBoundSignal object>
s = 'Cannot reach backend!'
self = <krita_diff.pages.upscale.UpscalePage object>
self.status_bar = <krita_diff.widgets.status_bar.StatusBar object>
self.status_bar.set_status = <bound method StatusBar.set_status of <krita_diff.widgets.status_bar.StatusBar object>>

 C:\Users\guy\AppData\Roaming\krita\pykrita\krita_diff\widgets\status_bar.py in set_status(self=<krita_diff.widgets.status_bar.StatusBar object>, s='Cannot reach backend!')
   18             return
   19         if s == STATE_DONE and STATE_INTERRUPT == self.text():
   20             return
   21 
   22         self.setText(f"<b>Status:</b> {s}")
self = <krita_diff.widgets.status_bar.StatusBar object>
self.setText = <built-in method setText of StatusBar object>
RuntimeError: wrapped C/C++ object of type StatusBar has been deleted
    __cause__ = None
    __class__ = <class 'RuntimeError'>
    __context__ = None
    __delattr__ = <method-wrapper '__delattr__' of RuntimeError object>
    __dict__ = {}
    __dir__ = <built-in method __dir__ of RuntimeError object>
    __doc__ = 'Unspecified run-time error.'
    __eq__ = <method-wrapper '__eq__' of RuntimeError object>
    __format__ = <built-in method __format__ of RuntimeError object>
    __ge__ = <method-wrapper '__ge__' of RuntimeError object>
    __getattribute__ = <method-wrapper '__getattribute__' of RuntimeError object>
    __gt__ = <method-wrapper '__gt__' of RuntimeError object>
    __hash__ = <method-wrapper '__hash__' of RuntimeError object>
    __init__ = <method-wrapper '__init__' of RuntimeError object>
    __init_subclass__ = <built-in method __init_subclass__ of type object>
    __le__ = <method-wrapper '__le__' of RuntimeError object>
    __lt__ = <method-wrapper '__lt__' of RuntimeError object>
    __ne__ = <method-wrapper '__ne__' of RuntimeError object>
    __new__ = <built-in method __new__ of type object>
    __reduce__ = <built-in method __reduce__ of RuntimeError object>
    __reduce_ex__ = <built-in method __reduce_ex__ of RuntimeError object>
    __repr__ = <method-wrapper '__repr__' of RuntimeError object>
    __setattr__ = <method-wrapper '__setattr__' of RuntimeError object>
    __setstate__ = <built-in method __setstate__ of RuntimeError object>
    __sizeof__ = <built-in method __sizeof__ of RuntimeError object>
    __str__ = <method-wrapper '__str__' of RuntimeError object>
    __subclasshook__ = <built-in method __subclasshook__ of type object>
    __suppress_context__ = False
    __traceback__ = <traceback object>
    args = ('wrapped C/C++ object of type StatusBar has been deleted',)
    with_traceback = <built-in method with_traceback of RuntimeError 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\guy\AppData\Roaming\krita\pykrita\krita_diff\pages\upscale.py", line 60, in <lambda>
    script.status_changed.connect(lambda s: self.status_bar.set_status(s))
  File "C:\Users\guy\AppData\Roaming\krita\pykrita\krita_diff\widgets\status_bar.py", line 22, in set_status
    self.setText(f"<b>Status:</b> {s}")
RuntimeError: wrapped C/C++ object of type StatusBar has been deleted

Desktop (please complete the following information):

  • OS: Windows 10
  • WebUI commit revision: 10:10:41-705339 INFO Python 3.10.6 on Windows
    10:10:43-073287 INFO Version: bfe62127 Thu Apr 27 15:47:13 2023 -0400
    10:10:44-116322 INFO Latest published version: 99e3fceedb2b3ecc34951d3a86148e7e39b53745 2023-04-28T17:09:34Z
  • Extension commit revision (I can't see that, but it was updated this morning)
@Interpause
Copy link
Owner

Above error is unrelated to the connection issue. Seems to be a result of the code trying to set the status bar text while Krita is closing.

@Interpause
Copy link
Owner

Can you send me a screenshot of the terminal running the webUI? It should give a warning like COMMANDLINE_ARGS does not contain --api, API won't be mounted.. vladmandic/automatic#282 does mention he added some sort of compatibility, so it might be a different issue.

@spreck
Copy link
Author

spreck commented Jun 3, 2023

Okay, it's connecting now, but there is still an error:
13:50:44-112566 ERROR Exception: 'int' object is not iterable
13:50:44-130539 ERROR INFO: 127.0.0.1:52632 - "GET /sdapi/interpause/config HTTP/1.1" 200 OK
Arguments: args=('', 0INFO: 127.0.0.1:52633 - "GET /sdapi/v1/progress HTTP/1.1" 200 OK
, 'test'INFO: 127.0.0.1:52631 - "GET /sdapi/v1/progress HTTP/1.1" 200 OK
, '', 'None', <PIL.PngImagePlugin.PngImageFile image mode=RGBA
size=666x222 at 0x2241F8A6DA0>, None, None, None, None, <PIL.PngImagePlugin.PngImageFile image
mode=RGBA size=666x222 at 0x2241F8A6DA0>, None, 40, 19, 0, None, 1, False, False, 1, 1, 12.0,
0, 0.8, -1, -1, 0.0, 0, 0, False, 1, 224, 672, 1.0, 1, False, 0, False, '', '', '', [], 0)
kwargs={}
13:50:44-178543 ERROR gradio call: TypeError
┌───────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────┐
│ C:\Users\fwss\github\automatic\modules\call_queue.py:34 in f │
│ │
│ 33 │ │ │ try: │
│ > 34 │ │ │ │ res = func(*args, **kwargs) INFO: 127.0.0.1:52634 - "GET /sdapi/v1/progress HTTP/1.1" 200 OK

│ 35 │ │ │ │ progress.record_results(id_task, res) │
│ │
│ C:\Users\fwss\github\automatic\modules\img2img.py:81 in img2img │
│ │
│ 80 │ │ sampler_index = 0 │
│ > 81 │ override_settings = create_override_settings_dict(override_settings_texts) │
│ 82 │
│ │
│ C:\Users\fwss\github\automatic\modules\generation_parameters_copypaste.py:341 in create_override_settings_dict │
│ │
│ 340 │ params = {} │
│ > 341 │ for pair in text_pairs: │
│ 342 │ │ k, v = pair.split(":", maxsplit=1) │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
TypeError: 'int' object is not iterable

@JaeHeyK
Copy link

JaeHeyK commented Jun 5, 2023

Okay, it's connecting now, but there is still an error: 13:50:44-112566 ERROR Exception: 'int' object is not iterable 13:50:44-130539 ERROR INFO: 127.0.0.1:52632 - "GET /sdapi/interpause/config HTTP/1.1" 200 OK Arguments: args=('', 0INFO: 127.0.0.1:52633 - "GET /sdapi/v1/progress HTTP/1.1" 200 OK , 'test'INFO: 127.0.0.1:52631 - "GET /sdapi/v1/progress HTTP/1.1" 200 OK , '', 'None', <PIL.PngImagePlugin.PngImageFile image mode=RGBA size=666x222 at 0x2241F8A6DA0>, None, None, None, None, <PIL.PngImagePlugin.PngImageFile image mode=RGBA size=666x222 at 0x2241F8A6DA0>, None, 40, 19, 0, None, 1, False, False, 1, 1, 12.0, 0, 0.8, -1, -1, 0.0, 0, 0, False, 1, 224, 672, 1.0, 1, False, 0, False, '', '', '', [], 0) kwargs={} 13:50:44-178543 ERROR gradio call: TypeError ┌───────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────┐ │ C:\Users\fwss\github\automatic\modules\call_queue.py:34 in f │ │ │ │ 33 │ │ │ try: │ │ > 34 │ │ │ │ res = func(*args, **kwargs) INFO: 127.0.0.1:52634 - "GET /sdapi/v1/progress HTTP/1.1" 200 OK │ │ 35 │ │ │ │ progress.record_results(id_task, res) │ │ │ │ C:\Users\fwss\github\automatic\modules\img2img.py:81 in img2img │ │ │ │ 80 │ │ sampler_index = 0 │ │ > 81 │ override_settings = create_override_settings_dict(override_settings_texts) │ │ 82 │ │ │ │ C:\Users\fwss\github\automatic\modules\generation_parameters_copypaste.py:341 in create_override_settings_dict │ │ │ │ 340 │ params = {} │ │ > 341 │ for pair in text_pairs: │ │ 342 │ │ k, v = pair.split(":", maxsplit=1) │ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ TypeError: 'int' object is not iterable

when I ran vlad's webui with debug option(.\webui --debug), I found somehow 'clip_skip' parameter is missing(-1 in log below, but should be 2 according to my setting). I think that's why all prameters after 'clip_skip' took wrong position and returned type error.

04:40:14-267444 DEBUG    txt2img: id_task=|prompt=(masterpiece, best quality:1.2), 1girl raise her hands, correct
                         anatomy|negative_prompt=(worst quality, low quality:1.4), (verybadimagenegative_v1.3:0.8),
                         text|prompt_styles=None|steps=30|sampler_index=3|restore_faces=False|tiling=False|n_iter=1|batch_size=1|cfg_scal
                         e=7.0|clip_skip=-1|seed=-1|subseed=0.0|subseed_strength=0|seed_resize_from_h=0|seed_resize_from_w=False|seed_ena
                         ble_extras=640|height=512|width=True|enable_hr=0.6|denoising_strength=0|hr_scale=SwinIR_4x|hr_upscaler=0|hr_seco
                         nd_pass_steps=1024|hr_resize_x=1280|hr_resize_y=[]|override_settings_texts=0args=()

So as quick fix, I add req.clip_skip parameters in app.py file and at least txt2img seems to work now.
Go to extensions/auto-sd-paint-ext/backend/app.py file, and add req.clip_skip between req.cfg_scale and req.seed.

 output = wrap_gradio_gpu_call(modules.txt2img.txt2img)(
        "",  # id_task (used by wrap_gradio_gpu_call for some sort of job id system)
        parse_prompt(req.prompt),  # prompt
        parse_prompt(req.negative_prompt),  # negative_prompt
        "None",  # prompt_styles: saved prompt styles (unsupported)
        req.steps,  # steps
        get_sampler_index(req.sampler_name),  # sampler_index
        req.restore_faces,  # restore_faces
        req.tiling,  # tiling
        req.batch_count,  # n_iter
        req.batch_size,  # batch_size
        req.cfg_scale,  # cfg_scale
        req.clip_skip, # clip_skip <<<<< here
        req.seed,  # seed
        req.subseed,  # subseed
        req.subseed_strength,  # subseed_strength
        req.seed_resize_from_h,  # seed_resize_from_h
        req.seed_resize_from_w,  # seed_resize_from_w
        req.seed_enable_extras,  # seed_enable_extras
        height,  # height
        width,  # width
        req.highres_fix,  # enable_hr: high res fix
        req.denoising_strength,  # denoising_strength: only applicable if high res fix in use
        0,  # hr_scale (overrided by hr_resize_x/y)
        req.upscaler_name,  # hr_upscaler: upscaler to use for highres fix
        0,  # hr_second_pass_steps: 0 uses same num of steps as generation to refine details
        req.orig_width,  # hr_resize_x
        req.orig_height,  # hr_resize_y
        [],  # override_settings_texts (unsupported)
        *args,
)

edit: okay, I just checked there's two 'output' sections in app.py (line 129 for txt2img and line 243 for img2img). By adding clip_skip param on both side, all of features(t2i, i2i, inpaint, upscale) seems to work.
image

@Daryl-Horton
Copy link

JaeHeyK, thanks for the solution. This seems to work for me, but vladmandic responds with a number of TypeErrors for missing required positional arguments.

@JaeHeyK
Copy link

JaeHeyK commented Jun 11, 2023

@Daryl-Horton yes, those errors appeared on my side too. And I suspect that's because vladmandic need default script parameters even for unused scripts. Maybe it can be covered in new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-compat Version compatibility bug
Development

No branches or pull requests

4 participants