Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#!/usr/bin/env python
2# coding=utf-8
4"""STARE dataset for Vessel Segmentation
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.
12* Reference: [STARE-2000]_
13* Original resolution (width x height): 700 x 605
14* Split reference: [MANINIS-2016]_
15* Protocol ``ah`` (default baseline):
17 * Training samples: 10 (including labels from annotator "ah")
18 * Test samples: 10 (including labels from annotator "ah")
20* Protocol ``vk`` (normally used as human comparison):
22 * Training samples: 10 (including labels from annotator "vk")
23 * Test samples: 10 (including labels from annotator "vk")
25"""
27import os
29import pkg_resources
31import bob.extension
33from ..dataset import JSONDataset
34from ..loader import load_pil_1, load_pil_rgb, make_delayed
36_protocols = [
37 pkg_resources.resource_filename(__name__, "ah.json"),
38 pkg_resources.resource_filename(__name__, "vk.json"),
39]
41_fieldnames = ("data", "label", "mask")
43_root_path = bob.extension.rc.get(
44 "bob.ip.binseg.stare.datadir", os.path.realpath(os.curdir)
45)
47_pkg_path = pkg_resources.resource_filename(__name__, "masks")
50class _make_loader:
51 # hack to get testing on the CI working fine for this dataset
53 def __init__(self, root_path):
54 self.root_path = root_path
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 )
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__)
69def _make_dataset(root_path):
71 return JSONDataset(
72 protocols=_protocols,
73 fieldnames=_fieldnames,
74 loader=_make_loader(root_path),
75 )
78dataset = _make_dataset(_root_path)
79"""STARE dataset object"""