in src/data_loader.py [0:0]
def __getitem__(self, item):
sample_name = self.ids[item].rstrip()
impath = os.path.join(self.root, 'images', sample_name)
maskname = sample_name.split('.jpg')[0] + '.png'
maskpath = os.path.join(self.root, 'annotations', maskname)
img = Image.open(impath).convert('RGB')
if self.transform is not None:
img = self.transform(img)
mask = Image.open(maskpath)
idxs = np.unique(mask)
# the 0 idx refers to "other objects"
idxs = np.delete(idxs, np.where(idxs == 0))
if not self.include_eos:
idxs = [i-1 for i in idxs]
if self.shuffle:
np.random.shuffle(idxs)
target_list = []
for t in idxs:
category_id = t
if category_id not in target_list:
target_list.append(category_id)
# eos
if self.include_eos:
target_list.append(0)
return img, target_list