Skip to content

About the demo.py inference.  #15

Description

@LWShowTime

In the codes here, what is the function of the mask_transform? It seems like the h and w not to be the real size of the input image, otherwise we don't need to resize. I am confused with this.

h, w = list(map(int, args.resolution.split(',')))
img_transform = transforms.Compose([
transforms.Resize((w, h)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225])
])
mask_transform = transforms.Compose([
transforms.Resize((w, h)),
transforms.ToTensor(),
])
inverse_transform = transforms.Compose([
transforms.Normalize(mean=[0., 0., 0.],
std=[1 / 0.229, 1 / 0.224, 1 / 0.225]),
transforms.Normalize(mean=[-0.485, -0.456, -0.406],
std=[1, 1, 1])
])
img = Image.open(args.input).convert('RGB')
img = img_transform(img)
img = img.cuda()
pred = model.encoder.forward_dummy(img.unsqueeze(0))
pred = torch.sigmoid(pred).view(1, w, h).cpu()
transforms.ToPILImage()(pred).save(args.output)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions