MCPcopy Create free account
hub / github.com/csuhan/OneLLM / CocoCapDataset

Class CocoCapDataset

eval/image_cap_cococap.py:29–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27
28
29class CocoCapDataset(Dataset):
30 def __init__(self) -> None:
31 super().__init__()
32 self.datas = json.load(open('datasets/Eval/image/coco_cap/coco_karpathy_val.json'))
33
34 def __len__(self):
35 return len(self.datas)
36
37 def __getitem__(self, index):
38 data = self.datas[index]
39 image_path = os.path.join("datasets/InstructionTuning/image/coco/", data['image'])
40 image = Image.open(image_path).convert('RGB')
41 image = T_resized_center_crop(image)
42 image_id = int(data['image'].split('_')[-1].split('.')[0])
43 question = 'Provide a one-sentence caption for the provided image.'
44 return image, question, image_id
45
46
47if __name__ == "__main__":

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected