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

load image problem #161

Open
stanny880913 opened this issue Jun 26, 2023 · 0 comments
Open

load image problem #161

stanny880913 opened this issue Jun 26, 2023 · 0 comments

Comments

@stanny880913
Copy link

stanny880913 commented Jun 26, 2023

I inference my data set, but when I want to load model , it cause error in this function

def bilinear_sampler(img, coords, mode='bilinear', mask=False):
    """ Wrapper for grid_sample, uses pixel coordinates """
    H, W = img.shape[-2:]
    xgrid, ygrid = coords.split([1,1], dim=-1)
    xgrid = 2*xgrid/(W-1) - 1
    ygrid = 2*ygrid/(H-1) - 1

    grid = torch.cat([xgrid, ygrid], dim=-1)
    img = F.grid_sample(img, grid, align_corners=True)

    if mask:
        mask = (xgrid > -1) & (ygrid > -1) & (xgrid < 1) & (ygrid < 1)
        return img, mask.float()

    return img

Error : RuntimeError: grid_sampler(): expected grid and input to have same batch size, but got input with sizes [760, 1, 19, 40] and grid with sizes [720, 9, 9, 2]
How to fix it!!!
Thank you

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

1 participant