MCPcopy
hub / github.com/ytongbai/LVM / read_image_to_tensor

Function read_image_to_tensor

evaluation/vqlm_demo/utils.py:101–112  ·  view source on GitHub ↗
(path, center_crop=1.0)

Source from the content-addressed store, hash-verified

99
100
101def read_image_to_tensor(path, center_crop=1.0):
102 pil_im = Image.open(path).convert('RGB')
103 if center_crop < 1.0:
104 width, height = pil_im.size
105 pil_im = pil_im.crop((
106 int((1 - center_crop) * height / 2), int((1 + center_crop) * height / 2),
107 int((1 - center_crop) * width / 2), int((1 + center_crop) * width / 2),
108 ))
109 input_img = pil_im.resize((256, 256))
110 input_img = np.array(input_img) / 255.0
111 input_img = input_img.astype(np.float32)
112 return input_img
113
114
115def match_mulitple_path(root_dir, regex):

Callers 10

__getitem__Method · 0.90
__getitem__Method · 0.90
__getitem__Method · 0.90
__getitem__Method · 0.90
__getitem__Method · 0.90
__getitem__Method · 0.90
__getitem__Method · 0.90
__getitem__Method · 0.90
__getitem__Method · 0.70
read_frames_from_dirFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected