# MSNet and M2SNet: multi-scale subtraction networks for medical image segmentation

> This repository holds the official code for MSNet, an automatic polyp segmentation network from MICCAI 2021, and M2SNet, its multi-scale in multi-scale successor published in 2026, both built on a subtraction mechanism that pairs Res2Net backbone features at several scales inside a layer and between layers. It suits a researcher reproducing those two papers, and it ships pretrained weights because training from scratch is not the intended route.

**Xiaoqi-Zhao-DLUT/MSNet-M2SNet** — (MIR 2026 [M2SNet] & MICCAI 2022 GOALS Challenge & MICCAI 2021 [MSNet]) Multi-scale in Multi-scale Subtraction Network for Medical Image Segmentation

- Repository: https://github.com/Xiaoqi-Zhao-DLUT/MSNet-M2SNet
- Stars: 1,030 · Forks: 87
- Language: Python
- License: not declared
- Published: 2026-10-19 · Updated: 2026-10-19 · Language: en
- Canonical page: https://hysenlabs.com/projects/xiaoqi-zhao-dlut-msnet-m2snet

## One repository, two papers and one idea

The repository is the official home for two related networks by Xiaoqi Zhao and colleagues. The first is MSNet, Automatic Polyp Segmentation via Multi-scale Subtraction Network, published at MICCAI 2021, and the second is M2SNet, Multi-scale in Multi-scale Subtraction Network for Medical Image Segmentation, published in 2026 in Machine Intelligence Research. Both papers are linked to arXiv from the README, with the MSNet paper at 2108.05082 and the M2SNet paper at 2303.10894, and the BibTeX entries are included at the bottom of the file.

The core idea they share is subtraction. The highlighted features in the README are a novel segmentation architecture, an efficient intra-layer multi-scale subtraction design, an efficient inter-layer multi-scale subtraction structure, a training-free loss network, and low FLOPs with the comparisons given under the Res2Net-50 backbone. So the design has two axes of multi-scale. Within a single layer, features at different scales are combined by subtracting them, and between layers the same operation is applied at a different granularity. The M2SNet title, multi-scale in multi-scale, is the paper's own way of saying that.

The credentials are visible too. The README shows an image of a MICCAI 2022 award, and states that the team took second place out of 100 in the MICCAI 2022 Challenge on Glaucoma Oct Analysis and Layer Segmentation, the GOALS challenge. For anyone judging whether this is a research project with a track record, that is the relevant signal, more so than the presence of a model directory.

The repository layout is small and direct, with train.py, prediction_rgb.py, test_score.py, a utils/ directory, a model/ directory holding the network definitions, and an image/ directory for the figures used in the README. There is no packaging, no setup.py and no tests directory.

## The subtraction mechanism at two granularities

The architecture is what makes these networks interesting, and the README points at it through the figures rather than through code, so the mechanism has to be read out of the paper.

The intra-layer design is the Res2Net idea taken further. The multi-scale subtraction arrangement works on the multi-scale features that backbone produces and forms differences between them, so a channel can encode the contrast between a fine scale and a coarse scale rather than a single absolute response. The inter-layer structure applies the same idea across layers rather than within one, which is the second scale axis and the specific addition M2SNet makes.

The practical consequence for a user is that this is a network you instantiate with a Res2Net-style backbone rather than a general segmentation library you point at a dataset. The README's FLOPs comparison is explicitly made under the Res2Net-50 backbone, and the trained MSNet and M2SNet models are distributed as downloadable files, along with a separate download for the Res2Net weights. Those Res2Net weights are not optional, because the subtraction modules operate on the multi-scale features that backbone produces.

The training-free loss network is the other distinctive component, and the name is the explanation. Rather than training a separate network to produce a loss, the design uses a loss network that requires no training of its own, which removes a training dependency and a source of instability from the pipeline. For someone reproducing the work, that is a meaningful simplification rather than a detail, because a jointly trained loss network has to be scheduled against the segmentation loss.

## Datasets come from Google Drive and BaiduYunPan

The data is published as links rather than bundled, and each dataset has both a training and a testing split with two mirrors.

For image polyp segmentation, the training and testing datasets are on Google Drive and BaiduYunPan, and there is a separate video polyp segmentation pair with the same two mirrors. A COVID-19 lung infection dataset is listed the same way, and a breast ultrasound segmentation dataset is listed with a Google Drive and a BaiduYunPan link.

The dual hosting is worth noting for a practical reason. The two services have different availability from different networks, and the BaiduYunPan links are the more reliable route for readers in China, which matters for a project originating at Dalian University of Technology. The same pattern applies to everything else the project publishes. The results for MSNet and for M2SNet are each hosted on both, the trained MSNet model and the trained M2SNet model are each on both, and the Res2Net weights are on both.

None of this is in a package index, a model hub or a scripted download. The links are in the README and the files are archives. That is a real friction point for a reproducibility workflow, since a script that fetches the model cannot rely on a stable registry URL, and it means the results and the weights will drift out of sync with the code unless you keep the README's links yourself.

The data itself is medical imaging, and the applications covered in the TODO list give a sense of the range: polyp, COVID-19 lung infection, breast tumour and OCT layer are marked done, while prostate, cell nuclei, liver, retinal vessel, skin lesion, lung, pancreas, hippocampus, heart and brain tumour are listed as pending.

