[GH-ISSUE #5] Occasional TypeError upon pressing the 1:1 button #5

Open
opened 2026-10-30 21:03:03 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @Technologicat on GitHub (Sep 1, 2024).
Original GitHub issue: https://github.com/altoiddealer/--sd-webui-ar-plusplus/issues/5

It sometimes happens that w and/or h are of type str, not int. Then trying to compute (w + h) / 2 raises a TypeError, and the image dimensions are not updated.

Unfortunately this only happens sometimes, and I haven't yet figured out exactly when. The last time this hit me, I was in the img2img tab.

What I do know, however, is that this can be fixed by introducing an explicit typecast, like this:

def avg_from_dims(w, h):
    w = int(w)
    h = int(h)
    avg = (w + h) // 2
    if (w + h) % 2 != 0:
        avg += 1
    return avg
Originally created by @Technologicat on GitHub (Sep 1, 2024). Original GitHub issue: https://github.com/altoiddealer/--sd-webui-ar-plusplus/issues/5 It sometimes happens that `w` and/or `h` are of type `str`, not `int`. Then trying to compute `(w + h) / 2` raises a `TypeError`, and the image dimensions are not updated. Unfortunately this only happens *sometimes*, and I haven't yet figured out exactly when. The last time this hit me, I was in the img2img tab. What I do know, however, is that this can be fixed by introducing an explicit typecast, like this: ```python def avg_from_dims(w, h): w = int(w) h = int(h) avg = (w + h) // 2 if (w + h) % 2 != 0: avg += 1 return avg ```
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
altoiddealer/--sd-webui-ar-plusplus#5
No description provided.