Bing-su / adetailer

Auto detecting, masking and inpainting with detection model.
GNU Affero General Public License v3.0
4.15k stars 317 forks source link

[Bug]: #732

Open rubberfashion opened 4 hours ago

rubberfashion commented 4 hours ago

Describe the bug

Error in using ADetailer with img2img

Steps to reproduce

SD.Next Version 2024-10-17 + ADetailer

I ran into an error using ADetailer in img2img with face and eyes.

Error AttributeError: module 'modules.images' has no attribute 'LANCZOS'

extensions/adetailer/scripts/!adetailer.py line 655

function:

@staticmethod def inpaint_mask_filter( img2img_mask: Image.Image, ad_mask: list[Image.Image] ) -> list[Image.Image]: if ad_mask and img2img_mask.size != ad_mask[0].size: img2img_mask = img2img_mask.resize(ad_mask[0].size, resample=images.LANCZOS) return [mask for mask in ad_mask if has_intersection(img2img_mask, mask)]

I changed to (solved my problem): @staticmethod def inpaint_mask_filter( img2img_mask: Image.Image, ad_mask: list[Image.Image] ) -> list[Image.Image]: if ad_mask and img2img_mask.size != ad_mask[0].size: img2img_mask = img2img_mask.resize(ad_mask[0].size, resample=Image.LANCZOS) return [mask for mask in ad_mask if has_intersection(img2img_mask, mask)]

Screenshots

-

Console logs, from start to end.

-

List of installed extensions

No response

dosubot[bot] commented 4 hours ago

@rubberfashion Hello there! I'm here to help you with any bugs, questions, or contributions. Let's work together to resolve any issues you encounter.

To resolve the AttributeError related to 'LANCZOS' in the ADetailer script, you need to ensure that the LANCZOS attribute is accessed from the correct module. The error occurs because LANCZOS is being accessed from modules.images instead of PIL.Image. You can fix this by changing the resample parameter in the inpaint_mask_filter function to use Image.LANCZOS:

@staticmethod
def inpaint_mask_filter(
    img2img_mask: Image.Image, ad_mask: list[Image.Image]
) -> list[Image.Image]:
    if ad_mask and img2img_mask.size != ad_mask[0].size:
        img2img_mask = img2img_mask.resize(ad_mask[0].size, resample=Image.LANCZOS)
    return [mask for mask in ad_mask if has_intersection(img2img_mask, mask)]

This change should resolve the error by correctly accessing the LANCZOS attribute from the PIL.Image module [1].

To continue talking to Dosu, mention @dosu.

rubberfashion commented 4 hours ago

Yes. this is exactly the problem, can you update the code please?