MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / __getitem__

Method __getitem__

diffsynth/data/simple_text_image.py:26–37  ·  view source on GitHub ↗
(self, index)

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected