Coverage for src/deepdraw/data/rimoner3/__init__.py: 93%
15 statements
« prev ^ index » next coverage.py v7.4.2, created at 2024-03-29 22:17 +0100
« prev ^ index » next coverage.py v7.4.2, created at 2024-03-29 22:17 +0100
1# SPDX-FileCopyrightText: Copyright © 2023 Idiap Research Institute <contact@idiap.ch>
2#
3# SPDX-License-Identifier: GPL-3.0-or-later
5"""RIM-ONE r3 (training set) for Cup Segmentation.
7The dataset contains 159 stereo eye fundus images with a resolution of 2144 x
81424. The right part of the stereo image is disregarded. Two sets of
9ground-truths for optic disc and optic cup are available. The first set is
10commonly used for training and testing. The second set acts as a “human”
11baseline. A third set, composed of annotation averages may also be used for
12training and evaluation purposes.
14* Reference: [RIMONER3-2015]_
15* Original resolution (height x width): 1424 x 1072
16* Split reference: [MANINIS-2016]_
17* Protocols ``optic-disc-exp1``, ``optic-cup-exp1``, ``optic-disc-exp2``,
18 ``optic-cup-exp2``, ``optic-disc-avg`` and ``optic-cup-avg``:
20 * Training: 99
21 * Test: 60
22"""
24import os
26import pkg_resources
28from ...data.dataset import JSONDataset
29from ...utils.rc import load_rc
30from ..loader import load_pil_1, load_pil_rgb, make_delayed
32_protocols = [
33 pkg_resources.resource_filename(__name__, "optic-disc-exp1.json"),
34 pkg_resources.resource_filename(__name__, "optic-cup-exp1.json"),
35 pkg_resources.resource_filename(__name__, "optic-disc-exp2.json"),
36 pkg_resources.resource_filename(__name__, "optic-cup-exp2.json"),
37 pkg_resources.resource_filename(__name__, "optic-disc-avg.json"),
38 pkg_resources.resource_filename(__name__, "optic-cup-avg.json"),
39]
41_root_path = load_rc().get("datadir.rimoner3", os.path.realpath(os.curdir))
42_pkg_path = pkg_resources.resource_filename(__name__, "masks")
45def _raw_data_loader(sample):
46 # RIM-ONE r3 provides stereo images - we clip them here to get only the
47 # left part of the image, which is also annotated
48 return dict(
49 data=load_pil_rgb(os.path.join(_root_path, sample["data"])).crop(
50 (0, 0, 1072, 1424)
51 ),
52 label=load_pil_1(os.path.join(_root_path, sample["label"])).crop(
53 (0, 0, 1072, 1424)
54 ),
55 mask=load_pil_1(os.path.join(_pkg_path, sample["mask"])).crop(
56 (0, 0, 1072, 1424)
57 ),
58 )
61def _loader(context, sample):
62 # "context" is ignored in this case - database is homogeneous
63 # we returned delayed samples to avoid loading all images at once
64 return make_delayed(sample, _raw_data_loader)
67dataset = JSONDataset(
68 protocols=_protocols,
69 fieldnames=("data", "label", "mask"),
70 loader=_loader,
71)
72"""RIM-ONE r3 dataset object."""