Coverage for src/deepdraw/data/hrf/__init__.py: 93%

14 statements  

« 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 

4 

5"""HRF dataset for Vessel Segmentation. 

6 

7The database includes 15 images of each healthy, diabetic retinopathy (DR), and 

8glaucomatous eyes. It contains a total of 45 eye fundus images with a 

9resolution of 3304 x 2336. One set of ground-truth vessel annotations is 

10available. 

11 

12* Reference: [HRF-2013]_ 

13* Original resolution (height x width): 2336 x 3504 

14* Configuration resolution: 1168 x 1648 (after specific cropping and rescaling) 

15* Split reference: [ORLANDO-2017]_ 

16* Protocol ``default``: 

17 

18 * Training samples: 15 (including labels) 

19 * Test samples: 30 (including labels) 

20""" 

21 

22import os 

23 

24import pkg_resources 

25 

26from ...data.dataset import JSONDataset 

27from ...utils.rc import load_rc 

28from ..loader import load_pil_1, load_pil_rgb, make_delayed 

29 

30_protocols = [ 

31 pkg_resources.resource_filename(__name__, "default.json"), 

32] 

33 

34_root_path = load_rc().get("datadir.hrf", os.path.realpath(os.curdir)) 

35 

36 

37def _raw_data_loader(sample): 

38 return dict( 

39 data=load_pil_rgb(os.path.join(_root_path, sample["data"])), 

40 label=load_pil_1(os.path.join(_root_path, sample["label"])), 

41 mask=load_pil_1(os.path.join(_root_path, sample["mask"])), 

42 ) 

43 

44 

45def _loader(context, sample): 

46 # "context" is ignored in this case - database is homogeneous 

47 # we returned delayed samples to avoid loading all images at once 

48 return make_delayed(sample, _raw_data_loader) 

49 

50 

51dataset = JSONDataset( 

52 protocols=_protocols, 

53 fieldnames=("data", "label", "mask"), 

54 loader=_loader, 

55) 

56"""HRF dataset object."""