Paint-by-Example icon indicating copy to clipboard operation
Paint-by-Example copied to clipboard

Input image and mask image size ?

Open kkbandaru opened this issue 2 years ago • 2 comments

Why the input images are 512 x 512, can i give any image of any size

kkbandaru avatar Aug 23 '23 14:08 kkbandaru

def image_resizer(image_p):
    image = Image.open(image_path)
    width, height = image.size
    new_width = (width // 8) * 8
    new_height = (height // 8) * 8
    
    if new_width != width or new_height != height:
        image = image.resize((new_width, new_height))
    image = image.convert("RGB")
    return image

image = image_resizer(image_path)
mask_image = image_resizer(mask_img_path)
example_image = image_resizer(example_image_path)

I revised the code this way and it worked for me

prathameshparit avatar Sep 10 '23 07:09 prathameshparit

def image_resizer(image_p):
    image = Image.open(image_path)
    width, height = image.size
    new_width = (width // 8) * 8
    new_height = (height // 8) * 8
    
    if new_width != width or new_height != height:
        image = image.resize((new_width, new_height))
    image = image.convert("RGB")
    return image

image = image_resizer(image_path)
mask_image = image_resizer(mask_img_path)
example_image = image_resizer(example_image_path)

I revised the code this way and it worked for me

Can you provide me the full code for my reference?The size of my picture is 681*1024, and after I modify it with your code, it still gives the error "RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 44 but got size 43 for tensor number 1 in the list."

Alex-McAvoy avatar Apr 30 '24 15:04 Alex-McAvoy