MCPcopy Create free account
hub / github.com/InternRobotics/G2VLM / patchify

Function patchify

data/data_utils.py:40–47  ·  view source on GitHub ↗
(image, patch_size)

Source from the content-addressed store, hash-verified

38
39
40def patchify(image, patch_size):
41 p = patch_size
42 c, h, w = image.shape
43 assert h % p == 0 and w % p == 0
44 image = image.reshape(c, h // p, p, w // p, p)
45 image = torch.einsum("chpwq->hwpqc", image)
46 image = image.reshape(-1, p**2 * c)
47 return image
48
49
50def get_flattened_position_ids_extrapolate(img_h, img_w, patch_size, max_num_patches_per_side):

Callers 4

pack_sequenceMethod · 0.85
pack_sequenceMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected