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

Function preprocess

app.py:53–67  ·  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

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

Callers 1

inferenceFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected