parent
969c7fd8e4
commit
294a1f377a
|
@ -10,8 +10,8 @@ class ChaseDB1Dataset(CustomDataset):
|
|||
|
||||
In segmentation map annotation for Chase_db1, 0 stands for background,
|
||||
which is included in 2 categories. ``reduce_zero_label`` is fixed to False.
|
||||
The ``img_suffix`` is fixed to '.jpg' and ``seg_map_suffix`` is fixed to
|
||||
'_1stHO.jpg'.
|
||||
The ``img_suffix`` is fixed to '.png' and ``seg_map_suffix`` is fixed to
|
||||
'_1stHO.png'.
|
||||
"""
|
||||
|
||||
CLASSES = ('background', 'vessel')
|
||||
|
@ -20,8 +20,8 @@ class ChaseDB1Dataset(CustomDataset):
|
|||
|
||||
def __init__(self, **kwargs):
|
||||
super(ChaseDB1Dataset, self).__init__(
|
||||
img_suffix='.jpg',
|
||||
seg_map_suffix='_1stHO.jpg',
|
||||
img_suffix='.png',
|
||||
seg_map_suffix='_1stHO.png',
|
||||
reduce_zero_label=False,
|
||||
**kwargs)
|
||||
assert osp.exists(self.img_dir)
|
||||
|
|
|
@ -10,8 +10,8 @@ class DRIVEDataset(CustomDataset):
|
|||
|
||||
In segmentation map annotation for DRIVE, 0 stands for background, which is
|
||||
included in 2 categories. ``reduce_zero_label`` is fixed to False. The
|
||||
``img_suffix`` is fixed to '.jpg' and ``seg_map_suffix`` is fixed to
|
||||
'_manual1.jpg'.
|
||||
``img_suffix`` is fixed to '.png' and ``seg_map_suffix`` is fixed to
|
||||
'_manual1.png'.
|
||||
"""
|
||||
|
||||
CLASSES = ('background', 'vessel')
|
||||
|
@ -20,8 +20,8 @@ class DRIVEDataset(CustomDataset):
|
|||
|
||||
def __init__(self, **kwargs):
|
||||
super(DRIVEDataset, self).__init__(
|
||||
img_suffix='.jpg',
|
||||
seg_map_suffix='_manual1.jpg',
|
||||
img_suffix='.png',
|
||||
seg_map_suffix='_manual1.png',
|
||||
reduce_zero_label=False,
|
||||
**kwargs)
|
||||
assert osp.exists(self.img_dir)
|
||||
|
|
|
@ -10,8 +10,8 @@ class HRFDataset(CustomDataset):
|
|||
|
||||
In segmentation map annotation for HRF, 0 stands for background, which is
|
||||
included in 2 categories. ``reduce_zero_label`` is fixed to False. The
|
||||
``img_suffix`` is fixed to '.jpg' and ``seg_map_suffix`` is fixed to
|
||||
'.jpg'.
|
||||
``img_suffix`` is fixed to '.png' and ``seg_map_suffix`` is fixed to
|
||||
'.png'.
|
||||
"""
|
||||
|
||||
CLASSES = ('background', 'vessel')
|
||||
|
@ -20,8 +20,8 @@ class HRFDataset(CustomDataset):
|
|||
|
||||
def __init__(self, **kwargs):
|
||||
super(HRFDataset, self).__init__(
|
||||
img_suffix='.jpg',
|
||||
seg_map_suffix='.jpg',
|
||||
img_suffix='.png',
|
||||
seg_map_suffix='.png',
|
||||
reduce_zero_label=False,
|
||||
**kwargs)
|
||||
assert osp.exists(self.img_dir)
|
||||
|
|
|
@ -10,8 +10,8 @@ class STAREDataset(CustomDataset):
|
|||
|
||||
In segmentation map annotation for STARE, 0 stands for background, which is
|
||||
included in 2 categories. ``reduce_zero_label`` is fixed to False. The
|
||||
``img_suffix`` is fixed to '.jpg' and ``seg_map_suffix`` is fixed to
|
||||
'.ah.jpg'.
|
||||
``img_suffix`` is fixed to '.png' and ``seg_map_suffix`` is fixed to
|
||||
'.ah.png'.
|
||||
"""
|
||||
|
||||
CLASSES = ('background', 'vessel')
|
||||
|
@ -20,8 +20,8 @@ class STAREDataset(CustomDataset):
|
|||
|
||||
def __init__(self, **kwargs):
|
||||
super(STAREDataset, self).__init__(
|
||||
img_suffix='.jpg',
|
||||
seg_map_suffix='.ah.jpg',
|
||||
img_suffix='.png',
|
||||
seg_map_suffix='.ah.png',
|
||||
reduce_zero_label=False,
|
||||
**kwargs)
|
||||
assert osp.exists(self.img_dir)
|
||||
|
|
|
@ -50,8 +50,10 @@ def main():
|
|||
for img_name in sorted(os.listdir(tmp_dir))[:TRAINING_LEN]:
|
||||
img = mmcv.imread(osp.join(tmp_dir, img_name))
|
||||
if osp.splitext(img_name)[1] == '.jpg':
|
||||
mmcv.imwrite(img,
|
||||
osp.join(out_dir, 'images', 'training', img_name))
|
||||
mmcv.imwrite(
|
||||
img,
|
||||
osp.join(out_dir, 'images', 'training',
|
||||
osp.splitext(img_name)[0] + '.png'))
|
||||
else:
|
||||
# The annotation img should be divided by 128, because some of
|
||||
# the annotation imgs are not standard. We should set a
|
||||
|
@ -61,18 +63,20 @@ def main():
|
|||
mmcv.imwrite(
|
||||
img[:, :, 0] // 128,
|
||||
osp.join(out_dir, 'annotations', 'training',
|
||||
osp.splitext(img_name)[0] + '.jpg'))
|
||||
osp.splitext(img_name)[0] + '.png'))
|
||||
|
||||
for img_name in sorted(os.listdir(tmp_dir))[TRAINING_LEN:]:
|
||||
img = mmcv.imread(osp.join(tmp_dir, img_name))
|
||||
if osp.splitext(img_name)[1] == '.jpg':
|
||||
mmcv.imwrite(
|
||||
img, osp.join(out_dir, 'images', 'validation', img_name))
|
||||
img,
|
||||
osp.join(out_dir, 'images', 'validation',
|
||||
osp.splitext(img_name)[0] + '.png'))
|
||||
else:
|
||||
mmcv.imwrite(
|
||||
img[:, :, 0] // 128,
|
||||
osp.join(out_dir, 'annotations', 'validation',
|
||||
osp.splitext(img_name)[0] + '.jpg'))
|
||||
osp.splitext(img_name)[0] + '.png'))
|
||||
|
||||
print('Removing the temporary files...')
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ def main():
|
|||
osp.join(
|
||||
out_dir, 'images', 'training',
|
||||
osp.splitext(img_name)[0].replace('_training', '') +
|
||||
'.jpg'))
|
||||
'.png'))
|
||||
|
||||
now_dir = osp.join(tmp_dir, 'training', '1st_manual')
|
||||
for img_name in os.listdir(now_dir):
|
||||
|
@ -62,7 +62,7 @@ def main():
|
|||
mmcv.imwrite(
|
||||
img[:, :, 0] // 128,
|
||||
osp.join(out_dir, 'annotations', 'training',
|
||||
osp.splitext(img_name)[0] + '.jpg'))
|
||||
osp.splitext(img_name)[0] + '.png'))
|
||||
|
||||
print('Extracting test.zip...')
|
||||
zip_file = zipfile.ZipFile(testing_path)
|
||||
|
@ -76,7 +76,7 @@ def main():
|
|||
img,
|
||||
osp.join(
|
||||
out_dir, 'images', 'validation',
|
||||
osp.splitext(img_name)[0].replace('_test', '') + '.jpg'))
|
||||
osp.splitext(img_name)[0].replace('_test', '') + '.png'))
|
||||
|
||||
now_dir = osp.join(tmp_dir, 'test', '1st_manual')
|
||||
if osp.exists(now_dir):
|
||||
|
@ -91,7 +91,7 @@ def main():
|
|||
mmcv.imwrite(
|
||||
img[:, :, 0] // 128,
|
||||
osp.join(out_dir, 'annotations', 'validation',
|
||||
osp.splitext(img_name)[0] + '.jpg'))
|
||||
osp.splitext(img_name)[0] + '.png'))
|
||||
|
||||
now_dir = osp.join(tmp_dir, 'test', '2nd_manual')
|
||||
if osp.exists(now_dir):
|
||||
|
@ -101,7 +101,7 @@ def main():
|
|||
mmcv.imwrite(
|
||||
img[:, :, 0] // 128,
|
||||
osp.join(out_dir, 'annotations', 'validation',
|
||||
osp.splitext(img_name)[0] + '.jpg'))
|
||||
osp.splitext(img_name)[0] + '.png'))
|
||||
|
||||
print('Removing the temporary files...')
|
||||
|
||||
|
|
|
@ -68,13 +68,13 @@ def main():
|
|||
mmcv.imwrite(
|
||||
img,
|
||||
osp.join(out_dir, 'images', 'training',
|
||||
osp.splitext(filename)[0] + '.jpg'))
|
||||
osp.splitext(filename)[0] + '.png'))
|
||||
for filename in sorted(os.listdir(tmp_dir))[TRAINING_LEN:]:
|
||||
img = mmcv.imread(osp.join(tmp_dir, filename))
|
||||
mmcv.imwrite(
|
||||
img,
|
||||
osp.join(out_dir, 'images', 'validation',
|
||||
osp.splitext(filename)[0] + '.jpg'))
|
||||
osp.splitext(filename)[0] + '.png'))
|
||||
|
||||
print('Generating annotations...')
|
||||
for now_path in annotations_path:
|
||||
|
@ -95,13 +95,13 @@ def main():
|
|||
mmcv.imwrite(
|
||||
img[:, :, 0] // 128,
|
||||
osp.join(out_dir, 'annotations', 'training',
|
||||
osp.splitext(filename)[0] + '.jpg'))
|
||||
osp.splitext(filename)[0] + '.png'))
|
||||
for filename in sorted(os.listdir(tmp_dir))[TRAINING_LEN:]:
|
||||
img = mmcv.imread(osp.join(tmp_dir, filename))
|
||||
mmcv.imwrite(
|
||||
img[:, :, 0] // 128,
|
||||
osp.join(out_dir, 'annotations', 'validation',
|
||||
osp.splitext(filename)[0] + '.jpg'))
|
||||
osp.splitext(filename)[0] + '.png'))
|
||||
|
||||
print('Done!')
|
||||
|
||||
|
|
|
@ -73,14 +73,14 @@ def main():
|
|||
mmcv.imwrite(
|
||||
img,
|
||||
osp.join(out_dir, 'images', 'training',
|
||||
osp.splitext(filename)[0] + '.jpg'))
|
||||
osp.splitext(filename)[0] + '.png'))
|
||||
|
||||
for filename in sorted(os.listdir(now_dir))[TRAINING_LEN:]:
|
||||
img = mmcv.imread(osp.join(now_dir, filename))
|
||||
mmcv.imwrite(
|
||||
img,
|
||||
osp.join(out_dir, 'images', 'validation',
|
||||
osp.splitext(filename)[0] + '.jpg'))
|
||||
osp.splitext(filename)[0] + '.png'))
|
||||
|
||||
print('Removing the temporary files...')
|
||||
|
||||
|
@ -112,14 +112,14 @@ def main():
|
|||
mmcv.imwrite(
|
||||
img[:, :, 0] // 128,
|
||||
osp.join(out_dir, 'annotations', 'training',
|
||||
osp.splitext(filename)[0] + '.jpg'))
|
||||
osp.splitext(filename)[0] + '.png'))
|
||||
|
||||
for filename in sorted(os.listdir(now_dir))[TRAINING_LEN:]:
|
||||
img = mmcv.imread(osp.join(now_dir, filename))
|
||||
mmcv.imwrite(
|
||||
img[:, :, 0] // 128,
|
||||
osp.join(out_dir, 'annotations', 'validation',
|
||||
osp.splitext(filename)[0] + '.jpg'))
|
||||
osp.splitext(filename)[0] + '.png'))
|
||||
|
||||
print('Removing the temporary files...')
|
||||
|
||||
|
@ -147,14 +147,14 @@ def main():
|
|||
mmcv.imwrite(
|
||||
img[:, :, 0] // 128,
|
||||
osp.join(out_dir, 'annotations', 'training',
|
||||
osp.splitext(filename)[0] + '.jpg'))
|
||||
osp.splitext(filename)[0] + '.png'))
|
||||
|
||||
for filename in sorted(os.listdir(now_dir))[TRAINING_LEN:]:
|
||||
img = mmcv.imread(osp.join(now_dir, filename))
|
||||
mmcv.imwrite(
|
||||
img[:, :, 0] // 128,
|
||||
osp.join(out_dir, 'annotations', 'validation',
|
||||
osp.splitext(filename)[0] + '.jpg'))
|
||||
osp.splitext(filename)[0] + '.png'))
|
||||
|
||||
print('Removing the temporary files...')
|
||||
|
||||
|
|
Loading…
Reference in New Issue