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

Class QwenVL2ImageTransform

data/transforms.py:151–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149 return img
150
151class QwenVL2ImageTransform:
152 def __init__(
153 self,
154 image_size_h,
155 image_size_w,
156 image_stride=14,
157 max_pixels=14*14*9*1024,
158 image_mean=OPENAI_CLIP_MEAN,
159 image_std=OPENAI_CLIP_STD,
160 ):
161 self.processor = Qwen2VLImageProcessor.from_pretrained('InternRobotics/G2VLM-2B-MoT')
162 self.img_h = image_size_h
163 self.img_w = image_size_w
164 self.stride = image_stride
165
166 # self.to_tensor_transform = transforms.ToTensor()
167 # self.normalize_transform = transforms.Normalize(mean=image_mean, std=image_std, inplace=True)
168
169 def __call__(self, img, img_num=1):
170 # if self.img_h is not None:
171 target_size = (self.img_h, self.img_w )
172 img = [ii.resize(target_size,3) for ii in img]
173
174 out = self.processor(img, return_tensors='pt')
175 pixel_values = out['pixel_values'] # this is flattened.
176 image_grid_thw = out['image_grid_thw']
177
178 return pixel_values, image_grid_thw
179
180class ImageTransform:
181 def __init__(

Callers 5

load_model_and_tokenizerFunction · 0.90
build_transformFunction · 0.90
build_datasetsMethod · 0.85
build_datasetsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected