Evaluating SAM-based and Convolutional Architectures in Thin Retinal Vessel Segmentation: Model Capacity, Computational Cost and Foundation Pre-training
Authors: Carlos Eduardo Fontaneli, Cesar Henrique Comin
Organizations: Department of Computer Science, Federal University of S˜ao Carlos, Rod. Washington Lu´ıs, km 235, 13565-905, S˜ao Carlos, SP, Brazil
In retinal vessel segmentation, plain Vision Transformers (ViTs) are commonly expected to perform worse than convolutional neural networks (CNNs) on thin vessels, for reasons such as their coarse patch tokenization, their weak locality bias and their need for large training sets. Although this expectation is widely shared in the literature, how plain ViTs actually compare with CNNs on thin vessels has not been systematically quantified. We address this question by comparing a model with a plain ViT encoder (MedSAM), a hybrid Transformer (LiteMedSAM) and three CNNs of different sizes on three retinal datasets (DRIVE, HRF, FIVES) and, as a second-domain check, a microscopy dataset (VessMap). We measured the centerline recall and precision of thin vessels and compared the models while also considering their computational cost and how many epochs they needed to train. We found that the pre-trained MedSAM had a centerline recall of thin vessels that was not significantly different from that of the best CNN on all four datasets (-0.6 to +2.5 percentage points). A compact plain ViT obtained through architecture search but trained from scratch did not retain this performance. For pre-trained plain ViTs, our results do not support the expectation that they miss thin vessels, although similar thin-vessel performance can be obtained with much smaller models.
Figures & tables
Model
Type
Encoder
Params (M)
MedSAM
Plain ViT
ViT-B
93.7
LiteMedSAM
Hybrid
TinyViT
9.8
ConvNeXt
CNN
ConvNeXt-L
211.4
ConvUNeXt
CNN
ConvNeXt blocks
3.5 / 13.8
LW-Net
CNN
Conv. blocks
0.07
Table 1: The five architectures and their parameters. ConvUNeXt and LW-Net are U-Nets without a separate, named encoder, so for them the encoder column gives the type of block of the encoding path. The size of ConvUNeXt depends on the dataset (Appendix A ).
CNN
Fine-tuned
Dataset
Metric
LW-Net
ConvUNeXt
ConvNeXt
LiteMedSAM
MedSAM
DRIVE ( n=20 )
Dice
81.1±2.4
77.6±15.1
77.5±2.5
82.3±1.9
81.3±1.3
Rcl
74.9±7.2
70.1±16.7
66.9±7.5
79.4±7.1
75.5±6.9
Pcl
89.3±2.3
90.5±4.4
89.5±3.1
87.6±2.5
87.3±2.9
HRF ( n=14 )
Dice
76.9±6.9
79.7±5.1
76.9±6.2
80.6±5.9
81.7±4.5
Rcl
72.0±12.0
72.8±9.5
73.8±7.6
82.2±7.6
76.6±8.6
Table 2: Overall segmentation performance. Values in bold indicate the best performance. Underlined values are not significantly different from the best (bold) of the same row.
Figure 1: Mean centerline recall for different vessel radius ranges. The first range, radius in [0.5,1.5) px, shows Rthin . Grey bars show the number of ground-truth centerline pixels for each range, calculated on the test images.
Figure 2: Centerline precision against centerline recall of thin vessels, per dataset.
Figure 3: Thin vessel detection agreement among the models. (a–d) Window of each test set with the most thin centerline pixels. Non-thin vessels are shown in dark grey. (e) Agreements between the models over all test images.
Figure 4: Cost of each architecture. (a) parameters and (b) GFLOPs per test image, log scale.
Figure 5: Relationship between performance and cost. Rthin (a–d) and Dice (e–h) against GFLOPs per test image.
Figure 6: Effect of pre-training. (a) Dice, (b) Rthin and (c) Pthin of the two transformer-based models fine-tuned (filled) and trained from scratch (hollow), next to the CNNs.
Figure 7: Training epochs required to reach 95% of the best validation Dice. Models were validated every epoch or every 10 epochs (see Table A.1 for details). “ ≤ ” means that the model reached the performance at the first validation.
DRIVE ( n=20 )
VessMap ( n=30 )
MedSAM
Metric
Padded
Upscaled
Δ
Padded
Upscaled
Δ
Fine-tuned
Dice
75.2±1.8
81.3±1.3
+6.1∗
78.7±7.5
92.8±2.1
+14.1∗
Rthin
39.0±10.9
56.9±11.8
+17.9∗
41.3±12.7
82.6±14.1
+41.3∗
Pthin
58.8±7.9
73.0±6.1
+14.2∗
76.8±13.2
79.6±14.8
+2.8
From scratch
Dice
65.7±3.0
78.7±1.6
+13.0∗
68.2±6.4
89.7±3.7
+21.5∗
Rthin
25.3±8.0
39.3±11.2
+14.0∗
43.6±19.2
70.2±20.9
+26.6∗
Table 3: MedSAM evaluated with the padded and the upscaled protocol. Bold indicates the best value. Significant differences are indicated by an asterisk.
Dice
Rthin
Dataset
MedSAM
Best CNN
MedSAM
Best CNN
DRIVE
81.3±
1.3
81.1±
2.4 L
56.9±
11.8
57.5±
12.1 L
HRF
81.7±
4.5∗
79.7±
5.1 U
26.9±
17.2
25.4±
13.5 N
FIVES
92.2±
8.5∗
90.2±
8.5 N
36.2±
11.9
36.5±
12.2 N
VessMap
92.8±
2.1
92.9±
2.1 U
82.6±
14.1
80.1±
12.2 L
Table 4: Fine-tuned MedSAM against the best CNN of each metric and dataset. L: LW-Net , U: ConvUNeXt , N: ConvNeXt . Bold indicates the best value. Asterisks indicate significantly different values.
Appendix figures & tables6 assets
Supplementary material from the paper’s appendix.
Appendix
Configuration
Dataset
Learning rate
Weight decay
Batch size
Architecture
Val.
GPU h
LW-Net
DRIVE
10−6 – 10−1
10−6 – 10−1
2, 4, 8
first width 8, 16, 32
1
13.0
HRF
10−6 – 10−1
10−6 – 10−1
2, 4, 8, 16
–
10
34.0
FIVES
10−6 – 10−1
10−6 – 10−1
2, 4, 8, 16, 32, 64
first width 8, 16, 32
1
108.6
VessMap
10−5 – 10−2
10−5 – 10−1
2, 4, 8, 16, 32
first width 8, 16, 32
1
1.2
ConvUNeXt
DRIVE
10−6 – 10−2
10−6 – 10−1
2, 4, 8
base width 16, 32, 64
1
13.4
HRF
10−6 – 10−2
10−6 – 10−1
2, 4, 8, 16
–
10
25.1
Appendix
Table A.1: Hyperparameter search. Learning rate and weight decay: log-uniform in the ranges shown. CNN architecture parameter: LW-Net , width of the first of its three levels (doubled at each level); ConvUNeXt , width of the first stage; ConvNeXt , stochastic-depth (drop-path) rate. Val.: validation interval in epochs. GPU h: sum of the trial durations.
Model
Version
Input
Patch
Tokens
Emb.
Depth
Heads
MLP
Window
Params
Dice
Rthin
Pthin
MedSAM
original
1024
16
64×64
768
12
12
4
14
93.7
Table B.1
compact, DRIVE
256
4
64×64
256
4
8
2
14
7.9
77.7±2.5
43.4±13.5
69.3±8.3
compact, HRF
256
4
64×64
128
6
4
2
14
6.0
78.3±5.9
23.7±15.3
43.3±11.6
compact, FIVES
256
8
32×32
256
8
8
6
7
13.5
87.8±9.0
32.0±11.3
41.9±10.7
compact, VessMap
256
4
64×64
384
6
4
6
7
20.6
91.7±2.8
77.5±18.2
74.5±14.5
LiteMedSAM
original
256
–
–
64,128,160,320
2,2,6,2
2,4,5,10
4
7,7,14,7
9.8
Table B.1
Appendix
Table A.2: Selected compact models and, for comparison, the original MedSAM and LiteMedSAM . Input and Patch in px. Tokens: patch grid of one window, calculated as image size divided by patch size. Emb.: embedding dimension. MLP: ratio of the hidden width of the MLP block. Window: size of the attention window in patches. Params: number of parameters in millions.
DRIVE
HRF
FIVES
VessMap
Patch (px)
Tr.
Dice
Tr.
Dice
Tr.
Dice
Tr.
Dice
1
0
OOM
0
OOM
0
OOM
0
OOM
2
0
OOM
0
OOM
0
OOM
0
OOM
4
18
76.8
44
78.9
4
85.3
37
92.1
8
16
70.2
13
75.0
69
89.6
32
90.5
16
56
15.7
16
14.0
8
82.7
6
87.0
Appendix
Table A.3: Patch sizes in the search of compact MedSAM . Number of trials that reached a validation epoch (Tr.) and their best validation Dice (%). Bold indicates the best performance for each dataset, which set the patch sizes used in the experiments. OOM: every trial ran out of GPU memory.
LiteMedSAM
MedSAM
Dataset
Metric
FT
Scratch
Δ
FT
Scratch
Δ
CNN
DRIVE ( n=20 )
Dice
82.3±1.9
81.4±2.4
+0.9∗
81.3±1.3
78.7±1.6
+2.6∗
81.1±2.4 L
Rthin
64.3±11.6
59.9±13.4
+4.4∗
56.9±11.8
39.3±11.2
+17.6∗
57.5±12.1 L
Pthin
74.5±5.2
76.2±5.8
−1.7
73.0±6.1
76.2±7.0
−3.2∗
80.8±8.6 U
HRF ( n=14 )
Dice
80.6±5.9
79.5±5.1
+1.1
81.7±4.5
79.7±5.4
+2.0∗
79.7±5.1 U
Rthin
40.1±15.7
30.2±13.6
+9.9∗
26.9±17.2
28.0±16.1
−1.1
25.4±13.5 N
Appendix
Table B.1: Effect of pre-training. LiteMedSAM and MedSAM fine-tuned (FT) and trained from scratch, and the best CNN. L: LW-Net , U: ConvUNeXt , N: ConvNeXt . Δ shows the FT value minus Scratch, with an asterisk when the difference is significant. Bold indicates the best value, including the CNN. Underlined values are not significantly different from the best of the same row.
DRIVE
HRF
FIVES
VessMap
Pair
Dice
Rthin
Pthin
Dice
Rthin
Pthin
Dice
Rthin
Pthin
Dice
Rthin
Pthin
LW vs CU
0.58
0.054
0.19
0.004 -
1.00
0.54
< 0.001 -
< 0.001 -
< 0.001 +
1.00
1.00
1.00
LW vs CN
< 0.001 +
< 0.001 +
0.010 +
1.00
1.00
0.59
< 0.001 -
< 0.001 -
0.059
< 0.001 +
< 0.001 +
0.75
LW vs LM
0.005 -
< 0.001 -
< 0.001 +
0.005 -
0.004 -
0.25
< 0.001 -
< 0.001 -
< 0.001 +
1.00
0.076
1.00
LW vs LM-S
0.44
0.008 -
0.025 +
0.004 -
0.62
1.00
< 0.001 -
0.33
1.00
< 0.001 +
0.002 +
0.15
LW vs LM-C
0.77
< 0.001 -
< 0.001 +
0.005 -
0.47
1.00
< 0.001 -
< 0.001 -
< 0.001 +
0.011 +
1.00
0.073
Appendix
Table C.1: Holm-adjusted p-values of the pairwise tests. A + superscript indicates that the first model of the pair is significantly better ( p<0.05 ). A − is used when the second configuration is better. LW: LW-Net ; CU: ConvUNeXt ; CN: ConvNeXt ; LM, LM-S, LM-C: LiteMedSAM fine-tuned, from scratch and compact; M, M-S, M-C: MedSAM fine-tuned, from scratch and compact.
DRIVE
HRF
FIVES
VessMap
Pair
Rcl
Pcl
Rcl
Pcl
Rcl
Pcl
Rcl
Pcl
LW vs CU
0.048 +
0.36
1.00
0.23
< 0.001 -
< 0.001 -
0.025 +
0.29
LW vs CN
< 0.001 +
1.00
1.00
0.026 +
< 0.001 -
< 0.001 -
< 0.001 +
1.00
LW vs LM
< 0.001 -
< 0.001 +
0.001 -
1.00
< 0.001 -
< 0.001 -
0.002 -
0.084
LW vs M
0.70
< 0.001 +
0.043 -
0.27
< 0.001 -
< 0.001 -
0.037 -
1.00
CU vs CN
0.003 +
0.43
1.00
0.001 +
< 0.001 -
0.14
0.028 +
0.55
Appendix
Table C.2: Holm-adjusted p-values for Table 2 (top) and Table 3 (bottom). LW: LW-Net ; CU: ConvUNeXt ; CN: ConvNeXt ; LM: LiteMedSAM fine-tuned; M: MedSAM fine-tuned. See the caption of Table C.1 for the meaning of the + and − superscripts.