Python API

Database

class bob.db.drive.query.FileList(db_json)[source]

Bases: object

FileList object that loads the protocol as defined in a json file. Provides a __getitem__ interface.

class bob.db.drive.query.Database(protocol='default')[source]

Bases: object

A low level database interface to be used with PyTorch or other deep learning frameworks.

protocol

protocol defining the train-test split.

Type

str

property paths

returns: paths – list of all paths of all samples :rtype: list

samples(split=None)[source]

Given a split, returns a list of Sample objects.

Parameters

split (str) – ‘train’, ‘test’ or None (returns all samples)

Returns

samples – list of Sample objects

Return type

list

Sample

class bob.db.drive.models.FundusImage(path)[source]

Bases: object

Generic fundus image object.

property basename

Returns the file name

Returns

name

Return type

str

property size

returns: size – the fundus image resolution in (W, H). :rtype: tuple

pil_image(datadir=None)[source]
Returns

img

Return type

PIL.Image.Image

class bob.db.drive.models.GroundTruth(path, threshold=None, drawsize=None)[source]

Bases: object

Generic ground truth object.

  • Allows for thresholding in case there are multiple ground truth annotations in one bitmap

  • Allows for “on-the-fly” drawing of ground truth annotations with a specified size

Parameters
  • path (str) – relative path to the file on disk

  • threshold (float) – in range [0,1] used to threshold ground-truth image data with multiple classes e.g. optic disc and cup

  • drawsize (tuple) – size tuple in pillow (W, H) format. Used for cases where drawing of gt is required

property basename

Returns the file name

Returns

name

Return type

str

property size

Retirms the ground truth image resolution in (W, H).

Returns

size

Return type

tuple

pil_image(datadir=None)[source]
Returns

gt – mode = ‘1’

Return type

PIL.Image.Image

class bob.db.drive.models.Mask(path)[source]

Bases: object

Generic mask object.

property basename

Returns the file name

Returns

name

Return type

str

property size

returns: size – the mask image resolution in (W, H). :rtype: tuple

pil_image(datadir=None)[source]
Returns

mask – mode = ‘1’

Return type

PIL.Image.Image

class bob.db.drive.models.Sample(img, gt, mask)[source]

Bases: object

Generic Sample object

High level sample class that combines the objects ‘FundusImage’, ‘GroundTruth’ and ‘Mask’. Allows for access of the subclass, e.g. :

>>> img = FundusImage('path/to/some_img.file')
>>> gt = GroundTruth('path/to/some_gt.file')
>>> mask = Mask('path/to/some_mask.file')
>>> mysample = Sample(img, gt, mask)
>>> mysample.img.basename
'some_img.file'
>>> mysample.gt.basename
'some_gt.file'
>>> mysample.mask.basename
'some_mask.file'
>>>
Parameters
property paths

returns: paths – paths of image, ground truth and mask :rtype: list