Closed LEv145 closed 3 weeks ago
I tested this in Forge - the button logic is now working without any errors.
There is a problem though - once clicked, the icon vanishes and does not ever restore.
Unclicked:
Clicked once:
Clicked again:
I understand, I'll have to recreate the buttons
This makes the whole button disappear when clicked XD
In my version, I actually change the button value (icon string) when clicked (not the gradio variant attribute for primary/secondary), which is why I change the "value" of the button when clicked.
I think you were close originally but the function was trying to update the value in addition to the variant?
Oops, I think I made a little mistake in the line :D https://github.com/LEv145/--sd-webui-ar-plus/commit/3199e772b27be1950eb4c2e9297c3a0823478763 https://github.com/LEv145/--sd-webui-ar-plus/commit/00b7978f8425135427f200476e98590127ce7758
The problem here is that the .update()
method is deprecated and broken in Gradio 4, so I'm recreating object as the developer advises:
https://github.com/gradio-app/gradio/issues/6339
Removes the deprecated
.update()
method from component classes. Instead, you can now just return an instance of a component from your function. I.e. returngr.Textbox(lines=4)
instead ofgr.Textbox.update(lines=4)
But gr.update
seems to still work
https://github.com/altoiddealer/--sd-webui-ar-plusplus/blob/8b900cd2748f95bce455db62ba0cb08093a3ca59/scripts/sd-webui-ar-plusplus.py#L439
The SD WebUI guys don't just import gradio and call it a day - they have all sorts of patches and stuff that I can't comprehend, which probably convert a lot of bad code into good code. It's very likely that there's something in there fixing the gr.update
I can't claim to understand that code well, I definitely relied hard on your code / ChatGPT.
The new commit is working in Forge... but unfortunately, that button is erroring in A1111
File "D:\0_AI\stable-diffusion-webui\venv\lib\site-packages\fastapi\encoders.py", line 148, in jsonable_encoder
if isinstance(obj, classes_tuple):
File "C:\Users\RandallSu\AppData\Local\Programs\Python\Python310\lib\abc.py", line 119, in __instancecheck__
return _abc_instancecheck(cls, instance)
RecursionError: maximum recursion depth exceeded in comparison
Okay, then it makes sense to use gr.update
In theory it should work
https://github.com/LEv145/--sd-webui-ar-plus/commit/670146696391617f922559addb64f30167d79a5b
I think in Gradio 4
they left the option to use gr.update
But, unfortunately, they did not write how to simply switch from Gradio 3
to Gradio 4
Good news! It's now working in A111 and Forge :)
Thanks again for coming up with the solution to our main problem, it was driving me insane!
Error
Possible solution
https://www.gradio.app/docs/gradio/state