MCPcopy Create free account
hub / github.com/JIA-Lab-research/LISA / preprocess

Function preprocess

chat.py:49–63  ·  view source on GitHub ↗

Normalize pixel values and pad to a square input.

(
    x,
    pixel_mean=torch.Tensor([123.675, 116.28, 103.53]).view(-1, 1, 1),
    pixel_std=torch.Tensor([58.395, 57.12, 57.375]).view(-1, 1, 1),
    img_size=1024,
)

Source from the content-addressed store, hash-verified

47
48
49def preprocess(
50 x,
51 pixel_mean=torch.Tensor([123.675, 116.28, 103.53]).view(-1, 1, 1),
52 pixel_std=torch.Tensor([58.395, 57.12, 57.375]).view(-1, 1, 1),
53 img_size=1024,
54) -> torch.Tensor:
55 """Normalize pixel values and pad to a square input."""
56 # Normalize colors
57 x = (x - pixel_mean) / pixel_std
58 # Pad
59 h, w = x.shape[-2:]
60 padh = img_size - h
61 padw = img_size - w
62 x = F.pad(x, (0, padw, 0, padh))
63 return x
64
65
66def main(args):

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected