DrCyanide / cyanic-sd-krita

A Stable Diffusion plugin for Krita, compatible with A1111 and SD.Next
68 stars 4 forks source link

controlNet models not showing for forge #30

Closed Hellrunner2k closed 4 months ago

Hellrunner2k commented 5 months ago

hello... just kicked off auto for forge and i noticed the cNet models are not showing up ... moved the models to the folder ... nothing halp ^^

image image

and this comes up when i select a preprocessor which are listed

KeyError Python 3.10.7: C:\Program Files\Krita (x64)\bin\krita.exe Fri Mar 22 18:57:55 2024

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\DicktatorF\AppData\Roaming\krita\pykrita\cyanic\extension_widgets\controlnet.py in () 138 self.preprocessor_select.setMaxVisibleItems(5) # Suppose to limit the number of visible options 139 # self.preprocessor_select.currentIndexChanged.connect(lambda: self.set_preprocessor_settings(self.preprocessor_select.currentText())) # ... This steps through EVERY index in between 140 self.preprocessor_select.currentTextChanged.connect(lambda: self.set_preprocessor_settings(self.preprocessor_select.currentText())) 141 control_type_row.layout().addRow('Preprocessor', self.preprocessor_select) 142 self = self.preprocessor_select = self.preprocessor_select.currentTextChanged = self.preprocessor_select.currentTextChanged.connect = self.set_preprocessor_settings = > self.preprocessor_select.currentText =

C:\Users\DicktatorF\AppData\Roaming\krita\pykrita\cyanic\extension_widgets\controlnet.py in set_preprocessor_settings(self=, preprocessor_name='softedge_pidinet') 398 self.preprocessor = preprocessor_name 399 400 details = self.cnapi.module_details[preprocessor_name] 401 self.model_select.setHidden(details['model_free']) 402 details undefined self = self.cnapi = self.cnapi.module_details = {} preprocessor_name = 'softedge_pidinet' KeyError: 'softedge_pidinet' cause = None class = <class 'KeyError'> context = None delattr = <method-wrapper 'delattr' of KeyError object> dict = {} dir = doc = 'Mapping key not found.' eq = <method-wrapper 'eq' of KeyError object> format = ge = <method-wrapper 'ge' of KeyError object> getattribute = <method-wrapper 'getattribute' of KeyError object> gt = <method-wrapper 'gt' of KeyError object> hash = <method-wrapper 'hash' of KeyError object> init = <method-wrapper 'init' of KeyError object> init_subclass = <built-in method init_subclass of type object> le = <method-wrapper 'le' of KeyError object> lt = <method-wrapper 'lt' of KeyError object> ne = <method-wrapper 'ne' of KeyError object> new = reduce = reduce_ex = <built-in method reduce_ex of KeyError object> repr = <method-wrapper 'repr' of KeyError object> setattr = <method-wrapper 'setattr' of KeyError object> setstate = sizeof = str = <method-wrapper 'str' of KeyError object> subclasshook = __suppress_context = False traceback__ = args = ('softedge_pidinet',) with_traceback =

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\DicktatorF\AppData\Roaming\krita\pykrita\cyanic\extension_widgets\controlnet.py", line 140, in self.preprocessor_select.currentTextChanged.connect(lambda: self.set_preprocessor_settings(self.preprocessor_select.currentText())) File "C:\Users\DicktatorF\AppData\Roaming\krita\pykrita\cyanic\extension_widgets\controlnet.py", line 400, in set_preprocessor_settings details = self.cnapi.module_details[preprocessor_name] KeyError: 'softedge_pidinet'

DrCyanide commented 5 months ago

I'll have to download Forge myself and test it. It is very odd that the ControlNet list should be empty unless it's not configured right in Forge. The ControlNet API is separate from the WebUI/SD.Next/Forge API, so that part shouldn't be an issue.

While I do that, can you paste the responses to these URLs? That should help me find out what's going on. localhost:7860/controlnet/version localhost:7860/controlnet/model_list?update=true localhost:7860/controlnet/module_list?alias_names=true

DrCyanide commented 5 months ago

Just got it installed, and while I don't have it set up to use my models yet I already see the problem - those URLs I use to get the ControlNet options are all non-functional, returning {"detail":"Not Found"}. This is odd, because the documentation page for the Forge ControlNet API seems like it should work, and also uses http://localhost:7860/controlnet/module_list

Because the documentation suggests that these API calls should be the same, my current guess is that this is a Forge Settings issue, and not Krita Plugin issue. I'll keep looking to see if I can find what setting needs to be changed to get it working.

DrCyanide commented 5 months ago

After a few times starting Forge up again, I got the model_list and module_list APIs to return, but I'm not sure how. I did edit the webui-user.bat file that Forge includes, which allowed it to see my A1111 installed models, hypernetworks, embeddings, and loras (but not my ControlNet). However, I don't think that is what did it, as when I commented those lines out again and restarted Forge it was still working.

As I dug into this, I'm more shocked that you even got ControlNet to show up in Krita at all. The API call that I use to check if ControlNet is installed was deleted from Forge, as were the the APIs to get Models, VAEs, Textual embeddings, and many, many others.

Cyanic-SD-Krita will not support Forge

It looks like they've removed too many of the /sdapi/v1/ API calls which this plugin was built around for it to be supported. It's possible that there's something odd with the stand-alone version I'm using that's causing APIs to start/stop working randomly, but that only makes me less confident that I can support it.

Hellrunner2k commented 5 months ago

i STRONGLY suggest that you rethink this approach ^^ .. the trend is moving away from auto... forge is just better.. it's the same but efficient and fast ... no one i know uses auto anymore ... maybe switch to forge native... and talk to the forge dude, maybe ... must be possible to get functionality back if it got thrown out without considering everything.. thank you for your service ... Krita is the future of SD... also come to the civitai discord if you like to get an ear to the ground

