All posts

One model for every kidney finding, on a student budget.

How we trained nnU-Net to outline kidney stones, cysts and tumors together in 290 CT scans, and fit four models, five folds each, into five Colab Pro+ subscriptions.

Axial CT slice through the abdomen at the level of both kidneys. The model outlines both kidneys and a small tumor at the lower edge of one.

Three models that don’t talk

A CT scan of the abdomen can show a kidney stone, a cyst and a tumor at once. Most segmentation work trains one model for each: a stone model that only knows stones, a tumor model that only knows tumors. Our thesis asked whether one model that learns the kidney and all three findings together does better than three that each learn one.

It mattered most for stones. Trained alone, our stone model found them for a few dozen epochs, then gave up. In every one of the five folds, its stone score fell back to zero between epoch 25 and 39, and never came back. A stone is a few voxels in a scan of millions, and answering “no stone” everywhere is the easiest way to look right.

290 scans, read twice

We built one dataset out of two that were never meant to meet. Tumors came from KiTS23, a kidney tumor challenge collected across hospitals. Scans with more than one finding came from MSWAL, which labels lesions across the whole abdomen. Extra stone and cyst cases came with no masks at all, so we drew them ourselves in 3D Slicer. Every label then had to agree on one map: background, kidney, cyst, stone, tumor.

  • 74 stones only
  • 50 cysts only
  • 45 tumors only
  • 121 more than one
290 CT volumes, each a full 3D scan of the abdomen.

A radiologist checked them before any training. Dr. Nathaniel F. Paragas, an interventional radiologist at Capitol Medical Center and associate professor at the Mapúa University School of Medicine, supervised the ground truth.

Five Colab subscriptions

nnU-Net plans its own training: it reads the dataset and picks a patch size, a network and a batch size to fit the GPU. What it can’t plan around is a student budget. We trained on Colab Pro+, on a single A100, and every hour of it came out of five subscriptions.

5 subscriptions we paid for

15+ what batch 12 would have needed

Each card is one Colab Pro+ subscription. The filled ones trained all four models; the outlined ones are the rest of what our first settings would have cost.

The work adds up fast. Each model trains five times, once per fold of the cross-validation, and each fold is 1,000 epochs. We needed four models: the multi-class one, and the stone, cyst and tumor models it was measured against. That’s 20 folds and 20,000 epochs.

Our first runs used a batch size of 12, to make use of the A100’s memory, and an epoch took about 185 seconds. That sounds like the fast way: twelve patches at a time instead of two. But an nnU-Net epoch isn’t one pass over the data. It’s a fixed 250 batches, so twelve patches a batch is six times the work in every epoch, for the same 1,000 epochs.

One epoch at batch 12

250 batches × 12 patches = 3,000 patches

One epoch at batch 2

250 batches × 2 patches = 500 patches

Each column stands for 10 batches, each mark for one 128³ patch. Both epochs are 250 batches long; only the work inside each one changes.

At batch 12, one fold would have taken about 51 hours, and all 20 about 1,030: at least 15 subscriptions’ worth. So we dropped the batch to 2. Epochs fell to about 27 seconds, a fold to under 8 hours, and all 20 folds to about 150. That fit in five.

Training time at batch 12 and batch 2
Batch sizeAn epochOne foldAll 20 folds
12Our first runs~185 s~51 h~1,030 h
2What we trained with~27 s~7.6 h~150 h
1,000 epochs a fold, 5 folds a model, 4 models, on one A100. Times from nnU-Net’s own training logs.

What training together changed

Seeing the kidney and all three findings at once raised the Dice score for every finding.

Dice score for each finding, trained alone and together
FindingAloneTogether
Stone0.0000.512
Cyst0.2220.501
Tumor0.6130.763
Dice, from 0 (no overlap with the radiologist’s label) to 1 (a perfect match), averaged over the five folds. The kidney itself scored 0.955.

Stones went from nothing to 0.512. Trained together, the model kept finding stones through all 1,000 epochs, in every fold, and 84% of the stones it flags are real.

Cysts more than doubled. Alone, the model marked the bladder and gallbladder as kidney cysts. With the kidney beside it, cyst precision rose from 0.27 to 0.71.

Tumors rose from 0.613 to 0.763. The model finds 89% of tumors, and 86% of what it marks as tumor is one.

None of the three gains is luck: a paired Wilcoxon test over every scan with that finding puts each below p = 10−11. It’s faster too: one pass over a scan instead of three, 4.81 seconds a volume instead of 12.61.

The doctors’ read

Dice says how a prediction compares with a label. It doesn’t tell a doctor whether to trust the model on a scan that has no label. So we asked radiologists something narrower: does the model’s own score match what they see?

Dr. Paragas reviewed 15 predicted cases. So did Dr. Marc Gabriel P. Meriño, a radiology resident at Veterans Memorial Medical Center (VMMC), supervised by Dr. Bernardo G. Bringas, Jr., head of its Department of Radiology and Radiotherapy. Three of their cases, as they saw them: the plain slice on the left, the model’s prediction on the right, in the thesis’s own colors (kidney blue, cyst green, tumor red).

Two copies of an axial CT slice. On the right, the model colors both kidneys blue and a small cyst on the left kidney green.

cyst_048 · Cyst

Both agree

Kidney
0.973
Cyst
0.901
  • “The AI has outlined the cyst perfectly. Agree with the score.”

    Dr. Paragas

  • “Good and appropriate detection of AI.”

    VMMC

Axial · slice 86 of 177

Two copies of an axial CT slice. On the right, the model colors both kidneys blue, with green and red marks for cysts and tumor around them.

multi_106 · Cysts and a tumor

A low score that was honest

Kidney
0.896
Cyst
0.358
Tumor
0.015
  • “All the highlighted areas in both kidneys are cysts and not tumors. Agree with the poor scores.”

    Dr. Paragas

  • “Good detection of lesions but bad identification which is reflected by the confidence of AI.”

    VMMC

Axial · slice 85 of 325

Two copies of an axial CT slice. On the right, the model colors both kidneys blue and a large mass on the left kidney red, as tumor.

multi_118 · A cyst and a tumor

The reviewers split

Kidney
0.984
Cyst
0.872
Tumor
0.946
  • “The AI has outlined the cyst and tumor perfectly. Agree with the score.”

    Dr. Paragas

  • “Was good in detection but confidence for identifying as tumor is high; should be ‘failed.’”

    VMMC

Axial · slice 137 of 253

The two reads don’t always agree, and that’s why we asked two. A low score that’s honest, like multi_106’s, still tells a doctor where to look twice. One that’s confident and, by one reading, wrong, like multi_118’s tumor, is the case a tool in a clinic has to flag.

Try it

The code, the training notebooks and the evaluation figures are public. The demo film shows the app we built on top of the model: axial, coronal and sagittal views of a scan with the outlines on, and a 3D surface.