in datasets/SCOODBenchmarkDataset.py [0:0]
def __getitem__(self, index):
# parse the string in imglist file:
line = self.imglist[index].strip("\n")
tokens = line.split(" ", 1)
image_name, extra_str = tokens[0], tokens[1]
extras = ast.literal_eval(extra_str)
sc_label = extras['sc_label'] # the ood label is here. -1 means ood.
# read image according to image name:
img_path = os.path.join(self.root, 'data', 'images', image_name)
with open(img_path, 'rb') as f:
img = Image.open(f).convert('RGB')
if self.transform is not None:
img = self.transform(img)
return img, sc_label