MCPcopy Create free account
hub / github.com/LargeWorldModel/LWM / _process_frame

Method _process_frame

lwm/vision_chat.py:59–74  ·  view source on GitHub ↗
(self, image, size)

Source from the content-addressed store, hash-verified

57 return self.mesh.shape['dp'] * self.mesh.shape['fsdp']
58
59 def _process_frame(self, image, size):
60 width, height = image.size
61 if width < height:
62 new_width = size
63 new_height = int(size * height / width)
64 else:
65 new_height = size
66 new_width = int(size * width / height)
67 image = image.resize((new_width, new_height))
68
69 left = (new_width - size) / 2
70 top = (new_height - size) / 2
71 right = (new_width + size) / 2
72 bottom = (new_height + size) / 2
73 image = image.crop((left, top, right, bottom))
74 return np.array(image, dtype=np.float32) / 127.5 - 1
75
76 def _read_process_vision(self, path, max_n_frames):
77 f = open_file(path, 'rb')

Callers 1

_read_process_visionMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected