Downloads · 30 days
1
4% of all-time downloads
szabopeter/roi-segresnet-2d
roi-segresnet-2d is a image segmentation model from szabopeter. Use it for the image segmentation task on the model card, and read the license before you ship it in a product. It is set up for pytorch. The card lists the license as apache-2.0.
Per-slice 2D lung foreground (thoracic parenchyma) segmentation for chest CT. Used as the ROI stage of a two-stage coarse-to-fine pulmonary-nodule segmentation pipeline: its outputs are stacked into a 3D lung bounding…
Downloads · 30 days
1
4% of all-time downloads
All-time downloads
24
Public
Repo size
27.7 MB
Likes
0
Public
Click a slice to open those files.
.pth27.7 MB · 100%
From the Hugging Face model README
Per-slice 2D lung foreground (thoracic parenchyma) segmentation for chest CT. Used as the ROI stage of a two-stage coarse-to-fine pulmonary-nodule segmentation pipeline: its outputs are stacked into a 3D lung bounding box that the downstream nodule model crops to.
(1, 256, 256) axial CT slice, intensity-normalised to [0, 1](1, 256, 256) sigmoid map; foreground = lung tissueTrained on the unified split (patient-grouped, dataset-stratified)
of a unified corpus assembled from three public sources:
Slices per split: 365 014 train / 64 097 val / — test held out.
Evaluated on 64 097 val slices (≈ 4.2 × 10⁹ pixels), micro-averaged at 0.5 threshold on sigmoid output.
| Metric | Value |
|---|---|
| mIoU | 0.9803 |
| Accuracy | 0.9953 |
| Precision | 0.9797 |
| Recall | 0.9857 |
| Dice (F1) | 0.9827 |
import yaml, torch
from monai.networks.nets import SegResNet
cfg = yaml.safe_load(open("config.yaml"))["model"]
model = SegResNet(
spatial_dims = cfg["spatial_dims"],
in_channels = cfg["in_channels"],
out_channels = cfg["out_channels"],
init_filters = cfg["init_filters"],
blocks_down = tuple(cfg["blocks_down"]),
blocks_up = tuple(cfg["blocks_up"]),
dropout_prob = cfg["dropout_prob"],
)
state = torch.load("model.pth", map_location="cpu", weights_only=True)
model.load_state_dict(state)
model.eval()
with torch.no_grad():
x = torch.randn(1, 1, 256, 256) # (B, C, H, W) — replace with your CT slice
prob = torch.sigmoid(model(x))
lung_mask = (prob > 0.5).to(torch.uint8)
DiceLoss(sigmoid=True, squared_pred=True)Full config is included in this repo as config.yaml.
Training code lives in an accompanying reproduction demo (published separately). Once available, reproduce with:
export DATA_ROOT=/path/to/unified # dir containing ct_2d/ and roi_sem_seg_2d/
python train.py --config config.yaml
Model weights released under Apache 2.0. Training data was public but covered by dataset-specific terms (NLST, NSCLC-Radiomics, LIDC-IDRI) — users must comply with those separately when using the model on comparable data.
Not a medical device. Not intended for clinical use. Research only.
Paper in preparation.