Manuscript Offprint
arXiv:2610.36722Progressively Refining SAM for Accurate Phytoplankton Segmentation
ABSTRACT
Accurate phytoplankton segmentation is essential for ecological monitoring, yet it remains largely underexplored due to the subtle visual characteristics of phytoplankton and the scarcity of pixel-level annotations. To address these challenges, we propose PhySeg, a SAM-based segmentation framework equipped with a lightweight refinement module that progressively restores fine-grained details through multiscale feature fusion. In addition, we construct a phytoplankton segmentation dataset by manually annotating instance-level masks for an existing dataset, providing a valuable resource for future research. Experimental results demonstrate that PhySeg improves segmentation accuracy, validating the effectiveness of the proposed module. Code is available at https://github.com/lijialin404/PhySeg.
Index Terms— Phytoplankton Image Segmentation, Segment Anything Model, Refinement
1. INTRODUCTION
Phytoplankton underpin marine primary production and food webs and play an important role in the global carbon cycle [1]. Characterizing their morphology and behavior is therefore essential for understanding marine ecosystems. Several studies have focused on phytoplankton classification [2, 3], supported by public benchmarks such as WHOI-Plankton [4]. Beyond classification, detection and tracking methods [5, 6, 7] enable the spatial localization and temporal association of individual organisms, supported by datasets such as PMID2019 [8] and PMOT2023 [9].
Despite this progress, category labels, bounding boxes, and trajectories provide limited information about the precise morphology of individual organisms. Therefore, pixel-level segmentation for phytoplankton is required to support more detailed ecological analysis [10]. However, phytoplankton segmentation remains comparatively underexplored, with two major challenges. First, general-purpose segmentation models, including the Segment Anything Model (SAM) [11], are not specifically designed for phytoplankton. Substantial variations in morphology and scale, together with slender structures, low contrast, and ambiguous boundaries (see examples in Fig. 3), make it difficult to recover fine details reliably [2, 8, 10]. Second, adapting these models requires high-quality segmentation annotations, which remain scarce in existing phytoplankton datasets. Recent surveys likewise identify limited annotated data and the need for segmentation-oriented methods as persistent challenges in phytoplankton image analysis [2, 3].
In this paper, we address these challenges through two contributions. 1) Methodology. We introduce a dedicated phytoplankton segmentation framework built on SAM2 [12], named PhySeg. Drawing on its strong general-purpose segmentation capabilities, we adapt SAM2 to phytoplankton microscopy and develop an add-on refiner that integrates multiscale features to progressively recover fine structural details. 2) Dataset. We extend PMID2019 with 11990 manually annotated instance masks across 9824 images. Unlike general objects, annotating phytoplankton requires substantial manual effort due to their slender structures and intricate boundaries. Despite its modest scale, this dataset provides a valuable resource for developing and evaluating phytoplankton segmentation methods. Experiments on this dataset demonstrate the effectiveness of the proposed framework, establishing a baseline for phytoplankton segmentation.
Progressive Refinement. In SAM2, coarse logits are directly upsampled and thresholded to obtain the final mask. However, upsampling alone does not explicitly correct errors in the coarse predictions. This naturally raises a question: can we refine the coarse predictions during upsampling?
Motivated by this idea, a Progressive Refinement strategy is introduced, which refines coarse logits through multiple steps, rather than relying on a single step to address various errors. Each step consists of two small convolutional modules, named Feature Fusion and Residual Head. The Feature Fusion module aggregates the input features at the current step, while the Residual Head module takes the fused features as input and predicts the residual logits. The residual logits are
- Corresponding author

Fig. 1. Detailed structure of the proposed PhySeg.

Global Average Pooling Add Residual Head
Fig. 2. Overview of the Feature Fusion module. denotes a convolution with dilation rate d, followed by GroupNorm and GELU. The dilation rate is 1 when omitted.
added to the coarse logits step by step to progressively refine the results.
Structure Design. SAM2 inherently encodes semantic and spatial information at multiple scales. We therefore reorganize these intermediate features as complementary cues for mask refinement. Specifically, we use three feature maps from the decoding process, denoted as , , and , with spatial resolutions of 1/16, 1/8, and 1/4 of the input image, respectively.
While provides rich semantic information, its limited spatial detail compromises the initial representation on which subsequent corrections rely. We therefore introduce at Step 0 to incorporate finer spatial cues from the outset, providing a stronger foundation for subsequent refinement. At Step 1, we introduce for finer spatial details while retaining to provide complementary structural context. After this feature transition in the first two steps, Step 2 directly uses to further handle finer local errors. In this way, the refinement process gradually shifts from correcting the overall structure to improving local details.
In addition, the updated logits at each step, together with the fused features, serve as the hidden state , carrying forward the refined features and current mask prediction and guiding the next step to achieve a balance between area and boundaries. At Step 0, an additional Feature Fusion module aggregates context from the input features before they are combined with the coarse logits to construct the initial hidden state . Besides, the shallow encoder feature is introduced at every step to provide local spatial details.
As shown in Fig. 2, inspired by the ASPP module [14], we design the Feature Fusion module to address the need for both local and global information during refinement. Input features are first aligned via Region of Interest (ROI) and then processed by three parallel convolutional branches with different dilation rates to capture local information, while Global Average Pooling is added to provide a shared global reference for refinement at different spatial locations. The fused features are further fed into the Residual Head R, which consists of a convolution followed by a convolution, to predict the residual logits for correction at each step.
Training Objective. The refined prediction is supervised using a combination of focal loss [15] and Dice loss [16]: .
3. PHYTOPLANKTON SEGMENTATION DATASET
Few public datasets provide pixel-level annotations for phytoplankton segmentation. To address this gap, we construct the Phytoplankton Segmentation Dataset (PhySegD) by manually annotating ground-truth masks for the PMID2019 dataset.
Creating PhySegD is particularly labor-intensive despite its moderate scale. In bright-field microscopy images, halos surrounding phytoplankton are often difficult to distinguish from the boundaries of semi-transparent cells, necessitating multiple rounds of expert review. Moreover, impurities

Fig. 3. Visual examples of the phytoplankton segmentation dataset.
Table 1. Category statistics of the dataset.
| ID | Genus | Images | Instances |
|---|---|---|---|
| 1 | bacteriastrum | 677 | 703 |
| 2 | biddulphia | 356 | 360 |
| 3 | ceratium | 2267 | 2332 |
| 4 | chaetoceros | 1095 | 1184 |
| 5 | coscinodiscus | 1123 | 1140 |
| 6 | dinophysis | 413 | 417 |
| 7 | ditylum | 99 | 100 |
| 8 | eucampia | 1446 | 1514 |
| 9 | guinardia | 857 | 869 |
| 10 | helicotheca | 369 | 374 |
| 11 | pleurosigma | 228 | 237 |
| 12 | protoperidinium | 105 | 105 |
| 13 | rhizosolenia | 77 | 77 |
| 14 | skeletonema | 1053 | 1141 |
| 15 | thalassionema | 1389 | 1437 |
with textures similar to those of phytoplankton may interfere with or obscure cell boundaries, further complicating accurate mask annotation. Representative samples from different genus-level categories and their annotations are shown in Fig. 3, while Table 1 reports the numbers of images and instances across the 15 categories. Overall, PhySegD contains 9824 images and 11990 instances, divided into 6880 training images with 8378 instances, 1968 validation images with 2395 instances, and 976 test images with 1217 instances.
4. EXPERIMENTS
Experimental Setup. We evaluate PhySeg on the proposed PhySegD dataset and compare it with representative mask- refinement methods, including CascadePSP [17], BPR [18], CRM [19], and HQ-SAM2 [20]. We report mean Intersection over Union (mIoU) and Dice scores to evaluate region accuracy, together with boundary F-scores at thresholds of 1, 2, and 4 pixels (BF1, BF2, and BF4) to assess boundary quality [21]. Higher values indicate better performance for all metrics. Among these metrics, mIoU serves as the primary measure of overall segmentation accuracy.
Implementation Details. During training, we apply random horizontal and vertical flips, rotations by multiples of , and color jittering. The same geometric transformations are applied consistently to the images, masks, and bounding boxes. Training is conducted in two stages. First, we adapt SAM2 to phytoplankton images using LoRA. The model is optimized for 15 epochs using AdamW with a learning rate of , a weight decay of 0.01, and a batch size of 1. Second, we freeze SAM2 and its LoRA parameters and train only the refiner for 15 epochs. We use AdamW with an initial learning rate of , a weight decay of 0.01, and a batch size of 1. The learning rate follows a cosine annealing schedule with a minimum value of .
Comparison Results. Table 2 compares PhySeg with existing segmentation and refinement methods. The upper part with the superscript * denotes models evaluated using their official pretrained weights without fine-tuning. The lower part reports the results of these models after fine-tuning on our dataset. For CRM, BPR, and CascadePSP, we fine-tune the official pretrained models using their recommended training configurations. For HQ-SAM2, we reimplement the HQ module ourselves, strictly following its instructions. PhySeg achieves the best mIoU, BF1, BF2, and Dice scores, reaching 91.87%, 68.32%, 84.02%, and 95.68%, respectively. It also outperforms the mask-based refinement methods despite
Table 2. Quantitative performance comparison of different methods on the test set. “Box” indicates that a bounding box is used as the model prompt, whereas “Mask” indicates that the SAM2+LoRA prediction is provided as the initial mask.
| Method | Venue | Prompt | mIoU↑ | Dice↑ | BF1↑ | BF2↑ | BF4↑ |
|---|---|---|---|---|---|---|---|
| CascadePSP* [17] | CVPR'20 | Mask | 87.08 | 92.77 | 53.45 | 72.41 | 90.57 |
| BPR* [18] | CVPR'21 | Mask | 88.51 | 93.53 | 59.61 | 77.99 | 92.88 |
| CRM* [19] | CVPR'22 | Mask | 68.20 | 76.08 | 34.94 | 49.04 | 65.39 |
| SAM2* [12] | ICLR'25 | Box | 81.03 | 87.82 | 42.86 | 60.29 | 80.46 |
| HQ-SAM2* [20] | NeurIPS'23 | Box | 82.99 | 89.35 | 47.57 | 65.83 | 84.64 |
| CascadePSP [17] | CVPR'20 | Mask | 89.72 | 94.37 | 62.69 | 79.85 | 93.36 |
| BPR [18] | CVPR'21 | Mask | 91.73 | 95.60 | 67.79 | 83.51 | 94.93 |
| CRM [19] | CVPR'22 | Mask | 67.19 | 75.03 | 36.00 | 51.55 | 68.36 |
| SAM2+LoRA [13] | ICLR'22 | Box | 91.20 | 95.30 | 65.50 | 82.52 | 94.86 |
| HQ-SAM2 [20] | NeurIPS'23 | Box | 91.73 | 95.60 | 67.52 | 83.71 | 95.31 |
| PhySeg (Ours) | - | Box | 91.87 | 95.68 | 68.32 | 84.02 | 95.19 |

(a)
(b)
(c)
(d)
(e)
(f)
Fig. 4. Visual examples of our method and others: (a) original image, (b) ground truth, (c) SAM2, (d) SAM2+LoRA, (e) HQ-SAM2, and (f) PhySeg (Ours).
requiring only a box prompt. Fig. 4 further shows that PhySeg better preserves slender structures and corrects inaccurate regions in the initial masks.
BF1 and BF2 require the predicted boundary to be closer to the real boundary, while BF4 uses a wider tolerance. Compared with HQ-SAM2, our method achieves improvements in mIoU, Dice, BF1, and BF2, with a slight decrease of 0.12 percentage points in BF4. Overall, these results show that PhySeg achieves a better balance between boundary refinement and region correction, which does not contradict the fact that there is still room for improvement in BF4.
Ablation Study. Table 3 evaluates the contributions of the feature inputs and progressive refinement steps. denotes the hidden state transferred across steps; denotes the shallow feature extracted from Hiera Stage 0. As shown in Fig. 1, Steps 0, 1, and 2 denote the progressive procedure of refinement. We transfer across steps to find a balance between area refinement and boundary refinement. As shown by the
Table 3. Ablation study on the val-set.
| Method | mIoU↑ | Dice↑ | BF1↑ | BF2↑ | BF4↑ |
|---|---|---|---|---|---|
| PhySeg | 92.07 | 95.80 | 67.75 | 84.11 | 95.47 |
| w/o H | 91.97 | 95.74 | 67.92 | 84.35 | 95.61 |
| w/o | 92.03 | 95.77 | 67.65 | 83.95 | 95.49 |
| w/o Step 0 | 92.00 | 95.76 | 67.45 | 84.04 | 95.55 |
| w/o Step 0 & Step 1 | 91.96 | 95.74 | 67.36 | 83.88 | 95.45 |
ablation study, adding leads to an increase in mIoU and Dice while causing a slight decrease in BF, which is consistent with the design of .
In addition, removing , Step 0, or Step 0 and Step 1 consistently leads to performance degradation across multiple metrics. Since the original SAM2 already provides a relatively strong segmentation baseline, the resulting changes are not necessarily large in magnitude. Moreover, these components contain partially overlapping feature information, which may further limit the apparent gain contributed by each individual component. However, the overall trend observed in the ablation results is consistent with our design motivation: these features are introduced as refinement prompts to progressively guide the segmentation results.
5. CONCLUSION
In this work, we propose PhySeg, a phytoplankton segmentation method built upon SAM2 and equipped with a newly designed refiner module. By progressively fusing multi-scale features, the refiner recovers missing details and corrects inaccurate regions in the initial segmentation, thereby improving the delineation of fine phytoplankton structures. In addition, we construct a phytoplankton segmentation dataset by manually annotating ground-truth masks for the existing PMID2019 dataset. Experimental results demonstrate the effectiveness of the proposed method.
6. REFERENCES
[1] P. G. Falkowski, R. T. Barber, and V. Smetacek, “Biogeochemical controls and feedbacks on ocean primary production,” Science, 1998.
[2] T. Eerola et al., “Survey of automatic plankton image recognition: Challenges, existing solutions and future perspectives,” Artificial Intelligence Review, 2024.
[3] N. Taheriashtiani et al., “Artificial intelligence and microscopy: A systematic review of deep learning in microalgae and cyanobacteria species identification,” Algal Research, 2026.
[4] E. C. Orenstein, O. Beijbom, E. E. Peacock, and H. M. Sosik, “WHOI-Plankton: A large scale fine grained visual recognition benchmark dataset for plankton classification,” CoRR, 2015.
[5] Y. Huo, Q. Lv, and J. Dong, “Enhancing phytoplankton recognition through a hybrid dataset and morphological description-driven prompt learning,” Journal of Marine Science and Engineering, 2025.
[6] T. Zhang, J. Dong, H. Zhao, Q. Li, and X. Sun, "Lightweight phytoplankton detection network based on knowledge distillation," Journal of Applied Sciences, 2020.
[7] Y. Yu, Q. Lv, Y. Li, Z. Wei, and J. Dong, “PhyTracker: An online tracker for phytoplankton,” IEEE Transactions on Circuits and Systems for Video Technology, 2025.
[8] Q. Li, X. Sun, J. Dong, and S. Han, “Developing a microscopic image dataset in support of intelligent phytoplankton detection using deep learning,” ICES Journal of Marine Science, 2020.
[9] J. Yu, Q. Lv, Y. Li, J. Dong, H. Zhao, and Q. Li, “PMOT2023: A large-scale multi-object tracking (MOT) dataset with application to phytoplankton observation,” Journal of Marine Science and Engineering, 2023.
[10] V. Sonnet, L. Guidi, C. B. Mouw, G. Puggioni, and S. D. Ayata, “Length, width, shape regularity, and chain structure: Time series analysis of phytoplankton morphology from imagery,” Limnology and Oceanography, 2022.
[11] A. Kirillov et al., “Segment anything,” in Proceedings of the IEEE/CVF International Conference on Computer Vision, 2023.
[12] N. Ravi et al., “SAM 2: Segment anything in images and videos,” in International Conference on Learning Representations, 2025.
[13] E. J. Hu et al., “LoRA: Low-rank adaptation of large language models,” in International Conference on Learning Representations, 2022.
[14] L.-C. Chen, G. Papandreou, I. Kokkinos, K. Murphy, and A. L. Yuille, “DeepLab: Semantic image segmentation with deep convolutional nets, atrous convolution, and fully connected CRFs,” IEEE Transactions on Pattern Analysis and Machine Intelligence, 2018.
[15] T.-Y. Lin, P. Goyal, R. Girshick, K. He, and P. Dollár, “Focal loss for dense object detection,” in Proceedings of the IEEE International Conference on Computer Vision (ICCV), 2017.
[16] F. Milletari, N. Navab, and S.-A. Ahmadi, “V-Net: Fully convolutional neural networks for volumetric medical image segmentation,” in 2016 Fourth International Conference on 3D Vision (3DV), 2016.
[17] H. K. Cheng, J. Chung, Y.-W. Tai, and C.-K. Tang, "CascadePSP: Toward class-agnostic and very high-resolution segmentation via global and local refinement," in Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2020.
[18] C. Tang, H. Chen, X. Li, J. Li, Z. Zhang, and X. Hu, "Look closer to segment better: Boundary patch refinement for instance segmentation," in Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2021.
[19] T. Shen et al., “High quality segmentation for ultra high-resolution images,” in Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2022.
[20] L. Ke et al., “Segment anything in high quality,” in Advances in Neural Information Processing Systems, 2023.
[21] F. Perazzi, J. Pont-Tuset, B. McWilliams, L. Van Gool, M. Gross, and A. Sorkine-Hornung, “A benchmark dataset and evaluation methodology for video object segmentation,” in Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2016.