Fantasy-Studio / Paint-by-Example

Paint by Example: Exemplar-based Image Editing with Diffusion Models
https://arxiv.org/abs/2211.13227
Other
1.02k stars 93 forks source link

Input image and mask image size ? #45

Open kkbandaru opened 10 months ago

kkbandaru commented 10 months ago

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

prathameshparit commented 10 months ago
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 commented 2 months ago
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."