Skip to content
Snippets Groups Projects
Commit 35dcc231 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

[configs.datasets] Add resources for matched test (mtest)

parent 2d66af36
No related branches found
No related tags found
1 merge request!12Streamlining
Pipeline #39328 passed
#!/usr/bin/env python
# coding=utf-8
"""CHASE-DB1 cross-evaluation dataset with matched resolution
* Configuration resolution (height x width): 960 x 960
"""
from bob.ip.binseg.data.transforms import CenterCrop, Pad, Resize
from bob.ip.binseg.configs.datasets.chasedb1.xtest import dataset as _xt
dataset = {
"train": _xt["train"],
"test": _xt["test"],
"drive": _xt["drive"].copy([CenterCrop((544, 544)), Resize(960)]),
"stare": _xt["stare"].copy(
[Pad((0, 32, 0, 32)), Resize(960), CenterCrop(960)]
),
"hrf": _xt["hrf"].copy([Pad((0, 584, 0, 584)), Resize(960)]),
"iostar": _xt["iostar"].copy([Resize(960)]),
}
#!/usr/bin/env python
# coding=utf-8
"""DRIVE cross-evaluation dataset with matched resolution
* Configuration resolution: 544 x 544
"""
from bob.ip.binseg.data.transforms import Resize, Pad, Crop
from bob.ip.binseg.configs.datasets.drive.xtest import dataset as _xt
dataset = {
"train": _xt["train"],
"test": _xt["test"],
"stare": _xt["stare"].copy([Resize(471), Pad((0, 37, 0, 36))]),
"chasedb1": _xt["chasedb1"].copy([Resize(544), Crop(0, 12, 544, 544)]),
"hrf": _xt["hrf"].copy([Resize((363)), Pad((0, 90, 0, 91))]),
"iostar": _xt["iostar"].copy([Resize(544)]),
}
#!/usr/bin/env python
# coding=utf-8
"""HRF cross-evaluation dataset with matched resolution
* Configuration resolution: 1168 x 1648
"""
from bob.ip.binseg.data.transforms import Crop, Pad, Resize
from bob.ip.binseg.configs.datasets.hrf.xtest import dataset as _xt
dataset = {
"train": _xt["train"],
"test": _xt["test"],
"drive": _xt["drive"].copy(
[Crop(75, 10, 416, 544), Pad((21, 0, 22, 0)), Resize(1168)]
),
"stare": _xt["stare"].copy(
[Crop(50, 0, 500, 705), Resize(1168), Pad((1, 0, 1, 0))]
),
"chasedb1": _xt["chasedb1"].copy([Crop(140, 18, 680, 960), Resize(1168)]),
"iostar": _xt["iostar"].copy(
[Crop(144, 0, 768, 1024), Pad((30, 0, 30, 0)), Resize(1168)]
),
}
#!/usr/bin/env python
# coding=utf-8
"""IOSTAR vessel cross-evaluation dataset with matched resolution
* Configuration resolution: 1024 x 1024
"""
from bob.ip.binseg.data.transforms import CenterCrop, Crop, Pad, Resize
from bob.ip.binseg.configs.datasets.iostar.vessel_xtest import dataset as _xt
dataset = {
"train": _xt["train"],
"test": _xt["test"],
"drive": _xt["drive"].copy([CenterCrop((540, 540)), Resize(1024)]),
"stare": _xt["stare"].copy(
[Pad((0, 32, 0, 32)), Resize(1024), CenterCrop(1024)]
),
"chasedb1": _xt["chasedb1"].copy([Crop(0, 18, 960, 960), Resize(1024)]),
"hrf": _xt["hrf"].copy([Pad((0, 584, 0, 584)), Resize(1024)]),
}
#!/usr/bin/env python
# coding=utf-8
"""STARE cross-evaluation dataset with matched resolution
* Configuration resolution: 704 x 608
"""
from bob.ip.binseg.data.transforms import CenterCrop, Pad, Resize
from bob.ip.binseg.configs.datasets.stare.xtest import dataset as _xt
dataset = {
"train": _xt["train"],
"test": _xt["test"],
"drive": _xt["drive"].copy(
[CenterCrop((470, 544)), Pad((10, 9, 10, 8)), Resize(608)]
),
"chasedb1": _xt["chasedb1"].copy([CenterCrop((829, 960)), Resize(608)]),
"hrf": _xt["hrf"].copy([Pad((0, 345, 0, 345)), Resize(608)]),
"iostar": _xt["iostar"].copy([Pad((81, 0, 81, 0)), Resize(608)]),
}
......@@ -125,6 +125,16 @@ class SampleListDataset(torch.utils.data.Dataset):
It supports indexing such that dataset[i] can be used to get ith sample.
Attributes
----------
transforms : list
An accessor to the list of transforms to be applied (excluding the last
transform, which is fixed). Notice that, after setting, a last transform
(:py:class:`bob.ip.binseg.data.transforms.ToTensor`) is always applied
- you do not need to add that.
Parameters
----------
......@@ -134,14 +144,36 @@ class SampleListDataset(torch.utils.data.Dataset):
transforms : :py:class:`list`, Optional
a list of transformations to be applied to **both** image and
ground-truth data. Notice a last transform
(:py:class:`bob.ip.binseg.data.transforms.ToTensor`) is always applied.
(:py:class:`bob.ip.binseg.data.transforms.ToTensor`) is always applied
- you do not need to add that.
"""
def __init__(self, samples, transforms=[]):
self._samples = samples
self._transforms = Compose(transforms + [ToTensor()])
self.transforms = transforms
@property
def transforms(self):
return self._transforms.transforms[:-1]
@transforms.setter
def transforms(self, l):
self._transforms = Compose(l + [ToTensor()])
def copy(self, transforms=None):
"""Returns a deep copy of itself, optionally resetting transforms
Parameters
----------
transforms : :py:class:`list`, Optional
An optional list of transforms to set in the copy. If not
specified, use ``self.transforms``.
"""
return SampleListDataset(self._samples, transforms or self.transforms)
def __len__(self):
"""
......
......@@ -45,7 +45,35 @@ def test_drive():
_check_subset(dataset["test"], 20)
@rc_variable_set("bob.ip.binseg.stare.datadir")
@rc_variable_set("bob.ip.binseg.drive.datadir")
@stare_variable_set("bob.ip.binseg.stare.datadir")
@rc_variable_set("bob.ip.binseg.chasedb1.datadir")
@rc_variable_set("bob.ip.binseg.hrf.datadir")
@rc_variable_set("bob.ip.binseg.iostar.datadir")
def test_drive_mtest():
from ..configs.datasets.drive.mtest import dataset
nose.tools.eq_(len(dataset), 6)
from ..configs.datasets.drive.default import dataset as baseline
nose.tools.eq_(dataset["train"], baseline["train"])
nose.tools.eq_(dataset["test"], baseline["test"])
for subset in dataset:
for sample in dataset[subset]:
assert 3 <= len(sample) <= 4
assert isinstance(sample[0], str)
nose.tools.eq_(sample[1].shape, (3, 544, 544)) #planes, height, width
nose.tools.eq_(sample[1].dtype, torch.float32)
nose.tools.eq_(sample[2].shape, (1, 544, 544))
nose.tools.eq_(sample[2].dtype, torch.float32)
if len(sample) == 4:
nose.tools.eq_(sample[3].shape, (1, 544, 544))
nose.tools.eq_(sample[3].dtype, torch.float32)
@rc_variable_set("bob.ip.binseg.drive.datadir")
@stare_variable_set("bob.ip.binseg.stare.datadir")
@rc_variable_set("bob.ip.binseg.chasedb1.datadir")
@rc_variable_set("bob.ip.binseg.hrf.datadir")
@rc_variable_set("bob.ip.binseg.iostar.datadir")
......@@ -74,7 +102,7 @@ def test_drive_covd():
@rc_variable_set("bob.ip.binseg.drive.datadir")
@rc_variable_set("bob.ip.binseg.stare.datadir")
@stare_variable_set("bob.ip.binseg.stare.datadir")
@rc_variable_set("bob.ip.binseg.chasedb1.datadir")
@rc_variable_set("bob.ip.binseg.hrf.datadir")
@rc_variable_set("bob.ip.binseg.iostar.datadir")
......@@ -150,6 +178,34 @@ def test_stare():
_check_subset(dataset["test"], 10)
@rc_variable_set("bob.ip.binseg.drive.datadir")
@stare_variable_set("bob.ip.binseg.stare.datadir")
@rc_variable_set("bob.ip.binseg.chasedb1.datadir")
@rc_variable_set("bob.ip.binseg.hrf.datadir")
@rc_variable_set("bob.ip.binseg.iostar.datadir")
def test_stare_mtest():
from ..configs.datasets.stare.mtest import dataset
nose.tools.eq_(len(dataset), 6)
from ..configs.datasets.stare.ah import dataset as baseline
nose.tools.eq_(dataset["train"], baseline["train"])
nose.tools.eq_(dataset["test"], baseline["test"])
for subset in dataset:
for sample in dataset[subset]:
assert 3 <= len(sample) <= 4
assert isinstance(sample[0], str)
nose.tools.eq_(sample[1].shape, (3, 608, 704)) #planes,height,width
nose.tools.eq_(sample[1].dtype, torch.float32)
nose.tools.eq_(sample[2].shape, (1, 608, 704)) #planes,height,width
nose.tools.eq_(sample[2].dtype, torch.float32)
if len(sample) == 4:
nose.tools.eq_(sample[3].shape, (1, 608, 704))
nose.tools.eq_(sample[3].dtype, torch.float32)
@stare_variable_set("bob.ip.binseg.stare.datadir")
@rc_variable_set("bob.ip.binseg.drive.datadir")
@rc_variable_set("bob.ip.binseg.chasedb1.datadir")
@rc_variable_set("bob.ip.binseg.hrf.datadir")
......@@ -200,7 +256,35 @@ def test_chasedb1():
@rc_variable_set("bob.ip.binseg.drive.datadir")
@rc_variable_set("bob.ip.binseg.stare.datadir")
@stare_variable_set("bob.ip.binseg.stare.datadir")
@rc_variable_set("bob.ip.binseg.chasedb1.datadir")
@rc_variable_set("bob.ip.binseg.hrf.datadir")
@rc_variable_set("bob.ip.binseg.iostar.datadir")
def test_chasedb1_mtest():
from ..configs.datasets.chasedb1.mtest import dataset
nose.tools.eq_(len(dataset), 6)
from ..configs.datasets.chasedb1.first_annotator import dataset as baseline
nose.tools.eq_(dataset["train"], baseline["train"])
nose.tools.eq_(dataset["test"], baseline["test"])
for subset in dataset:
for sample in dataset[subset]:
assert 3 <= len(sample) <= 4
assert isinstance(sample[0], str)
nose.tools.eq_(sample[1].shape, (3, 960, 960)) #planes,height,width
nose.tools.eq_(sample[1].dtype, torch.float32)
nose.tools.eq_(sample[2].shape, (1, 960, 960)) #planes,height,width
nose.tools.eq_(sample[2].dtype, torch.float32)
if len(sample) == 4:
nose.tools.eq_(sample[3].shape, (1, 960, 960))
nose.tools.eq_(sample[3].dtype, torch.float32)
@rc_variable_set("bob.ip.binseg.drive.datadir")
@stare_variable_set("bob.ip.binseg.stare.datadir")
@rc_variable_set("bob.ip.binseg.chasedb1.datadir")
@rc_variable_set("bob.ip.binseg.hrf.datadir")
@rc_variable_set("bob.ip.binseg.iostar.datadir")
def test_chasedb1_covd():
......@@ -249,8 +333,36 @@ def test_hrf():
@rc_variable_set("bob.ip.binseg.drive.datadir")
@rc_variable_set("bob.ip.binseg.stare.datadir")
@stare_variable_set("bob.ip.binseg.stare.datadir")
@rc_variable_set("bob.ip.binseg.chasedb1.datadir")
@rc_variable_set("bob.ip.binseg.hrf.datadir")
@rc_variable_set("bob.ip.binseg.iostar.datadir")
def test_hrf_mtest():
from ..configs.datasets.hrf.mtest import dataset
nose.tools.eq_(len(dataset), 6)
from ..configs.datasets.hrf.default import dataset as baseline
nose.tools.eq_(dataset["train"], baseline["train"])
nose.tools.eq_(dataset["test"], baseline["test"])
for subset in dataset:
for sample in dataset[subset]:
assert 3 <= len(sample) <= 4
assert isinstance(sample[0], str)
nose.tools.eq_(sample[1].shape, (3, 1168, 1648)) #planes,height,width
nose.tools.eq_(sample[1].dtype, torch.float32)
nose.tools.eq_(sample[2].shape, (1, 1168, 1648)) #planes,height,width
nose.tools.eq_(sample[2].dtype, torch.float32)
if len(sample) == 4:
nose.tools.eq_(sample[3].shape, (1, 1168, 1648))
nose.tools.eq_(sample[3].dtype, torch.float32)
@rc_variable_set("bob.ip.binseg.drive.datadir")
@stare_variable_set("bob.ip.binseg.stare.datadir")
@rc_variable_set("bob.ip.binseg.chasedb1.datadir")
@rc_variable_set("bob.ip.binseg.hrf.datadir")
@rc_variable_set("bob.ip.binseg.iostar.datadir")
def test_hrf_covd():
......@@ -300,9 +412,37 @@ def test_iostar():
@rc_variable_set("bob.ip.binseg.drive.datadir")
@rc_variable_set("bob.ip.binseg.stare.datadir")
@stare_variable_set("bob.ip.binseg.stare.datadir")
@rc_variable_set("bob.ip.binseg.chasedb1.datadir")
@rc_variable_set("bob.ip.binseg.hrf.datadir")
@rc_variable_set("bob.ip.binseg.iostar.datadir")
def test_iostar_mtest():
from ..configs.datasets.iostar.vessel_mtest import dataset
nose.tools.eq_(len(dataset), 6)
from ..configs.datasets.iostar.vessel import dataset as baseline
nose.tools.eq_(dataset["train"], baseline["train"])
nose.tools.eq_(dataset["test"], baseline["test"])
for subset in dataset:
for sample in dataset[subset]:
assert 3 <= len(sample) <= 4
assert isinstance(sample[0], str)
nose.tools.eq_(sample[1].shape, (3, 1024, 1024)) #planes,height,width
nose.tools.eq_(sample[1].dtype, torch.float32)
nose.tools.eq_(sample[2].shape, (1, 1024, 1024)) #planes,height,width
nose.tools.eq_(sample[2].dtype, torch.float32)
if len(sample) == 4:
nose.tools.eq_(sample[3].shape, (1, 1024, 1024))
nose.tools.eq_(sample[3].dtype, torch.float32)
@rc_variable_set("bob.ip.binseg.drive.datadir")
@stare_variable_set("bob.ip.binseg.stare.datadir")
@rc_variable_set("bob.ip.binseg.chasedb1.datadir")
@rc_variable_set("bob.ip.binseg.hrf.datadir")
@rc_variable_set("bob.ip.binseg.iostar.datadir")
def test_iostar_covd():
from ..configs.datasets.iostar.covd import dataset
......
......@@ -138,23 +138,27 @@ Datasets
bob.ip.binseg.configs.datasets.chasedb1.first_annotator
bob.ip.binseg.configs.datasets.chasedb1.second_annotator
bob.ip.binseg.configs.datasets.chasedb1.xtest
bob.ip.binseg.configs.datasets.chasedb1.mtest
bob.ip.binseg.configs.datasets.chasedb1.covd
bob.ip.binseg.configs.datasets.chasedb1.ssl
bob.ip.binseg.configs.datasets.drive.default
bob.ip.binseg.configs.datasets.drive.second_annotator
bob.ip.binseg.configs.datasets.drive.xtest
bob.ip.binseg.configs.datasets.drive.mtest
bob.ip.binseg.configs.datasets.drive.covd
bob.ip.binseg.configs.datasets.drive.ssl
bob.ip.binseg.configs.datasets.hrf.default
bob.ip.binseg.configs.datasets.hrf.xtest
bob.ip.binseg.configs.datasets.hrf.mtest
bob.ip.binseg.configs.datasets.hrf.default_fullres
bob.ip.binseg.configs.datasets.hrf.covd
bob.ip.binseg.configs.datasets.hrf.ssl
bob.ip.binseg.configs.datasets.iostar.vessel
bob.ip.binseg.configs.datasets.iostar.vessel_xtest
bob.ip.binseg.configs.datasets.iostar.vessel_mtest
bob.ip.binseg.configs.datasets.iostar.optic_disc
bob.ip.binseg.configs.datasets.iostar.covd
bob.ip.binseg.configs.datasets.iostar.ssl
......@@ -162,6 +166,7 @@ Datasets
bob.ip.binseg.configs.datasets.stare.ah
bob.ip.binseg.configs.datasets.stare.vk
bob.ip.binseg.configs.datasets.stare.xtest
bob.ip.binseg.configs.datasets.stare.mtest
bob.ip.binseg.configs.datasets.stare.covd
bob.ip.binseg.configs.datasets.stare.ssl
......
......@@ -62,6 +62,7 @@ setup(
"drive = bob.ip.binseg.configs.datasets.drive.default",
"drive-2nd = bob.ip.binseg.configs.datasets.drive.second_annotator",
"drive-xtest = bob.ip.binseg.configs.datasets.drive.xtest",
"drive-mtest = bob.ip.binseg.configs.datasets.drive.mtest",
"drive-covd = bob.ip.binseg.configs.datasets.drive.covd",
"drive-ssl = bob.ip.binseg.configs.datasets.drive.ssl",
......@@ -69,12 +70,14 @@ setup(
"stare = bob.ip.binseg.configs.datasets.stare.ah",
"stare-2nd = bob.ip.binseg.configs.datasets.stare.vk",
"stare-xtest = bob.ip.binseg.configs.datasets.stare.xtest",
"stare-mtest = bob.ip.binseg.configs.datasets.stare.mtest",
"stare-covd = bob.ip.binseg.configs.datasets.stare.covd",
"stare-ssl = bob.ip.binseg.configs.datasets.stare.ssl",
# iostar
"iostar-vessel = bob.ip.binseg.configs.datasets.iostar.vessel",
"iostar-vessel-xtest = bob.ip.binseg.configs.datasets.iostar.vessel_xtest",
"iostar-vessel-mtest = bob.ip.binseg.configs.datasets.iostar.vessel_mtest",
"iostar-disc = bob.ip.binseg.configs.datasets.iostar.optic_disc",
"iostar-vessel-covd = bob.ip.binseg.configs.datasets.iostar.covd",
"iostar-vessel-ssl = bob.ip.binseg.configs.datasets.iostar.ssl",
......@@ -82,6 +85,7 @@ setup(
# hrf
"hrf = bob.ip.binseg.configs.datasets.hrf.default",
"hrf-xtest = bob.ip.binseg.configs.datasets.hrf.xtest",
"hrf-mtest = bob.ip.binseg.configs.datasets.hrf.mtest",
"hrf-highres = bob.ip.binseg.configs.datasets.hrf.default_fullres",
"hrf-covd = bob.ip.binseg.configs.datasets.hrf.covd",
"hrf-ssl = bob.ip.binseg.configs.datasets.hrf.ssl",
......@@ -90,6 +94,7 @@ setup(
"chasedb1 = bob.ip.binseg.configs.datasets.chasedb1.first_annotator",
"chasedb1-2nd = bob.ip.binseg.configs.datasets.chasedb1.second_annotator",
"chasedb1-xtest = bob.ip.binseg.configs.datasets.chasedb1.xtest",
"chasedb1-mtest = bob.ip.binseg.configs.datasets.chasedb1.mtest",
"chasedb1-covd = bob.ip.binseg.configs.datasets.chasedb1.covd",
"chasedb1-ssl = bob.ip.binseg.configs.datasets.chasedb1.ssl",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment