Coverage for src/deepdraw/data/avdrive/__init__.py: 0%
15 statements
« prev ^ index » next coverage.py v7.3.1, created at 2023-11-30 15:00 +0100
« prev ^ index » next coverage.py v7.3.1, created at 2023-11-30 15:00 +0100
1# SPDX-FileCopyrightText: Copyright © 2023 Idiap Research Institute <contact@idiap.ch>
2#
3# SPDX-License-Identifier: GPL-3.0-or-later
5"""AV_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
17"""
19import os
21import pkg_resources
23from ...data.dataset import JSONDataset
24from ...utils.rc import load_rc
25from ..loader import load_pil_1, load_pil_rgb, make_delayed
27_protocols = [pkg_resources.resource_filename(__name__, "default.json")]
29_root_path_drive = load_rc().get("datadir.drive", os.path.realpath(os.curdir))
30_root_path_av_drive = load_rc().get(
31 "datadir.avdrive", os.path.realpath(os.curdir)
32)
35def _raw_data_loader(sample):
36 return dict(
37 data=load_pil_rgb(os.path.join(_root_path_drive, sample["data"])),
38 label=load_pil_1(os.path.join(_root_path_av_drive, sample["label"])),
39 mask=load_pil_1(os.path.join(_root_path_drive, sample["mask"])),
40 )
43def _loader(context, sample):
44 # "context" is ignored in this case - database is homogeneous
45 # we returned delayed samples to avoid loading all images at once
46 return make_delayed(sample, _raw_data_loader)
49dataset = JSONDataset(
50 protocols=_protocols,
51 fieldnames=("data", "label", "mask"),
52 loader=_loader,
53)
54"""DRIVE dataset object."""