Closed sould3mon closed 2 years ago
for full disclosure. i did just copy the venv from the stable-diffusion-webui directory. tested it in powershell with torch.cuda.is_available() and typed python launch.py
The error occurs when the selection box has an extremely large aspect ratio, causing the zero division in the logic that attempts to round it to a stride of 64. https://github.com/Interpause/auto-sd-krita/commit/0a86677e86fa7a3cc5f2114ee63c0ef0495502b5 should workaround the issue but result in the box being inaccurate for weird selections.
Check if your base size/max size are sensible, i.e. 512 and 768 respectively. The plugin scales the selection box to have one dimension match base size if possible, the other be under max size, and the dimensions being a stride of 64.
mask issue got fixed 💯. but this one still persists for me for all types of selections held shift while selecting tried larger /smaller then base size
tried: on large image with various selection sizes around the base size new 512x512 image and 128x128 selection box made sure only 1 selection box was present when having multiple documents open
settings are default (512, 768)
error changed to: 282 def try_fix_aspect_ratio(self): width = 64 height = 0
edit: inpaint works fine if i just deselect everything though and have mask layer active
---full error--- ZeroDivisionError Python 3.8.1: F:\Apps\Krita (x64)\bin\krita.exe Sun Oct 9 12:28:23 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\Admin\AppData\Roaming\krita\pykrita\krita_diff\script.py in cb()
476 def cb():
477 self.update_config()
478 self.try_fix_aspect_ratio()
479 self.apply_img2img(mode=1)
480 self.set_status(STATE_INPAINT)
self =
C:\Users\Admin\AppData\Roaming\krita\pykrita\krita_diff\script.py in try_fix_aspect_ratio(self=
C:\Users\Admin\AppData\Roaming\krita\pykrita\krita_diff\script.py in find_final_aspect_ratio(self=
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\Admin\AppData\Roaming\krita\pykrita\krita_diff\script.py", line 478, in cb self.try_fix_aspect_ratio() File "C:\Users\Admin\AppData\Roaming\krita\pykrita\krita_diff\script.py", line 288, in try_fix_aspect_ratio final_ratio = self.find_final_aspect_ratio() File "C:\Users\Admin\AppData\Roaming\krita\pykrita\krita_diff\script.py", line 280, in find_final_aspect_ratio return width / height ZeroDivisionError: division by zero
Did you replace the existing krita_diff
folder in the pykrita
folder after updating the code? Part of the workaround was just ignoring the selection box if the width/height was less than 1.
That said, based on what you tried, it seems very weird the selection height would be 0. Could you send some screenshots of what you are doing so I can try to reproduce the error? Thanks
yes i did forget that at first though. also tried disabling plugin restart enable restart for good measure and restart of the server.
i am uploading a short video since i think that be more usefull then couple screenshots www.youtube.com/watch?v=5UEyQmN5dRs
@Interpause video is should be up in hd now showing various actions that with selection present it fails show that the mask problem is fixed so it's running the updated code and lines in the error changed with +8 wich matches the commit amount
just tried settings>reset all settings but no change
now with an non equal selection box i get a diffrent error i din't notice
also tried adjusting you script to run parts of selection in scripter window so far i got to where line 280 returns
` ...
ans = width / height print(ans,width,height) ` ---output--- 204 202 1.0 512 512
--error with selection differing by 2 pixels same as below except ratio value--
delta_rev undefined
builtinabs =
--new error with large difference in ratio-- ZeroDivisionError Python 3.8.1: F:\Apps\Krita (x64)\bin\krita.exe Sun Oct 9 19:27:46 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\Admin\AppData\Roaming\krita\pykrita\krita_diff\script.py in cb()
439 def cb():
440 self.update_config()
441 self.try_fix_aspect_ratio()
442 self.apply_txt2img()
443 self.create_mask_layer_workaround()
self =
C:\Users\Admin\AppData\Roaming\krita\pykrita\krita_diff\script.py in try_fix_aspect_ratio(self=
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\Admin\AppData\Roaming\krita\pykrita\krita_diff\script.py", line 441, in cb self.try_fix_aspect_ratio() File "C:\Users\Admin\AppData\Roaming\krita\pykrita\krita_diff\script.py", line 291, in try_fix_aspect_ratio delta_rev = abs(1 / final_ratio - 1 / ratio) ZeroDivisionError: float division by zero
oh crap i noticed what was wrong. sh*t the plugin wouldn't have worked for any new user.
Okay so if you're curious. The original plugin set the model base size
and max size
per tab. However, I decided that the setting should be shared amongst all tabs. However, I seem to have failed to rename one of them. So on completely new installs, the config value wouldn't exist, but surprisingly returns 0 instead of erroring out. Anyways, I verified that all access to the settings actually exist now so it should not happen.
I was so close to thinking this was just a problem with your computer lol. I probably should have tried installing in a virtual machine or something.
Hopefully, the number of people who gave up on using this plugin because of this bug is less than 1...
so far everything seem to be working. oof that's a nasty type of bug to track down.
i think the biggest hurdle for the plugin is getting a duplicate setup for stable diffusion wich is is a 6gb install but i think it's worth it.
would be sad if after all that people are still to lazy to drop a bug report
I don't actually duplicate the setup. For me, if I want to use new features of AUTO's webui, I gotta update this repo lol.
Also it aint a 6GB install if you symlink all the models and use the same venv for both.
Maybe I should write an installation guide based on the assumption they already have AUTO's fork. For example, they could use the same venv/conda env, or simply patch AUTO's fork with the changes in my fork.
that would be a nice option i just copied the venv and symlinked models since i din't want to mess with the working copy. and on windows at least seems to fine. din't have to mess with the copy of venv at all, used to be that it would break stuff.
when selection is present everything breaks txt2img img2img etc without it it works like you showed on youtube.
version 5.1.1 (updated from 5.0.2 to see if it was because of outdated version) to produce i just need to have any selection present and cllick start. error:
---start of paste--- ZeroDivisionError Python 3.8.1: F:\Apps\Krita (x64)\bin\krita.exe Sat Oct 8 23:31:46 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\Admin\AppData\Roaming\krita\pykrita\krita_diff\script.py in cb() 468 def cb(): 469 self.update_config() 470 self.try_fix_aspect_ratio() 471 self.apply_img2img(mode=1) 472 self.set_status(STATE_INPAINT) self =
self.try_fix_aspect_ratio = <bound method Script.try_fix_aspect_ratio of >
C:\Users\Admin\AppData\Roaming\krita\pykrita\krita_diff\script.py in try_fix_aspect_ratio(self=)
278 if self.selection is not None and self.cfg("fix_aspect_ratio", bool):
279 ratio = self.width / self.height
280 final_ratio = self.find_final_aspect_ratio()
281
282 delta = abs(final_ratio - ratio)
final_ratio undefined
self =
self.find_final_aspect_ratio = <bound method Script.find_final_aspect_ratio of >
C:\Users\Admin\AppData\Roaming\krita\pykrita\krita_diff\script.py in find_final_aspect_ratio(self=)
270 width, height = rnd(ratio, max_size), max_size
271
272 return width / height
273
274 def try_fix_aspect_ratio(self):
width = 0
height = 0
ZeroDivisionError: division by zero
cause = None
class = <class 'ZeroDivisionError'>
context = None
delattr = <method-wrapper 'delattr' of ZeroDivisionError object>
dict = {}
dir =
doc = 'Second argument to a division or modulo operation was zero.'
eq = <method-wrapper 'eq' of ZeroDivisionError object>
format =
ge = <method-wrapper 'ge' of ZeroDivisionError object>
getattribute = <method-wrapper 'getattribute' of ZeroDivisionError object>
gt = <method-wrapper 'gt' of ZeroDivisionError object>
hash = <method-wrapper 'hash' of ZeroDivisionError object>
init = <method-wrapper 'init' of ZeroDivisionError object>
init_subclass = <built-in method init_subclass of type object>
le = <method-wrapper 'le' of ZeroDivisionError object>
lt = <method-wrapper 'lt' of ZeroDivisionError object>
ne = <method-wrapper 'ne' of ZeroDivisionError object>
new =
reduce =
reduce_ex = <built-in method reduce_ex of ZeroDivisionError object>
repr = <method-wrapper 'repr' of ZeroDivisionError object>
setattr = <method-wrapper 'setattr' of ZeroDivisionError object>
setstate =
sizeof =
str = <method-wrapper 'str' of ZeroDivisionError object>
subclasshook =
__suppress_context = False
traceback__ =
args = ('division by zero',)
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\Admin\AppData\Roaming\krita\pykrita\krita_diff\script.py", line 470, in cb self.try_fix_aspect_ratio() File "C:\Users\Admin\AppData\Roaming\krita\pykrita\krita_diff\script.py", line 280, in try_fix_aspect_ratio final_ratio = self.find_final_aspect_ratio() File "C:\Users\Admin\AppData\Roaming\krita\pykrita\krita_diff\script.py", line 272, in find_final_aspect_ratio return width / height ZeroDivisionError: division by zero
---end of paste---