From 53cdf6918b5a608e97efdfbf2e4db471e70e110b Mon Sep 17 00:00:00 2001 From: Tim Laibacher <tim.laibacher@idiap.ch> Date: Tue, 2 Jul 2019 09:30:38 +0200 Subject: [PATCH] Add more configs and some doc --- .../binseg/configs/datasets/allvessel544.py | 90 ------------------- .../configs/datasets/allvessel544test.py | 86 ------------------ bob/ip/binseg/configs/datasets/chasedb1544.py | 4 +- .../{chasedb1544test.py => chasedb1608.py} | 12 ++- .../configs/datasets/drive1024ssliostar.py | 42 --------- .../configs/datasets/drive1168sslhrf.py | 47 ---------- .../configs/datasets/drive2336sslhrf.py | 46 ---------- .../binseg/configs/datasets/drive2336test.py | 21 ----- .../datasets/drivechasedb1iostarhrf608.py | 10 +++ .../drivechasedb1iostarhrf608sslstare.py | 34 +++++++ .../drivestarechasedb1hrfl1024_all.py | 14 +++ .../drivestarechasedb1iostar1168_all.py | 13 +++ .../datasets/drivestareiostarhrf960.py | 10 +++ .../datasets/drivestareiostarhrf960_all.py | 14 +++ bob/ip/binseg/configs/datasets/hrf544.py | 24 +++++ bob/ip/binseg/configs/datasets/hrf608.py | 24 +++++ .../{drive2336.py => iostarvessel544.py} | 8 +- .../configs/datasets/iostarvessel608.py | 24 +++++ .../configs/datasets/stare1168sslhrf.py | 47 ---------- .../configs/datasets/stare1168sslhrfrefuge.py | 69 -------------- bob/ip/binseg/configs/datasets/stare544.py | 1 - .../datasets/starechasedb1iostarhrf544.py | 10 +++ .../starechasedb1iostarhrf544ssldrive.py | 34 +++++++ .../models/{m2unetssl0703.py => driussl.py} | 10 +-- bob/ip/binseg/configs/models/m2unetssl.py | 2 +- bob/ip/binseg/modeling/losses.py | 2 +- doc/benchmarkresults.rst | 25 ++++++ doc/datasets.rst | 52 +++++------ doc/index.rst | 1 + doc/links.rst | 46 +++++++++- setup.py | 1 + 31 files changed, 330 insertions(+), 493 deletions(-) delete mode 100644 bob/ip/binseg/configs/datasets/allvessel544.py delete mode 100644 bob/ip/binseg/configs/datasets/allvessel544test.py rename bob/ip/binseg/configs/datasets/{chasedb1544test.py => chasedb1608.py} (50%) delete mode 100644 bob/ip/binseg/configs/datasets/drive1024ssliostar.py delete mode 100644 bob/ip/binseg/configs/datasets/drive1168sslhrf.py delete mode 100644 bob/ip/binseg/configs/datasets/drive2336sslhrf.py delete mode 100644 bob/ip/binseg/configs/datasets/drive2336test.py create mode 100644 bob/ip/binseg/configs/datasets/drivechasedb1iostarhrf608.py create mode 100644 bob/ip/binseg/configs/datasets/drivechasedb1iostarhrf608sslstare.py create mode 100644 bob/ip/binseg/configs/datasets/drivestarechasedb1hrfl1024_all.py create mode 100644 bob/ip/binseg/configs/datasets/drivestarechasedb1iostar1168_all.py create mode 100644 bob/ip/binseg/configs/datasets/drivestareiostarhrf960.py create mode 100644 bob/ip/binseg/configs/datasets/drivestareiostarhrf960_all.py create mode 100644 bob/ip/binseg/configs/datasets/hrf544.py create mode 100644 bob/ip/binseg/configs/datasets/hrf608.py rename bob/ip/binseg/configs/datasets/{drive2336.py => iostarvessel544.py} (71%) create mode 100644 bob/ip/binseg/configs/datasets/iostarvessel608.py delete mode 100644 bob/ip/binseg/configs/datasets/stare1168sslhrf.py delete mode 100644 bob/ip/binseg/configs/datasets/stare1168sslhrfrefuge.py create mode 100644 bob/ip/binseg/configs/datasets/starechasedb1iostarhrf544.py create mode 100644 bob/ip/binseg/configs/datasets/starechasedb1iostarhrf544ssldrive.py rename bob/ip/binseg/configs/models/{m2unetssl0703.py => driussl.py} (80%) create mode 100644 doc/benchmarkresults.rst diff --git a/bob/ip/binseg/configs/datasets/allvessel544.py b/bob/ip/binseg/configs/datasets/allvessel544.py deleted file mode 100644 index 9044cebc..00000000 --- a/bob/ip/binseg/configs/datasets/allvessel544.py +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -from bob.db.drive import Database as DRIVE -from bob.db.stare import Database as STARE -from bob.db.chasedb1 import Database as CHASEDB1 -from bob.db.iostar import Database as IOSTAR -from bob.db.hrf import Database as HRF -from bob.ip.binseg.data.transforms import * -from bob.ip.binseg.data.binsegdataset import BinSegDataset -import torch - -# Target size: 544x544 (DRIVE) - -defaulttransforms = [RandomHFlip() - ,RandomVFlip() - ,RandomRotation() - ,ColorJitter() - ,ToTensor()] - - -# DRIVE -transforms_drive = Compose([ - CenterCrop((544,544)) - ,*defaulttransforms - ]) - -# bob.db.dataset init -bobdb_drive = DRIVE(protocol = 'default') - -# PyTorch dataset -torch_drive = BinSegDataset(bobdb_drive, split='train', transform=transforms_drive) - - -# CHASE_DB1 -transforms_chase = Compose([ - Resize(544) - ,Crop(0,12,544,544) - ,*defaulttransforms - ]) - -# bob.db.dataset init -bobdb_chase = CHASEDB1(protocol = 'default') - -# PyTorch dataset -torch_chase = BinSegDataset(bobdb_chase, split='train', transform=transforms_chase) - - -# IOSTAR VESSEL -transforms_iostar = Compose([ - Resize(544) - ,*defaulttransforms - ]) - -# bob.db.dataset init -bobdb_iostar = IOSTAR(protocol='default_vessel') - -# PyTorch dataset -torch_iostar = BinSegDataset(bobdb_iostar, split='train', transform=transforms_iostar) - -# STARE -transforms = Compose([ - Resize(471) - ,Pad((0,37,0,36)) - ,*defaulttransforms - ]) - -# bob.db.dataset init -bobdb_stare = STARE(protocol = 'default') - -# PyTorch dataset -torch_stare = BinSegDataset(bobdb_stare, split='train', transform=transforms) - - -# HRF -transforms_hrf = Compose([ - Resize((363)) - ,Pad((0,90,0,91)) - ,*defaulttransforms - ]) - -# bob.db.dataset init -bobdb_hrf = HRF(protocol = 'default') - -# PyTorch dataset -torch_hrf = BinSegDataset(bobdb_hrf, split='train', transform=transforms_hrf) - - - -# Merge -dataset = torch.utils.data.ConcatDataset([torch_drive,torch_stare, torch_chase, torch_iostar, torch_hrf]) \ No newline at end of file diff --git a/bob/ip/binseg/configs/datasets/allvessel544test.py b/bob/ip/binseg/configs/datasets/allvessel544test.py deleted file mode 100644 index 55994e9e..00000000 --- a/bob/ip/binseg/configs/datasets/allvessel544test.py +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -from bob.db.drive import Database as DRIVE -from bob.db.stare import Database as STARE -from bob.db.chasedb1 import Database as CHASEDB1 -from bob.db.iostar import Database as IOSTAR -from bob.db.hrf import Database as HRF -from bob.ip.binseg.data.transforms import * -from bob.ip.binseg.data.binsegdataset import BinSegDataset -import torch - -# Target size: 544x544 (DRIVE) - -defaulttransforms = [ToTensor()] - - -# DRIVE -transforms_drive = Compose([ - CenterCrop((544,544)) - ,*defaulttransforms - ]) - -# bob.db.dataset init -bobdb_drive = DRIVE(protocol = 'default') - -# PyTorch dataset -torch_drive = BinSegDataset(bobdb_drive, split='test', transform=transforms_drive) - - -# CHASE_DB1 -transforms_chase = Compose([ - Resize(544) - ,Crop(0,12,544,544) - ,*defaulttransforms - ]) - -# bob.db.dataset init -bobdb_chase = CHASEDB1(protocol = 'default') - -# PyTorch dataset -torch_chase = BinSegDataset(bobdb_chase, split='test', transform=transforms_chase) - - -# IOSTAR VESSEL -transforms_iostar = Compose([ - Resize(544) - ,*defaulttransforms - ]) - -# bob.db.dataset init -bobdb_iostar = IOSTAR(protocol='default_vessel') - -# PyTorch dataset -torch_iostar = BinSegDataset(bobdb_iostar, split='test', transform=transforms_iostar) - -# STARE -transforms = Compose([ - Resize(471) - ,Pad((0,37,0,36)) - ,*defaulttransforms - ]) - -# bob.db.dataset init -bobdb_stare = STARE(protocol = 'default') - -# PyTorch dataset -torch_stare = BinSegDataset(bobdb_stare, split='test', transform=transforms) - - -# HRF -transforms_hrf = Compose([ - Resize((363)) - ,Pad((0,90,0,91)) - ,*defaulttransforms - ]) - -# bob.db.dataset init -bobdb_hrf = HRF(protocol = 'default') - -# PyTorch dataset -torch_hrf = BinSegDataset(bobdb_hrf, split='test', transform=transforms_hrf) - - - -# Merge -dataset = torch.utils.data.ConcatDataset([torch_drive,torch_stare, torch_chase, torch_iostar, torch_hrf]) \ No newline at end of file diff --git a/bob/ip/binseg/configs/datasets/chasedb1544.py b/bob/ip/binseg/configs/datasets/chasedb1544.py index 9d94cd3c..9632d539 100644 --- a/bob/ip/binseg/configs/datasets/chasedb1544.py +++ b/bob/ip/binseg/configs/datasets/chasedb1544.py @@ -8,11 +8,11 @@ from bob.ip.binseg.data.binsegdataset import BinSegDataset #### Config #### transforms = Compose([ - RandomRotation() - ,Resize(544) + Resize(544) ,Crop(0,12,544,544) ,RandomHFlip() ,RandomVFlip() + ,RandomRotation() ,ColorJitter() ,ToTensor() ]) diff --git a/bob/ip/binseg/configs/datasets/chasedb1544test.py b/bob/ip/binseg/configs/datasets/chasedb1608.py similarity index 50% rename from bob/ip/binseg/configs/datasets/chasedb1544test.py rename to bob/ip/binseg/configs/datasets/chasedb1608.py index aa5d00a5..9a475cae 100644 --- a/bob/ip/binseg/configs/datasets/chasedb1544test.py +++ b/bob/ip/binseg/configs/datasets/chasedb1608.py @@ -7,9 +7,13 @@ from bob.ip.binseg.data.binsegdataset import BinSegDataset #### Config #### -transforms = Compose([ - Resize(544) - ,Crop(0,12,544,544) +transforms = Compose([ + RandomRotation() + ,CenterCrop((829,960)) + ,Resize(608) + ,RandomHFlip() + ,RandomVFlip() + ,ColorJitter() ,ToTensor() ]) @@ -17,4 +21,4 @@ transforms = Compose([ bobdb = CHASEDB1(protocol = 'default') # PyTorch dataset -dataset = BinSegDataset(bobdb, split='test', transform=transforms) \ No newline at end of file +dataset = BinSegDataset(bobdb, split='train', transform=transforms) \ No newline at end of file diff --git a/bob/ip/binseg/configs/datasets/drive1024ssliostar.py b/bob/ip/binseg/configs/datasets/drive1024ssliostar.py deleted file mode 100644 index 0158c4a9..00000000 --- a/bob/ip/binseg/configs/datasets/drive1024ssliostar.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from bob.db.drive import Database as DRIVE -from bob.db.iostar import Database as IOSTAR -from bob.ip.binseg.data.transforms import * -from bob.ip.binseg.data.binsegdataset import BinSegDataset, SSLBinSegDataset, UnLabeledBinSegDataset - -#### Config #### - -#### Unlabeled IOSTAR TRAIN #### -unlabeled_transforms = Compose([ - RandomHFlip() - ,RandomVFlip() - ,RandomRotation() - ,ColorJitter() - ,ToTensor() - ]) - -# bob.db.dataset init -sslbobdb = IOSTAR(protocol = 'default_vessel') - -# PyTorch dataset -unlabeled_dataset = UnLabeledBinSegDataset(sslbobdb, split='train', transform=unlabeled_transforms) - - -#### Labeled #### -labeled_transforms = Compose([ - CenterCrop((540,540)) - ,Resize(1024) - ,RandomHFlip() - ,RandomVFlip() - ,RandomRotation() - ,ColorJitter() - ,ToTensor() - ]) - -# bob.db.dataset init -bobdb = DRIVE(protocol = 'default') - -# PyTorch dataset -dataset = SSLBinSegDataset(bobdb, unlabeled_dataset, split='train', transform=labeled_transforms) diff --git a/bob/ip/binseg/configs/datasets/drive1168sslhrf.py b/bob/ip/binseg/configs/datasets/drive1168sslhrf.py deleted file mode 100644 index 75f742d4..00000000 --- a/bob/ip/binseg/configs/datasets/drive1168sslhrf.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from bob.db.drive import Database as DRIVE -from bob.db.hrf import Database as HRF -from bob.ip.binseg.data.transforms import * -from bob.ip.binseg.data.binsegdataset import BinSegDataset, SSLBinSegDataset, UnLabeledBinSegDataset - -#### Config #### - -#### Unlabeled HRF TRAIN #### -unlabeled_transforms = Compose([ - Crop(0,108,2336,3296) - ,Resize(1168) - ,RandomHFlip() - ,RandomVFlip() - ,RandomRotation() - ,ColorJitter() - ,ToTensor() - ]) - -# bob.db.dataset init -hrfbobdb = HRF(protocol = 'default') - -# PyTorch dataset -unlabeled_dataset = UnLabeledBinSegDataset(hrfbobdb, split='train', transform=unlabeled_transforms) - - -#### Labeled #### -labeled_transforms = Compose([ - Crop(75,10,416,544) - ,Pad((21,0,22,0)) - ,Resize(1168) - ,RandomHFlip() - ,RandomVFlip() - ,RandomRotation() - ,ColorJitter() - ,ToTensor() - ]) - -# bob.db.dataset init -bobdb = DRIVE(protocol = 'default') -labeled_dataset = BinSegDataset(bobdb, split='train', transform=labeled_transforms) - -# SSL Dataset - -dataset = SSLBinSegDataset(labeled_dataset, unlabeled_dataset) \ No newline at end of file diff --git a/bob/ip/binseg/configs/datasets/drive2336sslhrf.py b/bob/ip/binseg/configs/datasets/drive2336sslhrf.py deleted file mode 100644 index 9b6102ff..00000000 --- a/bob/ip/binseg/configs/datasets/drive2336sslhrf.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from bob.db.drive import Database as DRIVE -from bob.db.hrf import Database as HRF -from bob.ip.binseg.data.transforms import * -from bob.ip.binseg.data.binsegdataset import BinSegDataset, SSLBinSegDataset, UnLabeledBinSegDataset - -#### Config #### - -#### Unlabeled HRF TRAIN #### -unlabeled_transforms = Compose([ - Crop(0,108,2336,3296) - ,RandomHFlip() - ,RandomVFlip() - ,RandomRotation() - ,ColorJitter() - ,ToTensor() - ]) - -# bob.db.dataset init -hrfbobdb = HRF(protocol = 'default') - -# PyTorch dataset -unlabeled_dataset = UnLabeledBinSegDataset(hrfbobdb, split='train', transform=unlabeled_transforms) - - -#### Labeled #### -labeled_transforms = Compose([ - Crop(75,10,416,544) - ,Pad((21,0,22,0)) - ,Resize(2336) - ,RandomHFlip() - ,RandomVFlip() - ,RandomRotation() - ,ColorJitter() - ,ToTensor() - ]) - -# bob.db.dataset init -bobdb = DRIVE(protocol = 'default') -labeled_dataset = BinSegDataset(bobdb, split='train', transform=labeled_transforms) - -# SSL Dataset - -dataset = SSLBinSegDataset(labeled_dataset, unlabeled_dataset) \ No newline at end of file diff --git a/bob/ip/binseg/configs/datasets/drive2336test.py b/bob/ip/binseg/configs/datasets/drive2336test.py deleted file mode 100644 index 9ce3b649..00000000 --- a/bob/ip/binseg/configs/datasets/drive2336test.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from bob.db.drive import Database as DRIVE -from bob.ip.binseg.data.transforms import * -from bob.ip.binseg.data.binsegdataset import BinSegDataset - -#### Config #### - -transforms = Compose([ - Crop(75,10,416,544) - ,Pad((21,0,22,0)) - ,Resize(2336) - ,ToTensor() - ]) - -# bob.db.dataset init -bobdb = DRIVE(protocol = 'default') - -# PyTorch dataset -dataset = BinSegDataset(bobdb, split='test', transform=transforms) \ No newline at end of file diff --git a/bob/ip/binseg/configs/datasets/drivechasedb1iostarhrf608.py b/bob/ip/binseg/configs/datasets/drivechasedb1iostarhrf608.py new file mode 100644 index 00000000..5ab57b8a --- /dev/null +++ b/bob/ip/binseg/configs/datasets/drivechasedb1iostarhrf608.py @@ -0,0 +1,10 @@ +from bob.ip.binseg.configs.datasets.drive608 import dataset as drive +from bob.ip.binseg.configs.datasets.chasedb1608 import dataset as chase +from bob.ip.binseg.configs.datasets.iostarvessel608 import dataset as iostar +from bob.ip.binseg.configs.datasets.hrf608 import dataset as hrf +import torch + +#### Config #### + +# PyTorch dataset +dataset = torch.utils.data.ConcatDataset([drive,chase,iostar,hrf]) \ No newline at end of file diff --git a/bob/ip/binseg/configs/datasets/drivechasedb1iostarhrf608sslstare.py b/bob/ip/binseg/configs/datasets/drivechasedb1iostarhrf608sslstare.py new file mode 100644 index 00000000..928452f4 --- /dev/null +++ b/bob/ip/binseg/configs/datasets/drivechasedb1iostarhrf608sslstare.py @@ -0,0 +1,34 @@ +from bob.ip.binseg.configs.datasets.drive608 import dataset as drive +from bob.ip.binseg.configs.datasets.chasedb1608 import dataset as chase +from bob.ip.binseg.configs.datasets.iostarvessel608 import dataset as iostar +from bob.ip.binseg.configs.datasets.hrf608 import dataset as hrf +from bob.db.stare import Database as STARE +from bob.ip.binseg.data.transforms import * +import torch +from bob.ip.binseg.data.binsegdataset import BinSegDataset, SSLBinSegDataset, UnLabeledBinSegDataset + + +#### Config #### + +# PyTorch dataset +labeled_dataset = torch.utils.data.ConcatDataset([drive,chase,iostar,hrf]) + +#### Unlabeled STARE TRAIN #### +unlabeled_transforms = Compose([ + Pad((2,1,2,2)) + ,RandomHFlip() + ,RandomVFlip() + ,RandomRotation() + ,ColorJitter() + ,ToTensor() + ]) + +# bob.db.dataset init +starebobdb = STARE(protocol = 'default') + +# PyTorch dataset +unlabeled_dataset = UnLabeledBinSegDataset(starebobdb, split='train', transform=unlabeled_transforms) + +# SSL Dataset + +dataset = SSLBinSegDataset(labeled_dataset, unlabeled_dataset) \ No newline at end of file diff --git a/bob/ip/binseg/configs/datasets/drivestarechasedb1hrfl1024_all.py b/bob/ip/binseg/configs/datasets/drivestarechasedb1hrfl1024_all.py new file mode 100644 index 00000000..5d2b3456 --- /dev/null +++ b/bob/ip/binseg/configs/datasets/drivestarechasedb1hrfl1024_all.py @@ -0,0 +1,14 @@ +from bob.ip.binseg.configs.datasets.drive1024all import dataset as drive +from bob.ip.binseg.configs.datasets.stare1024all import dataset as stare +from bob.ip.binseg.configs.datasets.hrf1024all import dataset as hrf +from bob.ip.binseg.configs.datasets.chasedb11024all import dataset as chasedb +from bob.db.iostar import Database as IOSTAR +from bob.ip.binseg.data.transforms import * +import torch + + +#### Config #### + +# PyTorch dataset +dataset = torch.utils.data.ConcatDataset([drive,stare,hrf,chasedb]) + diff --git a/bob/ip/binseg/configs/datasets/drivestarechasedb1iostar1168_all.py b/bob/ip/binseg/configs/datasets/drivestarechasedb1iostar1168_all.py new file mode 100644 index 00000000..dcf35d87 --- /dev/null +++ b/bob/ip/binseg/configs/datasets/drivestarechasedb1iostar1168_all.py @@ -0,0 +1,13 @@ +from bob.ip.binseg.configs.datasets.drive1168all import dataset as drive +from bob.ip.binseg.configs.datasets.stare1168all import dataset as stare +from bob.ip.binseg.configs.datasets.chasedb11168all import dataset as chasedb +from bob.ip.binseg.configs.datasets.iostarvessel1168all import dataset as iostar +from bob.db.hrf import Database as HRF +from bob.ip.binseg.data.transforms import * +import torch + + +#### Config #### + +# PyTorch dataset +dataset = torch.utils.data.ConcatDataset([drive,stare,iostar,chasedb]) \ No newline at end of file diff --git a/bob/ip/binseg/configs/datasets/drivestareiostarhrf960.py b/bob/ip/binseg/configs/datasets/drivestareiostarhrf960.py new file mode 100644 index 00000000..9343cf22 --- /dev/null +++ b/bob/ip/binseg/configs/datasets/drivestareiostarhrf960.py @@ -0,0 +1,10 @@ +from bob.ip.binseg.configs.datasets.drive960 import dataset as drive +from bob.ip.binseg.configs.datasets.stare960 import dataset as stare +from bob.ip.binseg.configs.datasets.hrf960 import dataset as hrf +from bob.ip.binseg.configs.datasets.iostarvessel960 import dataset as iostar +import torch + +#### Config #### + +# PyTorch dataset +dataset = torch.utils.data.ConcatDataset([drive,stare,hrf,iostar]) diff --git a/bob/ip/binseg/configs/datasets/drivestareiostarhrf960_all.py b/bob/ip/binseg/configs/datasets/drivestareiostarhrf960_all.py new file mode 100644 index 00000000..cedbea74 --- /dev/null +++ b/bob/ip/binseg/configs/datasets/drivestareiostarhrf960_all.py @@ -0,0 +1,14 @@ +from bob.ip.binseg.configs.datasets.drive960all import dataset as drive +from bob.ip.binseg.configs.datasets.stare960all import dataset as stare +from bob.ip.binseg.configs.datasets.hrf960all import dataset as hrf +from bob.ip.binseg.configs.datasets.iostarvessel960all import dataset as iostar +from bob.db.chasedb1 import Database as CHASE +from bob.db.hrf import Database as HRF +from bob.ip.binseg.data.transforms import * +import torch + + +#### Config #### + +# PyTorch dataset +dataset = torch.utils.data.ConcatDataset([drive,stare,hrf,iostar]) \ No newline at end of file diff --git a/bob/ip/binseg/configs/datasets/hrf544.py b/bob/ip/binseg/configs/datasets/hrf544.py new file mode 100644 index 00000000..0e2cc051 --- /dev/null +++ b/bob/ip/binseg/configs/datasets/hrf544.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from bob.db.hrf import Database as HRF +from bob.ip.binseg.data.transforms import * +from bob.ip.binseg.data.binsegdataset import BinSegDataset + +#### Config #### + +transforms = Compose([ + Resize((363)) + ,Pad((0,90,0,91)) + ,RandomRotation() + ,RandomHFlip() + ,RandomVFlip() + ,ColorJitter() + ,ToTensor() + ]) + +# bob.db.dataset init +bobdb = HRF(protocol = 'default') + +# PyTorch dataset +dataset = BinSegDataset(bobdb, split='train', transform=transforms) diff --git a/bob/ip/binseg/configs/datasets/hrf608.py b/bob/ip/binseg/configs/datasets/hrf608.py new file mode 100644 index 00000000..b26e772a --- /dev/null +++ b/bob/ip/binseg/configs/datasets/hrf608.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from bob.db.hrf import Database as HRF +from bob.ip.binseg.data.transforms import * +from bob.ip.binseg.data.binsegdataset import BinSegDataset + +#### Config #### + +transforms = Compose([ + Pad((0,345,0,345)) + ,Resize(608) + ,RandomRotation() + ,RandomHFlip() + ,RandomVFlip() + ,ColorJitter() + ,ToTensor() + ]) + +# bob.db.dataset init +bobdb = HRF(protocol = 'default') + +# PyTorch dataset +dataset = BinSegDataset(bobdb, split='train', transform=transforms) diff --git a/bob/ip/binseg/configs/datasets/drive2336.py b/bob/ip/binseg/configs/datasets/iostarvessel544.py similarity index 71% rename from bob/ip/binseg/configs/datasets/drive2336.py rename to bob/ip/binseg/configs/datasets/iostarvessel544.py index 30ec9af8..aa03abe2 100644 --- a/bob/ip/binseg/configs/datasets/drive2336.py +++ b/bob/ip/binseg/configs/datasets/iostarvessel544.py @@ -1,16 +1,14 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from bob.db.drive import Database as DRIVE +from bob.db.iostar import Database as IOSTAR from bob.ip.binseg.data.transforms import * from bob.ip.binseg.data.binsegdataset import BinSegDataset #### Config #### transforms = Compose([ - Crop(75,10,416,544) - ,Pad((21,0,22,0)) - ,Resize(2336) + Resize(544) ,RandomHFlip() ,RandomVFlip() ,RandomRotation() @@ -19,7 +17,7 @@ transforms = Compose([ ]) # bob.db.dataset init -bobdb = DRIVE(protocol = 'default') +bobdb = IOSTAR(protocol='default_vessel') # PyTorch dataset dataset = BinSegDataset(bobdb, split='train', transform=transforms) \ No newline at end of file diff --git a/bob/ip/binseg/configs/datasets/iostarvessel608.py b/bob/ip/binseg/configs/datasets/iostarvessel608.py new file mode 100644 index 00000000..7fce4507 --- /dev/null +++ b/bob/ip/binseg/configs/datasets/iostarvessel608.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from bob.db.iostar import Database as IOSTAR +from bob.ip.binseg.data.transforms import * +from bob.ip.binseg.data.binsegdataset import BinSegDataset + +#### Config #### + +transforms = Compose([ + Pad((81,0,81,0)) + ,Resize(608) + ,RandomHFlip() + ,RandomVFlip() + ,RandomRotation() + ,ColorJitter() + ,ToTensor() + ]) + +# bob.db.dataset init +bobdb = IOSTAR(protocol='default_vessel') + +# PyTorch dataset +dataset = BinSegDataset(bobdb, split='train', transform=transforms) \ No newline at end of file diff --git a/bob/ip/binseg/configs/datasets/stare1168sslhrf.py b/bob/ip/binseg/configs/datasets/stare1168sslhrf.py deleted file mode 100644 index a7e3e201..00000000 --- a/bob/ip/binseg/configs/datasets/stare1168sslhrf.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from bob.db.stare import Database as STARE -from bob.db.hrf import Database as HRF -from bob.ip.binseg.data.transforms import * -from bob.ip.binseg.data.binsegdataset import BinSegDataset, SSLBinSegDataset, UnLabeledBinSegDataset - -#### Config #### - -#### Unlabeled HRF TRAIN #### -unlabeled_transforms = Compose([ - RandomRotation() - ,Crop(0,108,2336,3296) - ,Resize(1168) - ,RandomHFlip() - ,RandomVFlip() - ,ColorJitter() - ,ToTensor() - ]) - -# bob.db.dataset init -hrfbobdb = HRF(protocol = 'default') - -# PyTorch dataset -unlabeled_dataset = UnLabeledBinSegDataset(hrfbobdb, split='train', transform=unlabeled_transforms) - - -#### Labeled #### -labeled_transforms = Compose([ - RandomRotation() - ,Crop(50,0,500,705) - ,Resize(1168) - ,Pad((1,0,1,0)) - ,RandomHFlip() - ,RandomVFlip() - ,ColorJitter() - ,ToTensor() - ]) - -# bob.db.dataset init -bobdb = STARE(protocol = 'default') -labeled_dataset = BinSegDataset(bobdb, split='train', transform=labeled_transforms) - -# SSL Dataset - -dataset = SSLBinSegDataset(labeled_dataset, unlabeled_dataset) \ No newline at end of file diff --git a/bob/ip/binseg/configs/datasets/stare1168sslhrfrefuge.py b/bob/ip/binseg/configs/datasets/stare1168sslhrfrefuge.py deleted file mode 100644 index a116997a..00000000 --- a/bob/ip/binseg/configs/datasets/stare1168sslhrfrefuge.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from bob.db.stare import Database as STARE -from bob.db.refuge import Database as REFUGE -from bob.db.hrf import Database as HRF -from bob.ip.binseg.data.transforms import * -from bob.ip.binseg.data.binsegdataset import BinSegDataset, SSLBinSegDataset, UnLabeledBinSegDataset -import torch -#### Config #### - -#### Unlabeled HRF TRAIN #### -unlabeled_transforms = Compose([ - RandomRotation() - ,Crop(0,108,2336,3296) - ,Resize(1168) - ,RandomHFlip() - ,RandomVFlip() - ,ColorJitter() - ,ToTensor() - ]) - -#### Unlabeled REFUGE Test #### - -unlabeled_transforms_refuge = Compose([ - RandomRotation() - ,Crop(220,11,1150,1623) - ,Resize(1168) - ,RandomHFlip() - ,RandomVFlip() - ,ColorJitter() - ,ToTensor() - ]) - -## bob.db.dataset init -# hrf -hrfbobdb = HRF(protocol = 'default') -# refuge -refugebobdb = REFUGE() - - -# PyTorch dataset -unlabeled_dataset_1 = UnLabeledBinSegDataset(hrfbobdb, split='train', transform=unlabeled_transforms) - -unlabeled_dataset_2 = UnLabeledBinSegDataset(refugebobdb, split='test', transform=unlabeled_transforms_refuge) - -# Compose -unlabeled_dataset = torch.utils.data.ConcatDataset([unlabeled_dataset_1,unlabeled_dataset_2]) - - -#### Labeled #### -labeled_transforms = Compose([ - RandomRotation() - ,Crop(50,0,500,705) - ,Resize(1168) - ,Pad((1,0,1,0)) - ,RandomHFlip() - ,RandomVFlip() - ,ColorJitter() - ,ToTensor() - ]) - -# bob.db.dataset init -bobdb = STARE(protocol = 'default') -labeled_dataset = BinSegDataset(bobdb, split='train', transform=labeled_transforms) - -# SSL Dataset - -dataset = SSLBinSegDataset(labeled_dataset, unlabeled_dataset) \ No newline at end of file diff --git a/bob/ip/binseg/configs/datasets/stare544.py b/bob/ip/binseg/configs/datasets/stare544.py index 08c2ad4f..f03fcefb 100644 --- a/bob/ip/binseg/configs/datasets/stare544.py +++ b/bob/ip/binseg/configs/datasets/stare544.py @@ -14,7 +14,6 @@ transforms = Compose([ RandomRotation() ,RandomVFlip() ,ColorJitter() ,ToTensor() - ,ToTensor() ]) # bob.db.dataset init diff --git a/bob/ip/binseg/configs/datasets/starechasedb1iostarhrf544.py b/bob/ip/binseg/configs/datasets/starechasedb1iostarhrf544.py new file mode 100644 index 00000000..72349b3b --- /dev/null +++ b/bob/ip/binseg/configs/datasets/starechasedb1iostarhrf544.py @@ -0,0 +1,10 @@ +from bob.ip.binseg.configs.datasets.stare544 import dataset as stare +from bob.ip.binseg.configs.datasets.chasedb1544 import dataset as chase +from bob.ip.binseg.configs.datasets.iostarvessel544 import dataset as iostar +from bob.ip.binseg.configs.datasets.hrf544 import dataset as hrf +import torch + +#### Config #### + +# PyTorch dataset +dataset = torch.utils.data.ConcatDataset([stare,chase,hrf,iostar]) \ No newline at end of file diff --git a/bob/ip/binseg/configs/datasets/starechasedb1iostarhrf544ssldrive.py b/bob/ip/binseg/configs/datasets/starechasedb1iostarhrf544ssldrive.py new file mode 100644 index 00000000..3a5e3008 --- /dev/null +++ b/bob/ip/binseg/configs/datasets/starechasedb1iostarhrf544ssldrive.py @@ -0,0 +1,34 @@ +from bob.ip.binseg.configs.datasets.stare544 import dataset as stare +from bob.ip.binseg.configs.datasets.chasedb1544 import dataset as chase +from bob.ip.binseg.configs.datasets.iostarvessel544 import dataset as iostar +from bob.ip.binseg.configs.datasets.hrf544 import dataset as hrf +from bob.db.drive import Database as DRIVE +from bob.ip.binseg.data.transforms import * +import torch +from bob.ip.binseg.data.binsegdataset import BinSegDataset, SSLBinSegDataset, UnLabeledBinSegDataset + + +#### Config #### + +# PyTorch dataset +labeled_dataset = torch.utils.data.ConcatDataset([stare,chase,iostar,hrf]) + +#### Unlabeled STARE TRAIN #### +unlabeled_transforms = Compose([ + CenterCrop((544,544)) + ,RandomHFlip() + ,RandomVFlip() + ,RandomRotation() + ,ColorJitter() + ,ToTensor() + ]) + +# bob.db.dataset init +drivebobdb = DRIVE(protocol = 'default') + +# PyTorch dataset +unlabeled_dataset = UnLabeledBinSegDataset(drivebobdb, split='train', transform=unlabeled_transforms) + +# SSL Dataset + +dataset = SSLBinSegDataset(labeled_dataset, unlabeled_dataset) \ No newline at end of file diff --git a/bob/ip/binseg/configs/models/m2unetssl0703.py b/bob/ip/binseg/configs/models/driussl.py similarity index 80% rename from bob/ip/binseg/configs/models/m2unetssl0703.py rename to bob/ip/binseg/configs/models/driussl.py index d5a16082..39afd4a0 100644 --- a/bob/ip/binseg/configs/models/m2unetssl0703.py +++ b/bob/ip/binseg/configs/models/driussl.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- from torch.optim.lr_scheduler import MultiStepLR -from bob.ip.binseg.modeling.m2u import build_m2unet +from bob.ip.binseg.modeling.driu import build_driu import torch.optim as optim from torch.nn import BCEWithLogitsLoss from bob.ip.binseg.utils.model_zoo import modelurls @@ -23,17 +23,17 @@ scheduler_milestones = [900] scheduler_gamma = 0.1 # model -model = build_m2unet() +model = build_driu() # pretrained backbone -pretrained_backbone = modelurls['mobilenetv2'] +pretrained_backbone = modelurls['vgg16'] # optimizer optimizer = AdaBound(model.parameters(), lr=lr, betas=betas, final_lr=final_lr, gamma=gamma, eps=eps, weight_decay=weight_decay, amsbound=amsbound) - + # criterion -criterion = MixJacLoss(lambda_u=0.3, jacalpha=0.7, unlabeledjacalpha=0.3) +criterion = MixJacLoss(lambda_u=0.05, jacalpha=0.7) # scheduler scheduler = MultiStepLR(optimizer, milestones=scheduler_milestones, gamma=scheduler_gamma) diff --git a/bob/ip/binseg/configs/models/m2unetssl.py b/bob/ip/binseg/configs/models/m2unetssl.py index 8280e52f..3497cea2 100644 --- a/bob/ip/binseg/configs/models/m2unetssl.py +++ b/bob/ip/binseg/configs/models/m2unetssl.py @@ -33,7 +33,7 @@ optimizer = AdaBound(model.parameters(), lr=lr, betas=betas, final_lr=final_lr, eps=eps, weight_decay=weight_decay, amsbound=amsbound) # criterion -criterion = MixJacLoss(lambda_u=0.05, jacalpha=0.7, unlabeledjacalpha=0.3) +criterion = MixJacLoss(lambda_u=0.05, jacalpha=0.7) # scheduler scheduler = MultiStepLR(optimizer, milestones=scheduler_milestones, gamma=scheduler_gamma) diff --git a/bob/ip/binseg/modeling/losses.py b/bob/ip/binseg/modeling/losses.py index bb6578af..7bcde850 100644 --- a/bob/ip/binseg/modeling/losses.py +++ b/bob/ip/binseg/modeling/losses.py @@ -171,7 +171,7 @@ class MixJacLoss(_Loss): lambda_u : int determines the weighting of SoftJaccard and BCE. """ - def __init__(self, lambda_u=100, jacalpha=0.7, unlabeledjacalpha=0.3, size_average=None, reduce=None, reduction='mean', pos_weight=None): + def __init__(self, lambda_u=100, jacalpha=0.7, size_average=None, reduce=None, reduction='mean', pos_weight=None): super(MixJacLoss, self).__init__(size_average, reduce, reduction) self.lambda_u = lambda_u self.labeled_loss = SoftJaccardBCELogitsLoss(alpha=jacalpha) diff --git a/doc/benchmarkresults.rst b/doc/benchmarkresults.rst new file mode 100644 index 00000000..fb30961c --- /dev/null +++ b/doc/benchmarkresults.rst @@ -0,0 +1,25 @@ +.. -*- coding: utf-8 -*- +.. _bob.ip.binseg.benchmarkresults: + + +================== +Benchmark Results +================== + +Dice Scores +=========== + +* Benchmark results for models: DRIU, HED, M2UNet and U-Net. +* Train-Test split as indicated in :ref:`bob.ip.binseg.datasets` + ++--------+----------+--------+---------+--------+--------+ +| | CHASEDB1 | DRIVE | HRF1168 | IOSTAR | STARE | ++--------+----------+--------+---------+--------+--------+ +| DRIU | 0.8114 | 0.8226 | 0.7865 | 0.8273 | 0.8286 | ++--------+----------+--------+---------+--------+--------+ +| HED | 0.8111 | 0.8192 | 0.7868 | 0.8275 | 0.8250 | ++--------+----------+--------+---------+--------+--------+ +| M2UNet | 0.8035 | 0.8051 | 0.7838 | 0.8194 | 0.8174 | ++--------+----------+--------+---------+--------+--------+ +| UNet | 0.8136 | 0.8237 | 0.7941 | 0.8203 | 0.8306 | ++--------+----------+--------+---------+--------+--------+ diff --git a/doc/datasets.rst b/doc/datasets.rst index 67939144..0704149b 100644 --- a/doc/datasets.rst +++ b/doc/datasets.rst @@ -1,31 +1,33 @@ .. -*- coding: utf-8 -*- .. _bob.ip.binseg.datasets: - ================== -Supported Datasets +Supported Datasets ================== -+---+-------------+--------------------+--------+-------+------+------+--------+----+-----+---------------------------+ -| # | Name | H x W | # imgs | Train | Test | Mask | Vessel | OD | Cup | Ethnicity | -+===+=============+====================+========+=======+======+======+========+====+=====+===========================+ -| 1 | DRIVE | 584 x 565 | 40 | 20 | 20 | x | x | | | Dutch (adult) | -+---+-------------+--------------------+--------+-------+------+------+--------+----+-----+---------------------------+ -| 2 | STARE | 605 x 700 | 20 | 10 | 10 | | x | | | White American (adult) | -+---+-------------+--------------------+--------+-------+------+------+--------+----+-----+---------------------------+ -| 3 | CHASE_DB1 | 960 x 999 | 28 | 8 | 20 | | x | | | British (child) | -+---+-------------+--------------------+--------+-------+------+------+--------+----+-----+---------------------------+ -| 4 | HRF | 2336 x 3504 | 45 | 15 | 30 | x | x | | | | -+---+-------------+--------------------+--------+-------+------+------+--------+----+-----+---------------------------+ -| 5 | IOSTAR | 1024 x 1024 | 30 | 20 | 10 | x | x | x | | | -+---+-------------+--------------------+--------+-------+------+------+--------+----+-----+---------------------------+ -| 6 | DRIONS-DB | 400 x 600 | 110 | 60 | 50 | | | x | | | -+---+-------------+--------------------+--------+-------+------+------+--------+----+-----+---------------------------+ -| 7 | RIM-ONE r3 | 1424 x 1072 | 159 | 99 | 60 | | | x | x | | -+---+-------------+--------------------+--------+-------+------+------+--------+----+-----+---------------------------+ -| 8 | Drishti-GS1 | varying | 101 | 50 | 51 | | | x | x | | -+---+-------------+--------------------+--------+-------+------+------+--------+----+-----+---------------------------+ -| 9 | REFUGE train| 2056 x 2124 | 400 | 400 | | | | x | x | | -+---+-------------+--------------------+--------+-------+------+------+--------+----+-----+---------------------------+ -| 9 | REFUGE val | 1634 x 1634 | 400 | | 400 | | | x | x | | -+---+-------------+--------------------+--------+-------+------+------+--------+----+-----+---------------------------+ ++-----+---------------+-------------+--------+-------+------+------+--------+-----+-----+----------------------------+ +| # | Name | H x W | # imgs | Train | Test | Mask | Vessel | OD | Cup | Train-Test split reference | ++=====+===============+=============+========+=======+======+======+========+=====+=====+============================+ +| 1 | Drive_ | 584 x 565 | 40 | 20 | 20 | x | x | | | `Staal et al. (2004)`_ | ++-----+---------------+-------------+--------+-------+------+------+--------+-----+-----+----------------------------+ +| 2 | STARE_ | 605 x 700 | 20 | 10 | 10 | | x | | | `Maninis et al. (2016)`_ | ++-----+---------------+-------------+--------+-------+------+------+--------+-----+-----+----------------------------+ +| 3 | CHASEDB1_ | 960 x 999 | 28 | 8 | 20 | | x | | | `Fraz et al. (2012)`_ | ++-----+---------------+-------------+--------+-------+------+------+--------+-----+-----+----------------------------+ +| 4 | HRF_ | 2336 x 3504 | 45 | 15 | 30 | x | x | | | `Orlando et al. (2016)`_ | ++-----+---------------+-------------+--------+-------+------+------+--------+-----+-----+----------------------------+ +| 5 | IOSTAR_ | 1024 x 1024 | 30 | 20 | 10 | x | x | x | | `Meyer et al. (2017)`_ | ++-----+---------------+-------------+--------+-------+------+------+--------+-----+-----+----------------------------+ +| 6 | DRIONS-DB_ | 400 x 600 | 110 | 60 | 50 | | | x | | `Maninis et al. (2016)`_ | ++-----+---------------+-------------+--------+-------+------+------+--------+-----+-----+----------------------------+ +| 7 | RIM-ONEr3_ | 1424 x 1072 | 159 | 99 | 60 | | | x | x | `Maninis et al. (2016)`_ | ++-----+---------------+-------------+--------+-------+------+------+--------+-----+-----+----------------------------+ +| 8 | Drishti-GS1_ | varying | 101 | 50 | 51 | | | x | x | `Sivaswamy et al. (2014)`_ | ++-----+---------------+-------------+--------+-------+------+------+--------+-----+-----+----------------------------+ +| 9 | REFUGE_ train | 2056 x 2124 | 400 | 400 | | | | x | x | REFUGE_ | ++-----+---------------+-------------+--------+-------+------+------+--------+-----+-----+----------------------------+ +| 9 | REFUGE_ val | 1634 x 1634 | 400 | | 400 | | | x | x | REFUGE_ | ++-----+---------------+-------------+--------+-------+------+------+--------+-----+-----+----------------------------+ + + +.. include:: links.rst \ No newline at end of file diff --git a/doc/index.rst b/doc/index.rst index fe6cf753..c19b48ea 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -15,6 +15,7 @@ Users Guide :maxdepth: 2 datasets + benchmarkresults api references diff --git a/doc/links.rst b/doc/links.rst index d8a696c4..2398e1c8 100644 --- a/doc/links.rst +++ b/doc/links.rst @@ -6,4 +6,48 @@ .. _bob: http://www.idiap.ch/software/bob .. _installation: https://www.idiap.ch/software/bob/install .. _mailing list: https://www.idiap.ch/software/bob/discuss -.. _torchvision package: https://github.com/pytorch/vision \ No newline at end of file +.. _torchvision package: https://github.com/pytorch/vision + +.. DRIVE + +.. _drive: https://doi.org/10.1109/TMI.2004.825627 +.. _staal et al. (2004): https://doi.org/10.1109/TMI.2004.825627 + +.. STARE + +.. _stare: https://doi.org/10.1109/42.845178 +.. _maninis et al. (2016): https://doi.org/10.1007/978-3-319-46723-8_17 + +.. HRF + +.. _hrf: http://dx.doi.org/10.1155/2013/154860 +.. _orlando et al. (2016): https://doi.org/10.1109/TBME.2016.2535311 + +.. IOSTAR + +.. _iostar: https://doi.org/10.1109/TMI.2016.2587062 +.. _meyer et al. (2017): https://doi.org/10.1007/978-3-319-59876-5_56 + +.. CHASEDB1 + +.. _chasedb1: https://doi.org/10.1109/TBME.2012.2205687 +.. _fraz et al. (2012): https://doi.org/10.1109/TBME.2012.2205687 + +.. DRIONSDB + +.. _drions-db: http://dx.doi.org/10.1016/j.artmed.2008.04.005 +.. _maninis et al. (2016): https://doi.org/10.1007/978-3-319-46723-8_17 + +.. RIM-ONE r3 + +.. _rim-oner3: https://dspace5.zcu.cz/bitstream/11025/29670/1/Fumero.pdf +.. _maninis et al. (2016): https://doi.org/10.1007/978-3-319-46723-8_17 + +.. Drishti-GS1 + +.. _drishti-gs1: https://doi.org/10.1109/ISBI.2014.6867807 +.. _sivaswamy et al. (2014): https://doi.org/10.1109/ISBI.2014.6867807 + +.. REFUGE + +.. _refuge: http://ai.baidu.com/broad/download?dataset=gon diff --git a/setup.py b/setup.py index 8b82e9b2..593a4d78 100644 --- a/setup.py +++ b/setup.py @@ -58,6 +58,7 @@ setup( #bob hed train configurations 'bob.ip.binseg.config': [ 'DRIU = bob.ip.binseg.configs.models.driu', + 'DRIUSSL = bob.ip.binseg.configs.models.driussl' 'DRIUOD = bob.ip.binseg.configs.models.driuod', 'HED = bob.ip.binseg.configs.models.hed', 'M2UNet = bob.ip.binseg.configs.models.m2unet', -- GitLab