1#!/usr/bin/env python
2# coding=utf-8
3
4"""STARE dataset for Vessel Segmentation
5
6A subset of the original STARE dataset contains 20 annotated eye fundus images
7with a resolution of 700 x 605 (width x height). Two sets of ground-truth
8vessel annotations are available. The first set by Adam Hoover ("ah") is
9commonly used for training and testing. The second set by Valentina Kouznetsova
10("vk") is typically used as a “human” baseline.
11
12* Reference: [STARE-2000]_
13* Original resolution (width x height): 700 x 605
14* Split reference: [MANINIS-2016]_
15* Protocol ``ah`` (default baseline):
16
17 * Training samples: 10 (including labels from annotator "ah")
18 * Test samples: 10 (including labels from annotator "ah")
19
20* Protocol ``vk`` (normally used as human comparison):
21
22 * Training samples: 10 (including labels from annotator "vk")
23 * Test samples: 10 (including labels from annotator "vk")
24
25"""
26
27import os
28
29import pkg_resources
30
31import bob.extension
32
33from ..dataset import JSONDataset
34from ..loader import load_pil_1, load_pil_rgb, make_delayed
35
36_protocols = [
37 pkg_resources.resource_filename(__name__, "ah.json"),
38 pkg_resources.resource_filename(__name__, "vk.json"),
39]
40
41_fieldnames = ("data", "label", "mask")
42
43_root_path = bob.extension.rc.get(
44 "bob.ip.binseg.stare.datadir", os.path.realpath(os.curdir)
45)
46
47_pkg_path = pkg_resources.resource_filename(__name__, "masks")
48
49
50class _make_loader:
51 # hack to get testing on the CI working fine for this dataset
52
53 def __init__(self, root_path):
54 self.root_path = root_path
55
56 def __raw_data_loader__(self, sample):
57 return dict(
58 data=load_pil_rgb(os.path.join(self.root_path, sample["data"])),
59 label=load_pil_1(os.path.join(self.root_path, sample["label"])),
60 mask=load_pil_1(os.path.join(_pkg_path, sample["mask"])),
61 )
62
63 def __call__(self, context, sample):
64 # "context" is ignored in this case - database is homogeneous
65 # we returned delayed samples to avoid loading all images at once
66 return make_delayed(sample, self.__raw_data_loader__)
67
68
69def _make_dataset(root_path):
70
71 return JSONDataset(
72 protocols=_protocols,
73 fieldnames=_fieldnames,
74 loader=_make_loader(root_path),
75 )
76
77
78dataset = _make_dataset(_root_path)
79"""STARE dataset object"""