## Training, prediction and the ten evaluation metrics

The workflow is three scripts, and the README documents them in order.

Training starts by setting the configuration in train.py.

```python
Dataset.Config(datapath='', savepath='', mode='train', batch=16, lr=0.05, momen=0.9, decay=5e-4, epoch='')
```

Then you run the training script.

```bash
python train.py
```

The epoch count is set per dataset rather than by the script, and the README gives the numbers, 50 epochs for polyp segmentation, 200 for COVID-19 lung infection, 100 for breast tumour segmentation and 100 for OCT layer segmentation. The learning rate of 0.05 in the configuration is a large value for a segmentation network, which is consistent with the Res2Net style training setup these papers use, and momentum and weight decay are set in the same call.

Prediction is a separate script, prediction_rgb.py, which the README says can generate the predicted maps. Scoring is test_score.py, and it supports ten binary segmentation evaluation metrics, named in the README as MAE, maxF, avgF, wfm, Sm, Em, M_dice, M_iou, Ber and Acc. That metric set is the interesting part for a polyp or lesion segmentation paper, because the region overlap measures and the boundary measures are reported side by side, and MAE and the error rate cover the pixel accuracy side.

The prerequisites are pinned to a specific generation of the stack: Python 3.7, PyTorch 1.8.1, OpenCV 4.6, Numpy 1.19, and NVIDIA Apex. Python 3.7 is long past end of life, so reproducing this today means working inside an old environment rather than a current one.

## Where MSNet-M2SNet is the wrong tool

Three cases argue against it. The first is a production medical imaging deployment. The repository is research code. There is no inference service, no DICOM handling, no test harness, no validation study and no regulatory story, and the model is a segmentation network for specific datasets rather than a product. The performance numbers in the paper are measured on benchmark datasets with a test_score.py that computes ten metrics, and a clinician facing a real screening requirement needs something categorically different.

The second case is a project that wants a modern segmentation model. The pinned stack, Python 3.7, PyTorch 1.8.1 and Numpy 1.19, is a 2021 environment. Reproducing it means an old CUDA, an old Python and a fair amount of environment work, and if you have the option of a maintained implementation of a current architecture, that is usually less work than making this one run.

The third case is a task outside the two papers. The TODO list is a good guide to the limits of what has been done. Support for different backbones such as VGGNet, MobileNet, ResNet and Swin is still unchecked, and a 3D version of MSNet training is still open, which is significant given that the prostate task in the list is a 3D problem. Only four of the fourteen listed medical imaging tasks are marked as done.

There is a licensing point as well, and it is unusual. The repository records no licence identifier, and the README does not state one either. The code is public and the weights are downloadable, but without a licence file the terms for reuse are not settled, so anyone intending to build a product on this code has a question to raise with the authors rather than an answer they can rely on. That is worth resolving before you invest in a port.

On maintenance, the last push was on 2026-07-20 and there are no GitHub releases, so the code is the artifact and there is no version history to pin to.

## Conclusion

MSNet-M2SNet suits a researcher who wants the exact architecture, weights and evaluation code from the two papers rather than a general purpose segmentation library, and who is prepared to work with a 2021 era PyTorch stack. It does not suit production medical imaging, since the repository ships no inference service, no validation pipeline and no clinical evidence, and it does not suit a team that needs a maintained model zoo. Before you build on it, read the training configuration in train.py and set the epoch count for your dataset, download the Res2Net weights the model expects, and note that the last push was on 2026-07-20 with no tagged releases and no declared licence.

## FAQ

### What are MSNet and M2SNet?

MSNet is Automatic Polyp Segmentation via Multi-scale Subtraction Network, published at MICCAI 2021, and M2SNet is Multi-scale in Multi-scale Subtraction Network for Medical Image Segmentation, published in 2026 in Machine Intelligence Research. This repository is the official code for both, and the team took second place out of 100 in the MICCAI 2022 GOALS challenge.

### How do I train MSNet or M2SNet?

Set the configuration in train.py, including the datapath, savepath and the epoch count for your dataset, and then run python train.py. The README gives 50 epochs for polyp, 200 for COVID-19 lung infection, 100 for breast tumour and 100 for OCT layer segmentation.

### How do I evaluate the segmentation results?

Run test_score.py, which supports ten binary segmentation evaluation metrics: MAE, maxF, avgF, wfm, Sm, Em, M_dice, M_iou, Ber and Acc. Prediction maps are generated separately with prediction_rgb.py.

### What do I need to install to run this?

The README lists Python 3.7, PyTorch 1.8.1, OpenCV 4.6, Numpy 1.19 and NVIDIA Apex, plus the trained MSNet or M2SNet model and the Res2Net weights, which are published as downloads on Google Drive and BaiduYunPan.

## Sources

- [Issues](https://github.com/Xiaoqi-Zhao-DLUT/MSNet-M2SNet/issues)
- [README](https://github.com/Xiaoqi-Zhao-DLUT/MSNet-M2SNet/blob/main/README.md)
- [Xiaoqi-Zhao-DLUT/MSNet-M2SNet on GitHub](https://github.com/Xiaoqi-Zhao-DLUT/MSNet-M2SNet)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/xiaoqi-zhao-dlut-msnet-m2snet
