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