Commit 11608493 authored by Yunguan Fu's avatar Yunguan Fu

update loader to ignore xml

parent 3ae6173e
Pipeline #3923 failed with stages
in 1 minute and 59 seconds
......@@ -62,21 +62,25 @@ def extract_image_mask_fnames(folders, has_mask, keep_ratio, skip):
img_fnames = []
for folder_path in folders:
subfolders = [f.path + "/" for f in os.scandir(folder_path) if f.is_dir()] # extract paths of subfolders, some docx, zip files are ignored
subfolders = [f.path + "/" for f in os.scandir(folder_path) if
f.is_dir()] # extract paths of subfolders, some docx, zip files are ignored
for subfolder in subfolders:
img_fnames_sub = []
fnames = sorted(os.listdir(subfolder))
xmls = [x[:-11] for x in fnames if x.endswith("Contour.xml")]
imgs = [x[:-4] for x in fnames if x.endswith(".png") and not x.endswith("Mask.png")]
if has_mask and (len(xmls) == 0):
# in some folders, there's no xml file and mask imgs are all zero
continue
check_xml = not any([x.endswith(".not_check_xml") for x in fnames]) # a hack
if has_mask:
if check_xml: # so check
if len(xmls) == 0:
# in some folders, there's no xml file and mask imgs are all zero
continue
for x in imgs:
if has_mask: # label is correct iff the mask and contour file both exist
if x not in xmls:
continue
if check_xml:
if x not in xmls:
continue
if x + "Mask.png" not in fnames:
continue
img_fnames_sub.append(subfolder + x)
......@@ -198,7 +202,8 @@ def build_test_dataset(img_fnames, mean_std_path, config):
preprocess = config['data']['preprocess']
batch_size = config['model']['opt']['batch_size']
num_parallel_calls = config['tf']['num_parallel_calls']
dataset = load_dataset(img_fnames, has_mask=False, preprocess=preprocess, num_parallel_calls=num_parallel_calls, cut_border=False)
dataset = load_dataset(img_fnames, has_mask=False, preprocess=preprocess, num_parallel_calls=num_parallel_calls,
cut_border=False)
mean = decode_png(mean_std_path[0], channels=3)
std = decode_png(mean_std_path[1], channels=3)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment