fix dataset

This commit is contained in:
Jethong 2021-04-21 19:36:58 +08:00
parent 243bd9944d
commit 2365c70e4a
1 changed files with 5 additions and 3 deletions

View File

@ -72,6 +72,7 @@ class PGDataSet(Dataset):
def __getitem__(self, idx):
file_idx = self.data_idx_order_list[idx]
data_line = self.data_lines[file_idx]
img_id = 0
try:
data_line = data_line.decode('utf-8')
substr = data_line.strip("\n").split(self.delimiter)
@ -79,8 +80,9 @@ class PGDataSet(Dataset):
label = substr[1]
img_path = os.path.join(self.data_dir, file_name)
if self.mode.lower() == 'eval':
try:
img_id = int(data_line.split(".")[0][7:])
else:
except:
img_id = 0
data = {'img_path': img_path, 'label': label, 'img_id': img_id}
if not os.path.exists(img_path):