def __init__(self, opt): self.opt = opt if opt.data == 'voc': self.db = VOCBboxDataset(opt.voc_data_dir) elif opt.data == 's3d': self.db = S3DBboxDataset(opt.s3d_data_dir) self.tsf = Transform(opt.min_size, opt.max_size)
def __init__(self, path, is_train=True, min_size=600, max_size=1000): self.path = path self.is_train = is_train if self.is_train: self.db = VOCBboxDataset(path) self.tsf = Transform(min_size, max_size) else: self.db = VOCBboxDataset(path, split='val', use_difficult=True)
def __init__(self, opt, split='test', use_difficult=True): #add use_difficult self.opt = opt self.db = VOCBboxDataset(opt.voc_data_dir, split=split, use_difficult=use_difficult)
def __init__(self, opt, split='test', use_difficult=True): self.opt = opt if self.opt.data == 'markers': self.db = MarkersDataset(opt.data_dir) elif self.opt.data == 'voc': self.db = VOCBboxDataset(opt.data_dir) else: raise Exception('database type not recognised: {}'.format( self.opt.data)) self.label_names = self.db.get_label_names()
def __init__(self, opt): self.opt = opt if opt.data == 'cityperson': self.db = CityPersonTrainset( img_path=opt.cityperson_data_dir + '/leftImg8bit/train', annotation_path=opt.cityperson_data_dir + '/gtBboxCityPersons/train') else: self.db = VOCBboxDataset(opt.voc_data_dir) self.tsf = Transform(opt.min_size, opt.max_size)
def __init__(self, opt, split='test', use_difficult=True): self.opt = opt if opt.data == 'cityperson': self.db = CityPersonTestset( img_path=opt.cityperson_data_dir + '/leftImg8bit/val', annotation_path=opt.cityperson_data_dir + '/gtBboxCityPersons/val') else: self.db = VOCBboxDataset(opt.voc_data_dir, split=split, use_difficult=use_difficult)
def __init__(self, opt): self.opt = opt if self.opt.data == 'markers': self.db = MarkersDataset(opt.data_dir) elif self.opt.data == 'voc': self.db = VOCBboxDataset(opt.data_dir) else: raise Exception('database type not recognised: {}'.format( self.opt.data)) self.tsf = Transform(opt.min_size, opt.max_size) self.label_names = self.db.get_label_names()
def __init__(self, opt): self.opt = opt if opt.data == 'voc': self.db = VOCBboxDataset(opt.voc_data_dir) else: self.db = CITYBboxDataset(opt.city_data_dir, train=True) self.tsf = Transform(opt.min_size, opt.max_size)
def __init__(self, opt, split='test', use_difficult=True): self.opt = opt if opt.data == 'voc': self.db = VOCBboxDataset(opt.voc_data_dir, split=split, use_difficult=use_difficult) else: self.db = CITYBboxDataset(opt.city_data_dir, train=False)
class TestDataset: def __init__(self, opt, split='test', use_difficult=True): self.opt = opt if self.opt.data == 'markers': self.db = MarkersDataset(opt.data_dir) elif self.opt.data == 'voc': self.db = VOCBboxDataset(opt.data_dir) else: raise Exception('database type not recognised: {}'.format( self.opt.data)) self.label_names = self.db.get_label_names() def __getitem__(self, idx): ori_img, bbox, label, difficult = self.db.get_example(idx) img = preprocess(ori_img) return img, ori_img.shape[1:], bbox, label, difficult def __len__(self): return len(self.db)
class TestDataset: def __init__(self, opt): self.opt = opt self.db = VOCBboxDataset(self.opt.test_data_dir) def __getitem__(self, idx): ori_img, bbox, label, difficult, mask = self.db.get_example(idx) img, mask = preprocess(ori_img, mask) return img, ori_img.shape[1:], bbox, label, difficult, mask def __len__(self): return len(self.db)
class TestDataset: def __init__(self, opt, split='test', use_difficult=True): self.opt = opt self.db = VOCBboxDataset(opt.voc_data_dir, split=split, use_difficult=use_difficult) def __getitem__(self, idx): ori_img, bbox, label, difficult = self.db.get_example(idx) img = preprocess(ori_img) return img, ori_img.shape[1:], bbox, label, difficult def __len__(self): return len(self.db)
class TestTypeDataset: def __init__(self, opt, use_difficult=True, id_file=None, img_dir=None, anno_dir=None): self.opt = opt self.db = VOCBboxDataset(opt.voc_data_dir, id_file=id_file, img_dir=img_dir, anno_dir=anno_dir, use_difficult=use_difficult) def __getitem__(self, idx): ori_img, bbox, label, difficult = self.db.get_example(idx) img = preprocess(ori_img) return img, ori_img.shape[1:], bbox, label, difficult def __len__(self): return len(self.db)
class TestDataset(object): def __init__(self): self.db = VOCBboxDataset( 'D:/pyworks/FasterRCNN/data/testset/VOCdevkit/VOC2007', 'test', True) def __getitem__(self, idx): ori_img, bbox, label, difficult = self.db.get_example(idx) img = preprocess(ori_img) return img, ori_img.shape[1:], bbox, label, difficult def __len__(self): return len(self.db)
class TrainDataset(object): def __init__(self): self.db = VOCBboxDataset( 'D:/pyworks/FasterRCNN/data/VOCdevkit/VOC2007', 'trainval') self.transform = Transform() def __getitem__(self, idx): ori_img, bbox, label, difficult = self.db.get_example(idx) img, bbox, label, scale = self.transform((ori_img, bbox, label)) return img.copy(), bbox.copy(), label.copy(), scale def __len__(self): return len(self.db)
class Dataset: def __init__(self, opt): self.opt = opt self.db = VOCBboxDataset(opt.voc_data_dir) self.tsf = Transform(opt.min_size, opt.max_size) def __getitem__(self, idx): ori_img, bbox, label, difficult = self.db.get_example(idx) img, bbox, label, scale = self.tsf((ori_img, bbox, label)) return img.copy(), bbox.copy(), label.copy(), scale def __len__(self): return len(self.db)
class TestDataset: def __init__(self, configurations, split='val', use_difficult=True): self.configurations = configurations self.db = VOCBboxDataset(configurations.voc_data_dir, split=split, use_difficult=use_difficult) def __getitem__(self, idx): ori_image, bbox, label, difficult = self.db.get_example(idx) image = preprocess(ori_image) return image, ori_image.shape[1:], bbox, label, difficult def __len__(self): return len(self.db)
class TestFGSMDataset: def __init__(self, opt, split='test', use_difficult=True): self.opt = opt self.db = VOCBboxDataset(opt.voc_data_dir, split=split, use_difficult=use_difficult) self.tsf = Transform(opt.min_size, opt.max_size) def __getitem__(self, idx): ori_img, bbox, label, difficult = self.db.get_example(idx) _, _, _, scale = self.tsf((ori_img, bbox, label)) img = preprocess(ori_img) return img, ori_img.shape[1:], bbox, label, difficult, scale def __len__(self): return len(self.db)
class Dataset: def __init__(self, opt): self.opt = opt self.dataset = VOCBboxDataset(opt.voc_data_dir) self.transform = Transform(opt.min_size, opt.max_size) def __getitem__(self, item): ori_img, bbox, label, difficult = self.dataset.get_example(item) img, bbox, label, scale = self.transform((ori_img, bbox, label)) return img.copy(), bbox.copy(), label.copy( ), scale #返回处理后的图片(CHW,[-1,1]),bbox,label,原图和调整后图的比例因子 def __len__(self): return len(self.dataset)
class Dataset: def __init__(self, opt): self.opt = opt if self.opt.data == 'markers': self.db = MarkersDataset(opt.data_dir) elif self.opt.data == 'voc': self.db = VOCBboxDataset(opt.data_dir) else: raise Exception('database type not recognised: {}'.format( self.opt.data)) self.tsf = Transform(opt.min_size, opt.max_size) self.label_names = self.db.get_label_names() def __getitem__(self, idx): ori_img, bbox, label, difficult = self.db.get_example(idx) img, bbox, label, scale = self.tsf((ori_img, bbox, label)) # TODO: check whose stride is negative to fix this instead copy all # some of the strides of a given numpy array are negative. return img.copy(), bbox.copy(), label.copy(), scale def __len__(self): return len(self.db)
class Dataset: def __init__(self): self.db = VOCBboxDataset(voc_data_dir) self.tsf = Transform(min_size=600, max_size=1000) def __getitem__(self, idx): ori_img, bbox, label, difficult = self.db.get_example(idx) img, bbox, label, scale = self.tsf((ori_img, bbox, label)) # TODO: check whose stride is negative to fix this instead copy all # some of the strides of a given numpy array are negative. return img.copy(), bbox.copy(), label.copy(), scale def __len__(self): return len(self.db)
class Dataset: def __init__(self, opt): self.opt = opt self.db = VOCBboxDataset(opt.train_data_dir) self.tsf = Transform() def __getitem__(self, idx): ori_img, bbox, label, difficult, mask = self.db.get_example(idx) img, bbox, label, scale, mask = self.tsf((ori_img, bbox, label, mask)) # TODO: check whose stride is negative to fix this instead copy all # some of the strides of a given numpy array are negative. return img.copy(), bbox.copy(), label.copy(), scale, mask.copy() def __len__(self): return len(self.db)
class TestDataset: def __init__(self, opt, split='test', use_difficult=True): self.opt = opt self.db = VOCBboxDataset('/data2/dechunwang/dataset/', split=split, use_difficult=use_difficult) def __getitem__(self, idx): ori_img, bbox, label, difficult = self.db.get_example(idx) # print('\n', '*' * 70, 'ori_img shape: ', ori_img.shape, '\n', '*' * 70) img = preprocess(ori_img) # print('\n', '*' * 70, 'img shape: ', img.shape, '\n', '*' * 70) return ori_img, img, ori_img.shape[1:], bbox, label, difficult def __len__(self): return len(self.db)
class DatasetAugmented: def __init__(self, opt, id_file=None, img_dir=None, anno_dir=None, use_diff=True): self.opt = opt self.db = VOCBboxDataset(opt.voc_data_dir, id_file=id_file, img_dir=img_dir, anno_dir=anno_dir, use_difficult=use_diff) self.tsf = Transform(opt.min_size, opt.max_size) def __getitem__(self, idx): ori_img, bbox, label, difficult = self.db.get_example(idx) img, bbox, label, scale = self.tsf((ori_img, bbox, label)) # TODO: check whose stride is negative to fix this instead copy all # some of the strides of a given numpy array are negative. return img.copy(), bbox.copy(), label.copy(), scale def __len__(self): return len(self.db)
class SmallImageDataset: def __init__(self, opt): self.opt = opt self.db = VOCBboxDataset(opt.voc_data_dir, split='trainval_small_32', small_obj=True) self.tsf = Transform(opt.min_size, opt.max_size) def __getitem__(self, idx): ori_img, bbox, label, difficult = self.db.get_example(idx) img, bbox, label, scale = self.tsf((ori_img, bbox, label)) # TODO: check whose stride is negative to fix this instead copy all # some of the strides of a given numpy array are negative. return img.copy(), bbox.copy(), label.copy(), scale def __len__(self): return len(self.db)
class TestDataset: # 测试集 有五个输出 def __init__(self, opt, split=opt.testtxt, use_difficult=True): self.opt = opt self.db = VOCBboxDataset(opt.voc_data_dir, split=split, use_difficult=use_difficult) def __getitem__(self, idx): ori_img, bbox, label, difficult, id_ = self.db.get_example(idx) if len(bbox) == 0: return 0, ori_img.shape[1:], bbox, 0, 0, id_ img = preprocess(ori_img) return img, ori_img.shape[1:], bbox, label, difficult, id_ def __len__(self): return len(self.db)
class Dataset: def __init__(self, opt): self.opt = opt self.db = VOCBboxDataset(opt.voc_data_dir, opt.label_names) self.tsf = Transform(opt.min_size, opt.max_size) def __getitem__(self, idx): ori_img, bbox, label, difficult = self.db.get_example(idx) img, bbox, label, scale = self.tsf((ori_img, bbox, label)) # TODO: check whose stride is negative to fix this instead copy all # some of the strides of a given numpy array are negative. return img.copy(), ori_img.shape[1:], bbox.copy(), \ label.copy(), scale, difficult def __len__(self): return len(self.db)
class Dataset: def __init__(self, opt): self.opt = opt #预设参数 self.db = VOCBboxDataset(opt.voc_data_dir) #用预设参数创建数据集类 self.tsf = Transform(opt.min_size, opt.max_size) #实例化预处理类 def __getitem__(self, idx): #获得idx下标的一个数据 ori_img, bbox, label, difficult = self.db.get_example( idx) #从数据集中获得一个batch的数据 img, bbox, label, scale = self.tsf((ori_img, bbox, label)) #预处理数据 # TODO: check whose stride is negative to fix this instead copy all # some of the strides of a given numpy array are negative. return img.copy(), bbox.copy(), label.copy(), scale def __len__(self): #获得数据集总长度 return len(self.db)
class Dataset: def __init__(self, opt): self.opt = opt self.db = VOCBboxDataset(opt.voc_data_dir) # 实例化类 self.tsf = Transform(opt.min_size, opt.max_size) # 获得变换类 def __getitem__(self, idx): # 运行Dataset自动运行 # 调用VOCBboxDataset中的get_example()将img, bbox, label, difficult一个个取出 ori_img, bbox, label, difficult = self.db.get_example(idx) # 调用前面的Transform函数将图片, label进行最小值最大值放缩归一化 img, bbox, label, scale = self.tsf((ori_img, bbox, label)) # TODO: check whose stride is negative to fix this instead copy all # some of the strides of a given numpy array are negative. return img.copy(), bbox.copy(), label.copy(), scale def __len__(self): return len(self.db)
class Dataset: def __init__(self, opt): self.opt = opt self.db = VOCBboxDataset(opt.voc_data_dir) self.tsf = Transform(opt.min_size, opt.max_size) def __getitem__(self, idx): ori_img, bbox, label, difficult = self.db.get_example( idx ) #use voc_dataset.py VOCBboxDataset get_example() return img, bbox, label, difficult img, bbox, label, scale = self.tsf((ori_img, bbox, label)) # TODO: check whose stride is negative to fix this instead copy all # some of the strides of a given numpy array are negative. return img.copy(), bbox.copy(), label.copy(), scale def __len__(self): return len(self.db) #trainval =5011 test=4952