Coverage for src/deepdraw/data/stare/__init__.py: 100%
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"""STARE dataset for Vessel Segmentation.
7A subset of the original STARE dataset contains 20 annotated eye fundus images
8with a resolution of 700 x 605 (width x height). Two sets of ground-truth
9vessel annotations are available. The first set by Adam Hoover ("ah") is
10commonly used for training and testing. The second set by Valentina Kouznetsova
11("vk") is typically used as a “human” baseline.
13* Reference: [STARE-2000]_
14* Original resolution (width x height): 700 x 605
15* Split reference: [MANINIS-2016]_
16* Protocol ``ah`` (default baseline):
18 * Training samples: 10 (including labels from annotator "ah")
19 * Test samples: 10 (including labels from annotator "ah")
21* Protocol ``vk`` (normally used as human comparison):
23 * Training samples: 10 (including labels from annotator "vk")
24 * Test samples: 10 (including labels from annotator "vk")
25"""
27import os
29import pkg_resources
31from ...data.dataset import JSONDataset
32from ...utils.rc import load_rc
33from ..loader import load_pil_1, load_pil_rgb, make_delayed
35_protocols = [
36 pkg_resources.resource_filename(__name__, "ah.json"),
37 pkg_resources.resource_filename(__name__, "vk.json"),
38]
40_root_path = load_rc().get("datadir.stare", os.path.realpath(os.curdir))
41_pkg_path = pkg_resources.resource_filename(__name__, "masks")
44def _raw_data_loader(sample):
45 return dict(
46 data=load_pil_rgb(os.path.join(_root_path, sample["data"])),
47 label=load_pil_1(os.path.join(_root_path, sample["label"])),
48 mask=load_pil_1(os.path.join(_pkg_path, sample["mask"])),
49 )
52def _loader(context, sample):
53 # "context" is ignored in this case - database is homogeneous
54 # we returned delayed samples to avoid loading all images at once
55 return make_delayed(sample, _raw_data_loader)
58dataset = JSONDataset(
59 protocols=_protocols,
60 fieldnames=("data", "label", "mask"),
61 loader=_loader,
62)
63"""STARE dataset object."""