Repository navigation
[BTY-63] MIU-VL: zero-shot polyp detection with a PyTorch GLIP-T port - #1655
Conversation
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>
2a059e7 to
4b61cf5
Compare
Test CoverageTotal: 87.32% (51558 / 59045 lines)
|
|
/review |
There was a problem hiding this comment.
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_promptsis re-read for every subset and prompt. This is fine as is, but you could cache it if the example grows.
Reviewed commit 4b61cf5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BdtuVKBLhWpYbhTQbaZaTt
…ce 2.1.0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BdtuVKBLhWpYbhTQbaZaTt
…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>
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
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.
pyhealth/models/miu_vl.py): the manual polyp prompt andPubMedBERT MLM attribute prompts.
pyhealth/datasets/polyp.py) and PolypDetection(
pyhealth/tasks/polyp_detection.py): MIU-VL's COCO boxes over PraNet'simages. 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.
pyhealth/metrics/detection.py): COCO box AP,matching pycocotools.
examples/miu_vl_polyp_zero_shot.py): reproduces the zero-shotrows 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).PolypDatasetuses_resolve_metadata_dirfrompyhealth/datasets/imaging/io.py, the shared helper the other imaging datasetsuse to choose where they write their metadata CSV. No existing component is
changed; the
__init__.pyedits only register the new exports.Tests
tests/core/test_glip.py,tests/core/test_polyp.pyandtests/core/test_detection_metrics.pyrun offline: random-weight GLIP forwardand 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%.