🆕 Add SegFormer Architecture#1085
Open
Jiaqi-Lv wants to merge 6 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1085 +/- ##
=========================================
Coverage 99.88% 99.89%
=========================================
Files 86 88 +2
Lines 11661 11962 +301
Branches 1531 1549 +18
=========================================
+ Hits 11648 11949 +301
Misses 7 7
Partials 6 6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new transformer-based semantic segmentation architecture (SegFormer) backed by a Mix Transformer encoder, while refactoring existing segmentation architectures to reuse shared utility layers (e.g., Conv2dReLU, SegmentationHead, encoder utilities).
Changes:
- Add new SegFormer model implementation and a Mix Transformer (MiT) encoder backbone.
- Centralize shared encoder and convolution utilities in
architecture.utilsand remove duplicated implementations. - Add/adjust unit tests for the new architecture and for the moved utility functions.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
tiatoolbox/models/architecture/utils.py |
Adds shared building blocks (Conv2dReLU, EncoderMixin, dilation/patching utilities) used across architectures. |
tiatoolbox/models/architecture/timm_efficientnet.py |
Refactors EfficientNet encoder to import shared encoder mixin utilities instead of local copies. |
tiatoolbox/models/architecture/segformer.py |
Adds SegFormer model + decoder and inference/pre/post-processing helpers. |
tiatoolbox/models/architecture/mix_transformer.py |
Adds Mix Transformer backbone/encoder implementation used by SegFormer. |
tiatoolbox/models/architecture/grandqc.py |
Replaces local Conv2dReLU with the shared implementation from architecture.utils. |
tiatoolbox/models/architecture/efficientunet_tissue_mask_model.py |
Refactors to use shared Conv2dReLU and SegmentationHead from architecture.utils. |
tests/models/test_arch_utils.py |
Adds tests for moved utilities (patch_first_conv, replace_strides_with_dilation). |
tests/models/test_arch_timm_efficientnet.py |
Removes tests that moved to test_arch_utils.py. |
tests/models/test_arch_segformer.py |
Adds unit tests covering SegFormer model, decoder behavior, and preprocessing/postprocessing/inference. |
tests/models/test_arch_mix_transformer.py |
Adds unit tests for Mix Transformer backbone + encoder behaviors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds SegFormer segmentation model, and refactors the
EfficientUNetTissueMaskModelto use shared utility modules for common layers.New architectures for semantic segmentation
SegFormer
Mix Transformer (Encoder)
Refactoring for code reuse
EfficientUNetTissueMaskModelto use the sharedConv2dReLUandSegmentationHeadimplementations fromarchitecture.utils, replacing local definitions and reducing code duplication. [1] [2] [3] [4] [5]