CYF200127's picture
Upload 235 files
3e1d9f3 verified
raw
history blame
761 Bytes
from ..root import DATASETS
from ..utils import MInstrDataset
@DATASETS.register_module()
class InstructDataset(MInstrDataset):
def __init__(self, *args, add_coco_prefix=False, **kwargs):
super().__init__(*args, **kwargs, placeholders=(), template_string='', template_file=None)
self.add_coco_prefix = add_coco_prefix
def __getitem__(self, index):
item = self.get_raw_item(index)
if self.add_coco_prefix:
img_path = f"COCO_train2014_{item['image']}"
else:
img_path = item['image']
conversations = item['conversations']
image = self.get_image(img_path)
ret = {
'image': image,
'conversations': conversations,
}
return ret