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

The extension doesn't work at all (img2img() missing 3 required positional arguments) #158

Open
Miraihi opened this issue Jul 30, 2023 · 53 comments · May be fixed by #160
Open

The extension doesn't work at all (img2img() missing 3 required positional arguments) #158

Miraihi opened this issue Jul 30, 2023 · 53 comments · May be fixed by #160

Comments

@Miraihi
Copy link

Miraihi commented Jul 30, 2023

Describe the bug
Getting the error each time I click "start inpaint/img2img/txt2img" in Krita.

To Reproduce
Steps to reproduce the behavior:

  1. Insert any settings
  2. Click "start inpaint/img2img/txt2img"

Screenshots
WB0N0DR

auto-sd-paint-ext:WARNING: Interrupted!
auto-sd-paint-ext:INFO: img2img:
{'restore_faces': False, 'face_restorer': 'None', 'codeformer_weight': 0.0, 'inpainting_fill': 1, 'inpaint_full_res': False, 'inpaint_full_res_padding': 0, 'mask_blur': 0, 'invert_mask': False, 'inpaint_mask_weight': 1.0, 'sd_model': 'anything-v4.5-inpainting.safetensors [6d9a152b7a]', 'sd_vae': 'blessed2.vae.pt', 'clip_skip': 2, 'script': 'None', 'script_args': [], 'prompt': 'flawless, highly detailed, high resolution, sharp focus, 4k, vivid colors, best quality, perfect lighting, trending on artstation', 'negative_prompt': 'Negative_ng_deepnegative_v1_75t, Negative_badhandv4, (extra fingers, deformed hands:1.15), (worst quality, low quality, poor quality, bad quality:1.35), logo, watermark, text', 'seed': -1, 'seed_enable_extras': False, 'subseed': -1, 'subseed_strength': 0.0, 'seed_resize_from_h': 0, 'seed_resize_from_w': 0, 'sampler_name': 'DPM++ 2M Karras', 'steps': 20, 'cfg_scale': 10.0, 'denoising_strength': 0.4, 'batch_count': 1, 'batch_size': 1, 'base_size': 512, 'max_size': 768, 'disable_sddebz_highres': False, 'tiling': False, 'highres_fix': False, 'firstphase_height': 512, 'firstphase_width': 512, 'upscaler_name': 'None', 'filter_nsfw': False, 'include_grid': False, 'sample_path': 'outputs/krita-out', 'save_samples': True, 'is_inpaint': True, 'resize_mode': 1, 'color_correct': True, 'do_exact_steps': True}
auto-sd-paint-ext:INFO: img size: 1074x1432 -> 512x688, aspect ratio: 0.75 -> 0.74, -0.78% change
*** Error completing request
*** Arguments: ('', 4, 'flawless, highly detailed, high resolution, sharp focus, 4k, vivid colors, best quality, perfect lighting, trending on artstation', 'Negative_ng_deepnegative_v1_75t, Negative_badhandv4, (extra fingers, deformed hands:1.15), (worst quality, low quality, poor quality, bad quality:1.35), logo, watermark, text', 'None', <PIL.PngImagePlugin.PngImageFile image mode=RGBA size=1074x1432 at 0x2387BFC8A00>, None, None, None, None, <PIL.PngImagePlugin.PngImageFile image mode=RGBA size=1074x1432 at 0x2387BFC8A00>, <PIL.Image.Image image mode=L size=1074x1432 at 0x2387BD3C910>, 20, 2, 0, None, 1, False, False, 1, 1, 10.0, 0, 0.4, -1, -1, 0.0, 0, 0, False, 1, 688, 512, 1.0, 1, False, 0, False, '', '', '', [], 0) {}
    Traceback (most recent call last):
      File "E:\AI\stable-diffusion-webui-directml\modules\call_queue.py", line 58, in f
        res = list(func(*args, **kwargs))
      File "E:\AI\stable-diffusion-webui-directml\modules\call_queue.py", line 37, in f
        res = func(*args, **kwargs)
    TypeError: img2img() missing 3 required positional arguments: 'img2img_batch_png_info_props', 'img2img_batch_png_info_dir', and 'request'

Desktop (please complete the following information):

  • OS: Windows 11 64 bit.
  • WebUI commit revision: 4873e6aaba62c2fa2e4481798e85098e50e1e2c6
  • Extension commit revision: 0071435

Additional context
Doesn't work since 1.5.1 Automatic update. Worked fine before that.

@DrCyanide
Copy link

DrCyanide commented Aug 2, 2023

I've fixed this on my local copy a few times now. A few weeks ago I had it working, then the SD XL updates it broke again, and I fixed it once again. This method will help you fix it each time it breaks in the future. I'm using SD.Next (vlads), but the process should be identical for A1111

extensions\auto-sd-paint-ext\backend\app.py has a list of parameters it uses to call txt2img and img2img, as part of def f_txt2img and def f_img2img respectively. Both lists of parameters start on lines that have output = wrap_gradio_gpu_call. These parameters should correspond to the parameters in modules\txt2img.py's def txt2img and modules\img2img.py's def img2img.
BUT
It seems like the modules keep getting updated, adding and removing required parameters, which in turn breaks this extension.

The quick-and-dirty way to fix the extension each time it breaks is to open up those modules and go item by item through their parameters and line them up with the app.py version. After you've done that, save app.py and restart your stable diffusion server. When you try to use the Krita extension, you'll see a lot of output in the server logs, including errors, but it should work.

It's tedious, it sucks, and I'm sure there's a better way to do it, but for right now that's what you need to do.

@Fhalo48
Copy link

Fhalo48 commented Aug 2, 2023

Same her, getting following errors:-
*** Error completing request
*** Arguments: ('', '', '', 'None', 20, 6, False, False, 1, 1, 7.0, -1, -1, 0.0, 0, 0, False, 512, 512, False, 0.7, 0, 'None', 0, 512, 512, [], 0) {}
Traceback (most recent call last):
File "F:\AI\Automatic1111\stable-diffusion-webui\modules\call_queue.py", line 58, in f
res = list(func(*args, **kwargs))
File "F:\AI\Automatic1111\stable-diffusion-webui\modules\call_queue.py", line 37, in f
res = func(*args, **kwargs)
TypeError: txt2img() missing 3 required positional arguments: 'hr_negative_prompt', 'override_settings_texts', and 'request'


auto-sd-paint-ext:WARNING: Interrupted!
WARNING:auto-sd-paint-ext:Interrupted!

@Miraihi
Copy link
Author

Miraihi commented Aug 2, 2023

@DrCyanide Thanks for a really good hint, I was wondering what I can do myself about that!
Unfortunately, I still can't figure out the value for the "request" argument.

Getting such error

*** Error completing request
*** Arguments: ('', 4, 'flawless, highly detailed, high resolution, sharp focus, 4k, vivid colors, best quality, perfect lighting, trending on artstation', 'Negative_ng_deepnegative_v1_75t, Negative_badhandv4, (extra fingers, deformed hands:1.15), (worst quality, low quality, poor quality, bad quality:1.35), logo, watermark, text', 'None', <PIL.PngImagePlugin.PngImageFile image mode=RGBA size=583x424 at 0x141F24995D0>, None, None, None, None, <PIL.PngImagePlugin.PngImageFile image mode=RGBA size=583x424 at 0x141F24995D0>, <PIL.Image.Image image mode=L size=583x424 at 0x141F249B400>, 20, 2, 0, None, 1, False, False, 1, 1, 10.0, 0, 0.4, -1, -1, 0.0, 0, 0, False, 1, 512, 704, 1.0, 1, False, 0, False, '', '', '', [], '', '', 1, 0) {}
    Traceback (most recent call last):
      File "E:\AI\stable-diffusion-webui-directml\modules\call_queue.py", line 58, in f
        res = list(func(*args, **kwargs))
      File "E:\AI\stable-diffusion-webui-directml\modules\call_queue.py", line 37, in f
        res = func(*args, **kwargs)
      File "E:\AI\stable-diffusion-webui-directml\modules\img2img.py", line 214, in img2img
        p.user = request.username
    AttributeError: 'int' object has no attribute 'username'

---
auto-sd-paint-ext:WARNING: Interrupted!

What I did exactly is wedged


        "", # img2img_batch_png_info_props
        "", # img2img_batch_png_info_dir
        req.username, # request

between [], # override_settings_texts (unsupported) and *args,.

In img2img.py the "request" argument looks like that:
...request: gr.Request, *args):

I tried just putting "gr.Request" as a string like "gr.Request", # request but it still doesn't work, as well as leaving the quotes empty.

@DrCyanide
Copy link

Have you tried passing None in for the request? I know many months ago I was using A1111 with Gradio auth, but the API requests that auto-sd-paint-ext made didn't need any username or password. It's possible they've changed it, but try the easiest thing first.

@Miraihi
Copy link
Author

Miraihi commented Aug 2, 2023

@DrCyanide None produces the same error unfortunately. Switching to vladmandic (SD.Next) is also the option, but it updates way too often so that's not too optimal as I see it.

@DrCyanide
Copy link

@DrCyanide None produces the same error unfortunately.

None gives you an error that says 'int' object has no attribute 'username'? Where else did you add a .username then?

@Miraihi
Copy link
Author

Miraihi commented Aug 2, 2023

Yes, exactly the same error that traces back to modules\img2img.py", line 214
p.user = request.username. I didn't modify anything except app.py.

@DrCyanide
Copy link

Have you restarted A1111 after saving your changes to app.py? Because the only way you should be able to get that error is if you skipped that last step, and A1111 is using the cached version of app.py.

@Miraihi
Copy link
Author

Miraihi commented Aug 2, 2023

I restart it properly after each change.

@DrCyanide
Copy link

I restart it properly after each change.

What's "properly" in this case? Through the UI? I don't know if that does a full restart. Try killing it in the command line and starting it up from scratch.

@Miraihi
Copy link
Author

Miraihi commented Aug 2, 2023

"Properly" means pressing ctrl+c on cmd window and closing it. Look, I wouldn't come that far without knowing such basic things.

@DrCyanide
Copy link

Just needed to make sure.
In that case, double check the entire list of parameters in app.py. When I first started trying to fix this I was just adding the one parameter that the error message gave, without realizing there were duds left earlier in the line. My guess is you forgot to remove the no longer supported parameters (not to be confused with app.py's "unused" parameters), and it's causing an offset issue (which explains why it thinks you've got an int where you put a None).

As a longer term fix, I think it might be possible to name each parameter that's passed in (example: (id_task="", init_img=image, ...) to make it easier to maintain. No longer supported arguments would so up with an error unexpected keyword argument 'old_dead_param', and missing params would show up as missing 1 required positional argument: 'new_param'.

@Miraihi
Copy link
Author

Miraihi commented Aug 2, 2023

@DrCyanide There has actually been the offset issue (I didn't put one argument that sd-auto wasn't complaining about). But the error stays pretty much the same, with the minor changes

*** Error completing request
*** Arguments: ('', 4, 'flawless, highly detailed, high resolution, sharp focus, 4k, vivid colors, best quality, perfect lighting, trending on artstation', 'Negative_ng_deepnegative_v1_75t, Negative_badhandv4, (extra fingers, deformed hands:1.15), (worst quality, low quality, poor quality, bad quality:1.35), logo, watermark, text', 'None', <PIL.PngImagePlugin.PngImageFile image mode=RGBA size=516x301 at 0x2AB30EBBF70>, None, None, None, None, <PIL.PngImagePlugin.PngImageFile image mode=RGBA size=516x301 at 0x2AB30EBBF70>, <PIL.Image.Image image mode=L size=516x301 at 0x2AB30EBB2E0>, 20, 2, 0, None, 1, False, False, 1, 1, 10.0, 0, 0.4, -1, -1, 0.0, 0, 0, False, 1, 448, 768, 1.0, 1, False, 0, False, '', '', '', [], False, [], '', None, 0) {}
    Traceback (most recent call last):
      File "E:\AI\stable-diffusion-webui-directml\modules\call_queue.py", line 58, in f
        res = list(func(*args, **kwargs))
      File "E:\AI\stable-diffusion-webui-directml\modules\call_queue.py", line 37, in f
        res = func(*args, **kwargs)
      File "E:\AI\stable-diffusion-webui-directml\modules\img2img.py", line 214, in img2img
        p.user = request.username
    AttributeError: 'NoneType' object has no attribute 'username'

---
auto-sd-paint-ext:WARNING: Interrupted!

It's still a mystery how to get around that "username".

Right now the last few lines of img2img section of my app.py look like that

        [],  # override_settings_texts (unsupported)
        False,  # img2img_batch_use_png_info
        [],  # img2img_batch_png_info_props
        "",  # img2img_batch_png_info_dir
        None,  # request
        *args,

@DrCyanide
Copy link

Well, that's progress at least!

There's built-in API documentation for A1111 that might explain how to populate the request parameter correctly. This wiki link doesn't have a screenshot of the current version, but if you follow the steps (and the built-in version is updated) then it might be the last step you need.

https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/API

@Miraihi
Copy link
Author

Miraihi commented Aug 2, 2023

Well, I tried. But it's time to realize I'm not good enough to really fix it myself, so for the time being I'll be using Photoshop extension that seems to be working just fine.

@DrCyanide
Copy link

I know you said you're done with it, but I have one last idea to try if you (or someone else reading this down the road) is willing to try it.

Just doing a quick search of the code, it looks like request is only a parameter so it can pass request.username into another variable p.user, which in turn gets processed by either the txt2img or img2img. The only place that .user variable is used seems to be in modules\processing.py if you've set an option to add the username to the info. In other words, it's not for security, and it's barely used at all.

Since it's basically unused, this could make for an easy fix for A1111 users. Add import gradio as gr to the top with the imports, then a simple gr.Request() in your parameters where the request param shows up.

@bakasephi
Copy link

bakasephi commented Aug 3, 2023

hi !
I also have the exact same problem and tried to slove but i couldn't, I am also too bad to fix it (ended up with a few more error for gr and user.img2img). Just wanted to say thx for trying to help !

@Ripsomeone
Copy link

I have follow along posts and i got it to work in the end.

first i added the gradio to the import in app.py

from __future__ import annotations

import logging
import os
import time
import gradio as gr #added by user

and after that i go down past output = wrap_gradio_gpu_call(modules.img2img.img2img)
to add the new args

        [],  # override_settings_texts (unsupported)
		False,	# img2img_batch_use_png_info (added by user)
		[],	# img2img_batch_png_info_props (added by user)
		"",	# img2img_batch_png_info_dir (added by user)
		gr.Request(),	# request (added by user)
        *args,

@DrCyanide and @Miraihi thanks for the post it was really helpfull

@Fhalo48
Copy link

Fhalo48 commented Aug 3, 2023

Hi

Great!! It works to img2img, any syggestions for txt2img?

@bakasephi
Copy link

bakasephi commented Aug 3, 2023

Oh yep its working ! Thx !
And for txt2img I added the same lines in output = wrap_gradio_gpu_call(modules.txt2img.txt2img) in app.py and its working for me.

@Fhalo48
Copy link

Fhalo48 commented Aug 3, 2023

I;ll try again for txt2img

@Fhalo48
Copy link

Fhalo48 commented Aug 3, 2023

In my case I'm getting following err:
hr_sampler_name=sd_samplers.samplers_for_img2img[hr_sampler_index - 1].name if hr_sampler_index != 0 else None,
TypeError: unsupported operand type(s) for -: 'list' and 'int'

my code layout

        req.orig_width,  # hr_resize_x
        req.orig_height,  # hr_resize_y
        [],  # override_settings_texts (unsupported)
            False,	# img2img_batch_use_png_info (added by user)
            [],	# img2img_batch_png_info_props (added by user)
            "",	# img2img_batch_png_info_dir (added by user)
            gr.Request(),	# request (added by user)
        *args,

@bakasephi
Copy link

bakasephi commented Aug 3, 2023

Oh I cheked the wrong lines (sry very tired) you need to replace the arg that gives you errors, for me it was 'hr_prompt', 'hr_negative_prompt', 'override_settings_texts', and 'request'
And adapt the code from ripsomeone to thoses new arg and to txt2img instead to img2img
For me it works but i still have one error showing so maybe wait for better. (mine might be a fluke since even without fix txt2img was working but with a lot of errors). Anyway too tired to think i'll recheck later with a normal brain.
So waiting for someone else might be better

@Ripsomeone
Copy link

@Fhalo48 hey here is the fix i use for txt2img

add after output = wrap_gradio_gpu_call(modules.txt2img.txt2img)

        req.orig_width,  # hr_resize_x
        req.orig_height,  # hr_resize_y
		0,	#hr_sampler_index (added by user)
		[],	#hr_prompt (added by user)
		[],	#hr_negative_prompt (added by user)
        [],  # override_settings_texts (unsupported)
		gr.Request(),	# request (added by user)
        *args,

@poipoi300
Copy link

Wow, if only I had found the discussion here before fixing it...

@Miraihi
Copy link
Author

Miraihi commented Aug 3, 2023

@DrCyanide Thanks for all the help and solution seeking.
@poipoi300 Thank you, your fork works just fine

@Fhalo48
Copy link

Fhalo48 commented Aug 3, 2023

@Ripsomeone , you are a star.

That works, thank you and everyone else/

@poipoi300
Copy link

@Miraihi It's likely to break in the future again unfortunately. Not even mentioning the random new positional arguments that can be added. For the request object, I'm passing the internal pydantic request objects that I added a "username" field to. It seems like txt2img and img2img are accessing the passed "gradio" request with a generic property accessor, so if they keep doing that it should be as simple as just adding new fields in the pydantic models at least.

I'm considering picking this up since interpause has been inactive for a while, and there is at least one QoL thing I want implemented.

@Fhalo48
Copy link

Fhalo48 commented Aug 3, 2023

Hi

Spoken to soon :(

Could some check if the following code is correct fro img2img
req.resize_mode, # resize_mode False, # req.inpaint_full_res, # inpaint_full_res 0, # req.inpaint_full_res_padding, # inpaint_full_res_padding req.invert_mask, # inpainting_mask_invert "", # img2img_batch_input_dir (unspported) "", # img2img_batch_output_dir (unsupported) "", # img2img_batch_inpaint_mask_dir (unsupported) [], # override_settings_texts (unsupported) False, # img2img_batch_use_png_info (added by user) [], # img2img_batch_png_info_props (added by user) "", # img2img_batch_png_info_dir (added by user) gr.Request(), # request (added by user) *args,

@poipoi300
Copy link

@Fhalo48 Try my fork.

@iDumle
Copy link

iDumle commented Aug 3, 2023

@Fhalo48 Have you tried using the fix that @poipoi300 posted a pull request for.
https://github.com/poipoi300/auto-sd-krita-ext-xl

@DrCyanide
Copy link

The next question will be how do we handle the different parameters between A1111 and Vlad's SD.Next? I don't think it's worth forking over (since it's only a few lines that are different), but we need an elegant solution that provides what each API needs.

A dictionary of kwargs could work, but we need a way to identify which project the extension is being called from.

@Fhalo48
Copy link

Fhalo48 commented Aug 3, 2023

Thanks again. I'll try the fork/

@Fhalo48
Copy link

Fhalo48 commented Aug 3, 2023

@thanks again pyhon, experts. The fork works

:)

@poipoi300
Copy link

poipoi300 commented Aug 3, 2023

@DrCyanide Not familiar with Vlad's webUI at all. Is it just calling the txt2img/img2img that needs to be different? I feel either the user could select which UI they're using or the backend just polls the backend for the info. I imagine there are many different identifiable things on the API.

Edit for clarity:
I meant the extension backend polling the webUI backend, lol.

@poipoi300
Copy link

@Fhalo48 🤣 I wish recruiters regarded me as an "expert". Glad to help though.

@DrCyanide
Copy link

@DrCyanide Not familiar with Vlad's webUI at all. Is it just calling the txt2img/img2img that needs to be different? I feel either the user could select which UI they're using or the backend just polls the backend for the info. I imagine there are many different identifiable things on the API.

I don't know how much is different right off (not at my PC), but I know at the very least that Vlad's doesn't have the request parameter.

@DrCyanide
Copy link

Here's the current differences between Vlads and A1111's

Img2Img:

Vlads ADDS
latent_index: int, diffusers_guidance_rescale: float, refiner_start: float, clip_skip: int, img2img_batch_files: list
Vlads REMVOES
seed_enable_extras: bool, img2img_batch_use_png_info: bool, img2img_batch_png_info_props: list, img2img_batch_png_info_dir: str, request: gr.Request

Txt2Img:

Vlads ADDS
latent_index: int, image_cfg_scale: float, diffusers_guidance_rescale: float, clip_skip: int, refiner_start: int, refiner_prompt: str, refiner_negative: str
Vlads REMOVES
seed_enabled_extras: bool, hr_sampler_index: int, hr_prompt: str, hr_negative_prompt, request: gr.Request

So 10-12 keyword arguments change between calling one endpoint and calling the other.

@XenHunt
Copy link

XenHunt commented Aug 3, 2023

Thank you everybody for your work, now it is alive, although it has some problems with other extensions (control net, segment anything and so on), but it is not big problem, as I can finally generate and edit pictures again with more precision than original webui. Thank you everybody again.

@poipoi300
Copy link

@DrCyanide Maybe worth checking then. Ideally it would support everything, but it's never that simple of course. A1111, Vlad, Comfy, Invoke and more lol. I have some experience building these kinds of pipelines, but I'm not well-versed in the current codebase at all, so I can't guarantee anything on that front or even in general lol. I think a rewrite to use the A1111 API would be a good start.

@XenHunt What kind of problems? Mine has been spitting errors for nearly every extension present but that was the case since the start. The fact that the code is essentially hijacking functions might have something to do with that. I am definitely interested in fixing that as well since it's been bugging me.

BTW this discussion section is getting pretty off-topic now. I'm going to work on adding the stuff I'm interested in to my fork for now, and issues like #158 would definitely get taken care of quickly as I use this extension myself every day. I would look at PRs too. For anything else, no guarantees.

@XenHunt
Copy link

XenHunt commented Aug 4, 2023

@poipoi300 yeah, it is just spitting errors as you say, not something big, and I wanted to fix it too (for control net especially as it will empower krita really great), but I am not master of python (I am noob) and so on, so it will be hard. Good luck with your fork!

@DrCyanide DrCyanide linked a pull request Aug 25, 2023 that will close this issue
@DrCyanide
Copy link

I've put in a pull request that should make this kind of error never show up again - or at least be drastically faster to fix!

It programmatically checks what parameters the backend wants (thanks to Python's inspect module) and provides only those parameters from a dictionary. If a parameter name isn't known, it checks what datatype is expected and guesses at a default - which should result in the plugin getting usable images back even if the backend adds new functionality. It also adds warnings to the console log if there are missing parameters, telling the user what datatype they are and where their local directory for app.py is - all of which I hope makes it easier for users to fix problems.

And as a result of all of that, my pull request is A1111 and SD.Next compatible, and should have some forwards and backwards compatibility! A new copy of the extension will work with an older copy of the UI, and a newer copy of the UI will work with this version of the extension.

I really hope it gets pulled, because it would be a massive help for maintenance.

@poipoi300
Copy link

poipoi300 commented Aug 25, 2023

@DrCyanide Mind doing a PR on my fork for that? I don't agree with all the changes and just reading the code I see that a bug which was fixed on my fork has been reintroduced, but other than that it looks good if it works.

Edit: Mostly don't agree with the verbosity and specificity of the added text in the README. The goal of the readme is not to inform users how the code works or how it has been changed.

@Miraihi
Copy link
Author

Miraihi commented Sep 14, 2023

Hate to resurrect that thread after all the work you've done guys, but the extension fork by DrCyanide and poipoi300 only works up to Automatic version 1.5.2 and breaks again at 1.6.0. Seems like the new implementation is still not robust enough. Also doesn't work correctly for the latest commits of SD Next, at least for me.
But it's not that big of a deal since can just stay at 1.5.2 and keep my usual workflow.

@DrCyanide
Copy link

Making some early notes for anyone else trying to figure this out (looking at you, @poipoi300 )

SD.Next's issue comes from some value passed to Krita that the Krita frontend doesn't handle well. I believe these are related to the SD Scripts, but I haven't tracked down exactly what/why is breaking. The terminal looks clean, which means the plugin didn't get far enough along to actually ask SD.Next to do anything. The parameters fix might still be working here, but the frontend needs some attention before we can find out.


A1111 broke the one assumption I made: that the backend would work with it's own default values.
A1111 is crashing on a default value it picks if it can't find a certain key. It's in modules/options.py, lines 90 and 91. 90 sets the value of info to None, then line 91 doesn't check if info is None, it just tries to use it anyway.

Changing line 91 to be if info == None or info.do_not_save: gets further, but it still crashes. That *args that is at the end of txt2img and img2img parameters? Looks like A1111 changed what it expects there. In this extension, those *args have been handled by backend\script_hack.py. I can't automate a system to check for what parameters it expects there, so fixes for changes like this will have to be completely manual.


Personally, I want to see ControlNet integrated into a Krita plugin that I can use with SD.Next or A1111. The only way I see that happening is by switching from our lovely little hacking to using the API. Since that will basically be a full re-write of the app (since the SD.Next issues are on the frontend anyway), I think my hobby dev time would be better spent trying to make a new Krita plugin to accomplish that goal.

@poipoi300
Copy link

@Miraihi Check my fork directly. I updated it to be working with 1.6.0 2 days ago. Could've been a lot earlier if I had kept on top of the versions or didn't assume an issue to be caused by something else 😅

I'm also not really testing SD.Next at all, its support is(was?) pretty much a miracle thanks to @DrCyanide lmao. Speaking of, did you try my fork on SD.Next? Because the issues with A1111 were also on the frontend. If we're lucky it was the same exact issue and I fixed both.

Also would like to see ControlNet added to krita. Being able to edit openpose/depth map/whatever straight in krita seems really powerful. Someone left a comment on one of my fork's issues saying they were working towards merging our recent fixes with the controlnet fork. I thnk they were referencing this one? It hasn't been worked on in 2 months it looks like, but most of the code is probably still fine and the author even said the ControlNet part used the official API.

Unfortunately, past making sure my fork works, I don't have much time for this. Most of my already little free time is spent working on images rather than coding. If I somehow 5x my speed at making images, then the time saved can go into coding 😂

@Miraihi
Copy link
Author

Miraihi commented Sep 15, 2023

@poipoi300 Thanks, I see it now. I haven't realized that you have the entire fork unassociated with a pull request. It seems to work fine.
But no, it doesn't work with SD.Next. It still crashes on 25% progress.

@DrCyanide
Copy link

DrCyanide commented Sep 15, 2023

FYI, SD.Next just pushed out an update that seems to have fixed my version of the extension for txt2img and img2img (they sanitized some bad script-info data in the API). And my robustness changes worked!

image

That parameter refiner_steps would have completely broken the old version of this app, requiring all the manual checks outlined earlier. By guessing a default value, the image was allowed to complete and Krita worked like normal. Yes, the terminal has A TON of errors from various scripts that were expecting additional data in the *args, but as long as you can use the plugin to make art who cares!

Since @poipoi300 copied the robustness changes to his code, I'm guessing his version should work on the latest SD.Next as well now.

(Also, I've started work on a new Krita plugin using the API. I was able to get txt2img to work via API on the command line, so now the challenge is the Krita specific stuff)

@poipoi300
Copy link

Unfortunately I needed to stop using the internal txt2img and img2img functions because they no longer take in a seed as parameter. I had to sidestep them to get seeds working again. I kept the main idea of your robustness change, but it's mostly removed because it's not applicable to the way it works now. It's a dataclass where all fields have defaults instead of a func, so I just fill whatever params we do have into the dataclass.

Unfortunately this also broke SD.Next support. It may be possible to get it back, as images are still being generated through the extension and it's very close to giving back the image to the frontend when it does raise an exception. Just that right now it doesn't work anymore. Will look into SD.Next support next weekend.

On the bright side, I think doing it this way may make it easier to suppress those pesky errors and get scripts working again.

@DrCyanide
Copy link

DrCyanide commented Sep 29, 2023

(Also, I've started work on a new Krita plugin using the API. I was able to get txt2img to work via API on the command line, so now the challenge is the Krita specific stuff)

As a follow-up to my previous post, I've uploaded the first working version of my API based plugin. I've tested it and it works with both A1111 and SD.Next.

https://github.com/DrCyanide/cyanic-sd-krita

This will be the only time I bring up my plugin here. I only do so because the conversation about fixing this plugin is what pushed me into developing it, so I figure the people here would be the most interested in it at this point.

I consider this to be in a "Usable Alpha" state. I think I've made some usability improvements over auto-sd-paint-ext (beyond just "does it work?"), such as preview images being displayed in canvas, support for Styles that a user has defined in the WebUI, more compact layout, etc.

I'm trying to add the features I use in Stable Diffusion the most first. This means that things like ControlNet and After Detailer will likely be added before things like Upscaling, CFG scale, or Face Restore. Some things (like Scripts) I don't plan to add anytime soon, and may not be added at all.

Edit: Inpainting and ControlNet now included.

@rexelbartolome
Copy link

rexelbartolome commented Sep 29, 2023

@DrCyanide your fork looks promising too! Thanks for sharing, I'll try testing it out soon :)

@Miraihi
Copy link
Author

Miraihi commented Sep 29, 2023

Great job, @DrCyanide! I desperately need the inpainting feature, but as soon as you implement that I'll be switching for good.

@DrCyanide
Copy link

Great job, @DrCyanide! I desperately need the inpainting feature, but as soon as you implement that I'll be switching for good.

Inpaint is added now (as well as ControlNet). Please leave issues with any bugs you find in it on my project's page - I'm sure there's a lot of stuff I don't have hooked up right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
9 participants