Coverage for src/deepdraw/data/drive/__init__.py: 93%
14 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"""DRIVE dataset for Vessel Segmentation.
7The DRIVE database has been established to enable comparative studies on
8segmentation of blood vessels in retinal images.
10* Reference: [DRIVE-2004]_
11* Original resolution (height x width): 584 x 565
12* Split reference: [DRIVE-2004]_
13* Protocol ``default``:
15 * Training samples: 20 (including labels and masks)
16 * Test samples: 20 (including labels from annotator 1 and masks)
18* Protocol ``second-annotator``:
20 * Test samples: 20 (including labels from annotator 2 and masks)
21"""
23import os
25import pkg_resources
27from ...data.dataset import JSONDataset
28from ...utils.rc import load_rc
29from ..loader import load_pil_1, load_pil_rgb, make_delayed
31_protocols = [
32 pkg_resources.resource_filename(__name__, "default.json"),
33 pkg_resources.resource_filename(__name__, "second-annotator.json"),
34]
36_root_path = load_rc().get("datadir.drive", os.path.realpath(os.curdir))
39def _raw_data_loader(sample):
40 return dict(
41 data=load_pil_rgb(os.path.join(_root_path, sample["data"])),
42 label=load_pil_1(os.path.join(_root_path, sample["label"])),
43 mask=load_pil_1(os.path.join(_root_path, sample["mask"])),
44 )
47def _loader(context, sample):
48 # "context" is ignored in this case - database is homogeneous
49 # we returned delayed samples to avoid loading all images at once
50 return make_delayed(sample, _raw_data_loader)
53dataset = JSONDataset(
54 protocols=_protocols,
55 fieldnames=("data", "label", "mask"),
56 loader=_loader,
57)
58"""DRIVE dataset object."""