fix bug while label and img not match (#289)

This commit is contained in:
yhq 2023-02-21 16:17:09 +08:00 committed by GitHub
parent 8f49e1fa4f
commit e30520b424
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -110,6 +110,7 @@ class DetSourceRaw(DetSourceBase):
]
self.label_files = []
self.img_files_effec = []
for img_path in self.img_files:
img_name = os.path.splitext(os.path.basename(img_path))[0]
find_label_path = False
@ -119,18 +120,18 @@ class DetSourceRaw(DetSourceBase):
if io.exists(lable_path):
find_label_path = True
self.label_files.append(lable_path)
self.img_files_effec.append(img_path)
break
if not find_label_path:
logging.warning(
'Not find label file %s for img: %s, skip the sample!' %
(lable_path, img_path))
self.img_files.remove(img_path)
assert len(self.img_files) == len(self.label_files)
assert len(
self.img_files) > 0, 'No samples found in %s' % self.img_root_path
assert len(self.img_files_effec) == len(self.label_files)
assert len(self.img_files_effec
) > 0, 'No samples found in %s' % self.img_root_path
return list(zip(self.img_files, self.label_files))
return list(zip(self.img_files_effec, self.label_files))
def post_process_fn(self, result_dict):
result_dict = super(DetSourceRaw, self).post_process_fn(result_dict)