Skip to content

[BTY-63] MIU-VL: zero-shot polyp detection with a PyTorch GLIP-T port - #1655

Merged
solarsys merged 1 commit into
sunlabuiuc:masterfrom
irvifa:bty-63-miu-vl
Nov 28, 2026
Merged

solarsys merged 1 commit into
sunlabuiuc:masterfrom
irvifa:bty-63-miu-vl

Conversation

@irvifa

@irvifa irvifa commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Add prompt-based zero-shot detection from MIU-VL (Qin et al., ICLR 2023,
https://arxiv.org/abs/2209.15517) on the five PraNet polyp test sets.

What this adds

  • GLIP (pyhealth/models/glip.py): a pure-PyTorch port of GLIP-T (Swin-T,
    O365 + GoldG) that loads the official checkpoint and runs on CPU, CUDA and
    MPS. It matches the official code within float error.
  • MIU-VL prompts (pyhealth/models/miu_vl.py): the manual polyp prompt and
    PubMedBERT MLM attribute prompts.
  • PolypDataset (pyhealth/datasets/polyp.py) and PolypDetection
    (pyhealth/tasks/polyp_detection.py): MIU-VL's COCO boxes over PraNet's
    images. Sources: MIU-VL (https://github.com/MembrAI/MIU-VL) and PraNet
    (https://github.com/DengPingFan/PraNet), with download links in the class
    docstring and the docs page.
  • detection_metrics_fn (pyhealth/metrics/detection.py): COCO box AP,
    matching pycocotools.
  • Example (examples/miu_vl_polyp_zero_shot.py): reproduces the zero-shot
    rows of Table 3.

Results

With the prompt "polyp", the port reproduces the paper's GLIP-T row: 6.1 AP on
CVC-300, and 4.5 averaged over the five sets against the paper's 4.1. The
released hybrid prompts are within 1.2 AP of the paper on CVC-300, ClinicDB and
ColonDB.

Shared code

The new components build only on base classes (BaseModel, BaseDataset,
BaseTask). PolypDataset uses _resolve_metadata_dir from
pyhealth/datasets/imaging/io.py, the shared helper the other imaging datasets
use to choose where they write their metadata CSV. No existing component is
changed; the __init__.py edits only register the new exports.

Tests

tests/core/test_glip.py, tests/core/test_polyp.py and
tests/core/test_detection_metrics.py run offline: random-weight GLIP forward
and checkpoint round-trip, MLM prompts with a fake model, a synthetic polyp
folder for the dataset and task, and a pycocotools-derived AP reference case.
Coverage of the changed pyhealth/ files is between 98.3% and 100%.

Add prompt-based zero-shot detection from MIU-VL (Qin et al., ICLR 2023)
on the five PraNet polyp test sets:

- GLIP (pyhealth/models/glip.py): a pure-PyTorch port of GLIP-T (Swin-T,
  O365 + GoldG) that loads the official checkpoint and runs on CPU, CUDA
  and MPS. It matches the official code within float error.
- MIU-VL prompts (pyhealth/models/miu_vl.py): the manual polyp prompt and
  PubMedBERT MLM attribute prompts.
- PolypDataset and PolypDetection: MIU-VL's COCO boxes over PraNet's
  images.
- detection_metrics_fn: COCO box AP, matching pycocotools.
- examples/miu_vl_polyp_zero_shot.py: reproduces the zero-shot rows of
  Table 3.

With the prompt "polyp" the port reproduces the paper's GLIP-T row
(6.1 AP on CVC-300, 4.5 vs 4.1 averaged over the five sets). The
released hybrid prompts are within 1.2 AP of the paper on CVC-300,
ClinicDB and ColonDB.

Signed-off-by: Irvi Aini <irvi.fa@gmail.com>
@github-actions

Copy link
Copy Markdown

Test Coverage

Total: 87.32% (51558 / 59045 lines)

Modified file Coverage Lines
pyhealth/datasets/__init__.py 100.00% 86 / 86
pyhealth/datasets/polyp.py 100.00% 65 / 65
pyhealth/metrics/__init__.py 100.00% 17 / 17
pyhealth/metrics/detection.py 98.80% 82 / 83
pyhealth/models/__init__.py 100.00% 103 / 103
pyhealth/models/glip.py 98.90% 537 / 543
pyhealth/models/miu_vl.py 100.00% 31 / 31
pyhealth/tasks/__init__.py 98.31% 116 / 118
pyhealth/tasks/polyp_detection.py 100.00% 13 / 13

Workflow run · 4b61cf5

@solarsys solarsys added the status: automatic The PR will go through automatic review process. label Nov 28, 2026
@solarsys

Copy link
Copy Markdown
Collaborator

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Review

suggestion: approve
decision: approve

Thank you for this contribution. It adds a pure-PyTorch GLIP-T port, the MIU-VL prompts, a PolypDataset and PolypDetection task, a COCO box AP metric, docs and an example that reproduces the zero-shot rows of Table 3.

It looks ready to merge. The new components build on the base classes (BaseModel, BaseDataset, BaseTask). The __init__.py edits only register new exports and remove or rename nothing. PolypDataset's use of _resolve_metadata_dir from the imaging helpers is named in the description with a clear reason. The dataset's class docstring and docs page cite their sources (PraNet, MIU-VL and the underlying datasets). The docs match the code.

Coverage is above the bar. The whole repository is at 87.3%, against the 60% guideline. Every changed or added file under pyhealth/ is at least 98.3%, against the 80% guideline.

Optional suggestions:

  • Add a short note in the GLIP docs on the expected memory and CPU runtime per image. Users will meet the 3.7 GB checkpoint download and the 800px inference size.
  • In the example, hybrid_prompts is re-read for every subset and prompt. This is fine as is, but you could cache it if the example grows.

Reviewed commit 4b61cf5

@solarsys
solarsys merged commit 3a63733 into sunlabuiuc:master Nov 28, 2026
3 checks passed
solarsys added a commit to solarsys/PyHealth that referenced this pull request Nov 28, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BdtuVKBLhWpYbhTQbaZaTt
solarsys added a commit to solarsys/PyHealth that referenced this pull request Nov 28, 2026
@irvifa
irvifa deleted the bty-63-miu-vl branch November 28, 2026 10:30
jeremy-chy added a commit to jeremy-chy/PyHealth that referenced this pull request Nov 28, 2026
…mortality

Both upstream PRs added entries to the same task toctree as this branch;
keep both. The other index files merged cleanly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: automatic The PR will go through automatic review process.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants