Coverage for src/deepdraw/data/drive/__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"""DRIVE dataset for Vessel Segmentation. 

6 

7The DRIVE database has been established to enable comparative studies on 

8segmentation of blood vessels in retinal images. 

9 

10* Reference: [DRIVE-2004]_ 

11* Original resolution (height x width): 584 x 565 

12* Split reference: [DRIVE-2004]_ 

13* Protocol ``default``: 

14 

15 * Training samples: 20 (including labels and masks) 

16 * Test samples: 20 (including labels from annotator 1 and masks) 

17 

18* Protocol ``second-annotator``: 

19 

20 * Test samples: 20 (including labels from annotator 2 and masks) 

21""" 

22 

23import os 

24 

25import pkg_resources 

26 

27from ...data.dataset import JSONDataset 

28from ...utils.rc import load_rc 

29from ..loader import load_pil_1, load_pil_rgb, make_delayed 

30 

31_protocols = [ 

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

33 pkg_resources.resource_filename(__name__, "second-annotator.json"), 

34] 

35 

36_root_path = load_rc().get("datadir.drive", os.path.realpath(os.curdir)) 

37 

38 

39def _raw_data_loader(sample): 

40 return dict( 

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

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

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

44 ) 

45 

46 

47def _loader(context, sample): 

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

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

50 return make_delayed(sample, _raw_data_loader) 

51 

52 

53dataset = JSONDataset( 

54 protocols=_protocols, 

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

56 loader=_loader, 

57) 

58"""DRIVE dataset object."""