MCPcopy Create free account
hub / github.com/EmbodiedGPT/EmbodiedGPT_Pytorch / load_image

Function load_image

demo/inference.py:126–143  ·  view source on GitHub ↗
(image_file, input_size=224)

Source from the content-addressed store, hash-verified

124 return model, tokenizer
125
126def load_image(image_file, input_size=224):
127 if image_file.startswith('http') or image_file.startswith('https'):
128 response = requests.get(image_file)
129 image = Image.open(BytesIO(response.content)).convert('RGB')
130 else:
131 image = Image.open(image_file).convert('RGB')
132
133 crop_pct = 224 / 256
134 size = int(input_size / crop_pct)
135 transform = T.Compose([
136 T.Lambda(lambda img: img.convert('RGB') if img.mode != 'RGB' else img),
137 T.Resize(size, interpolation=InterpolationMode.BICUBIC),
138 T.CenterCrop(input_size),
139 T.ToTensor(),
140 T.Normalize(mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225))
141 ])
142 image = transform(image)
143 return image
144
145def load_video(video_path, num_segments=8):
146 vr = VideoReader(video_path, ctx=cpu(0))

Callers 2

generate_streamFunction · 0.70
get_image_embeddingMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected