(self, index)
| 24 | |
| 25 | |
| 26 | def __getitem__(self, index): |
| 27 | data_id = torch.randint(0, len(self.path), (1,))[0] |
| 28 | data_id = (data_id + index) % len(self.path) # For fixed seed. |
| 29 | text = self.text[data_id] |
| 30 | image = Image.open(self.path[data_id]).convert("RGB") |
| 31 | target_height, target_width = self.height, self.width |
| 32 | width, height = image.size |
| 33 | scale = max(target_width / width, target_height / height) |
| 34 | shape = [round(height*scale),round(width*scale)] |
| 35 | image = torchvision.transforms.functional.resize(image,shape,interpolation=transforms.InterpolationMode.BILINEAR) |
| 36 | image = self.image_processor(image) |
| 37 | return {"text": text, "image": image} |
| 38 | |
| 39 | |
| 40 | def __len__(self): |
nothing calls this directly
no outgoing calls
no test coverage detected