DrCyanide commented 5 months ago

I've made a ticket on Forge's issue tracker for it. - https://github.com/lllyasviel/stable-diffusion-webui-forge/issues/599

Here's a list of API calls that Cyanic SD Krita uses which do not seem to be present in Forge (you can check them at http://localhost:7860/docs):

When the only /sdapi/v1 endpoints that Forge seems to support are /sdapi/v1/loras and /sdapi/v1/refresh-loras then the only thing that work in Krita is listing your LoRAs. Looking at the example code in their Read Me, it's pretty clear that Forge was designed around supporting WebUI extensions, not completely separate programs that use the API. Maybe that's an oversight, or maybe it's been intentionally cut for performance improvements.

If anyone in your Discord server knows their way around the Forge API they're more than welcome to make the necessary changes to my sdapi_v1.py and submit a pull request. However I will not be pursuing it further unless I hear back from Forge.

It doesn't matter how popular Forge or ComfyUI or Fooocus or any other UI is. It matters if they're backwards compatible with the A1111 API. I'm fine making small changes and workarounds like I've done for SD.Next, but I won't be doing ground-up rewrites for other APIs.

Hellrunner2k commented 5 months ago

fair... I see what i can get

DrCyanide commented 5 months ago

Looks like Forge is back on the table! Their documentation (plus the FastAPI documentation page loading) made it seem like it did not need the --api commandline arg and behaved similar to SD.Next (which automatically activates the API). Adding that to my starting args gets an API that Cyanic SD Krita can interact with, and I successfully was able to pick my models and do Txt2Img tests.

Back to the initial problem, the ControlNet API is still a bit different than the A1111 and SD.Next versions. It doesn't have /controlnet/settings (which let me check how many ControlNet Units there are), nor does it have /controlnet/control_types (which tells which Models + Preprocessors go with which tab, like Canny or OpenPose).

I tried checking /sdapi/v1/options to see if the Units have been moved there, but I'm not seeing it. Defaulting to 1 ControlNet Unit for now.

To work around not having control_types, I'm re-creating the format and putting everything in the "All" category. It's messy, but it populates the dropdowns.

I don't have my ControlNet models linked yet, but I've pushed the change. Give it a test and see if it works for you.

Hellrunner2k commented 5 months ago

aye, sir... promptly

Hellrunner2k commented 5 months ago

yeeeii :D image

Good stuff, thank you so much ^^

preprocessor shenanigans still persists... but i can live without them for now :D

KeyError Python 3.10.7: C:\Program Files\Krita (x64)\bin\krita.exe Sun Mar 24 08:57:53 2024

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\DicktatorF\AppData\Roaming\krita\pykrita\cyanic\extension_widgets\controlnet.py in () 138 self.preprocessor_select.setMaxVisibleItems(5) # Suppose to limit the number of visible options 139 # self.preprocessor_select.currentIndexChanged.connect(lambda: self.set_preprocessor_settings(self.preprocessor_select.currentText())) # ... This steps through EVERY index in between 140 self.preprocessor_select.currentTextChanged.connect(lambda: self.set_preprocessor_settings(self.preprocessor_select.currentText())) 141 control_type_row.layout().addRow('Preprocessor', self.preprocessor_select) 142 self = self.preprocessor_select = self.preprocessor_select.currentTextChanged = self.preprocessor_select.currentTextChanged.connect = self.set_preprocessor_settings = > self.preprocessor_select.currentText =

C:\Users\DicktatorF\AppData\Roaming\krita\pykrita\cyanic\extension_widgets\controlnet.py in set_preprocessor_settings(self=, preprocessor_name='canny') 398 self.preprocessor = preprocessor_name 399 400 details = self.cnapi.module_details[preprocessor_name] 401 self.model_select.setHidden(details['model_free']) 402 details undefined self = self.cnapi = self.cnapi.module_details = {} preprocessor_name = 'canny' KeyError: 'canny' cause = None class = <class 'KeyError'> context = None delattr = <method-wrapper 'delattr' of KeyError object> dict = {} dir = doc = 'Mapping key not found.' eq = <method-wrapper 'eq' of KeyError object> format = ge = <method-wrapper 'ge' of KeyError object> getattribute = <method-wrapper 'getattribute' of KeyError object> gt = <method-wrapper 'gt' of KeyError object> hash = <method-wrapper 'hash' of KeyError object> init = <method-wrapper 'init' of KeyError object> init_subclass = <built-in method init_subclass of type object> le = <method-wrapper 'le' of KeyError object> lt = <method-wrapper 'lt' of KeyError object> ne = <method-wrapper 'ne' of KeyError object> new = reduce = reduce_ex = <built-in method reduce_ex of KeyError object> repr = <method-wrapper 'repr' of KeyError object> setattr = <method-wrapper 'setattr' of KeyError object> setstate = sizeof = str = <method-wrapper 'str' of KeyError object> subclasshook = __suppress_context = False traceback__ = args = ('canny',) with_traceback =

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\DicktatorF\AppData\Roaming\krita\pykrita\cyanic\extension_widgets\controlnet.py", line 140, in self.preprocessor_select.currentTextChanged.connect(lambda: self.set_preprocessor_settings(self.preprocessor_select.currentText())) File "C:\Users\DicktatorF\AppData\Roaming\krita\pykrita\cyanic\extension_widgets\controlnet.py", line 400, in set_preprocessor_settings details = self.cnapi.module_details[preprocessor_name] KeyError: 'canny'

image

DrCyanide commented 4 months ago

Please try pulling the latest version of the plugin, I believe this is fixed now. I've disabled some preprocessor options that Forge's API doesn't currently support, and I think it's stable now.