mirror of
https://github.com/alibaba/EasyCV.git
synced 2025-06-03 14:49:00 +08:00
fix bug while label and img not match (#289)
This commit is contained in:
parent
8f49e1fa4f
commit
e30520b424
@ -110,6 +110,7 @@ class DetSourceRaw(DetSourceBase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
self.label_files = []
|
self.label_files = []
|
||||||
|
self.img_files_effec = []
|
||||||
for img_path in self.img_files:
|
for img_path in self.img_files:
|
||||||
img_name = os.path.splitext(os.path.basename(img_path))[0]
|
img_name = os.path.splitext(os.path.basename(img_path))[0]
|
||||||
find_label_path = False
|
find_label_path = False
|
||||||
@ -119,18 +120,18 @@ class DetSourceRaw(DetSourceBase):
|
|||||||
if io.exists(lable_path):
|
if io.exists(lable_path):
|
||||||
find_label_path = True
|
find_label_path = True
|
||||||
self.label_files.append(lable_path)
|
self.label_files.append(lable_path)
|
||||||
|
self.img_files_effec.append(img_path)
|
||||||
break
|
break
|
||||||
if not find_label_path:
|
if not find_label_path:
|
||||||
logging.warning(
|
logging.warning(
|
||||||
'Not find label file %s for img: %s, skip the sample!' %
|
'Not find label file %s for img: %s, skip the sample!' %
|
||||||
(lable_path, img_path))
|
(lable_path, img_path))
|
||||||
self.img_files.remove(img_path)
|
|
||||||
|
|
||||||
assert len(self.img_files) == len(self.label_files)
|
assert len(self.img_files_effec) == len(self.label_files)
|
||||||
assert len(
|
assert len(self.img_files_effec
|
||||||
self.img_files) > 0, 'No samples found in %s' % self.img_root_path
|
) > 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):
|
def post_process_fn(self, result_dict):
|
||||||
result_dict = super(DetSourceRaw, self).post_process_fn(result_dict)
|
result_dict = super(DetSourceRaw, self).post_process_fn(result_dict)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user