Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input image and mask image size ? #45

Open
kkbandaru opened this issue Aug 23, 2023 · 2 comments
Open

Input image and mask image size ? #45

kkbandaru opened this issue Aug 23, 2023 · 2 comments

Comments

@kkbandaru
Copy link

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

@prathameshparit
Copy link

prathameshparit commented Sep 10, 2023

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

@Alex-McAvoy
Copy link

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."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants