MedSegAgent (https://ieeexplore.ieee.org/document/11455620) を再現するためのWebAppを実装

agents FEAT: update MedSegAgent V1 Core (#1) 1 year ago
assets Update README 6 months ago
dataset FEAT: update MedSegAgent V1 Core (#1) 1 year ago
prompts FEAT: update MedSegAgent V1 Core (#1) 1 year ago
results FEAT: update MedSegAgent V1 Core (#1) 1 year ago
skills/ medsegagent-nnunet-runner add medsegagent skill 6 months ago
utils FEAT: update MedSegAgent V1 Core (#1) 1 year ago
webapp Add ChatGPT-style TotalSegmentator demo webapp 21 days ago
.DS_Store FEAT: update MedSegAgent V1 Core (#1) 1 year ago
.gitignore Add ChatGPT-style TotalSegmentator demo webapp 21 days ago
LICENSE FEAT: update MedSegAgent V1 Core (#1) 1 year ago
MedSegAgent_JBHI_2026.pdf Add JBHI paper PDF 5 months ago
OAI_CONFIG_LIST.example FEAT: update MedSegAgent V1 Core (#1) 1 year ago
README.md Add ChatGPT-style TotalSegmentator demo webapp 21 days ago
eval_diff_llms.sh FEAT: update MedSegAgent V1 Core (#1) 1 year ago
eval_example.sh FEAT: update MedSegAgent V1 Core (#1) 1 year ago
evaluate.py FEAT: update MedSegAgent V1 Core (#1) 1 year ago
model_selection_bench.jsonl FEAT: update MedSegAgent V1 Core (#1) 1 year ago
model_selection_test_case.jsonl FEAT: update MedSegAgent V1 Core (#1) 1 year ago
requirements.txt FEAT: update MedSegAgent V1 Core (#1) 1 year ago
README.md

MedSegAgent: A Universal and Scalable Multi-Agent System for Instructive Medical Image Segmentation

This work has been accepted by the IEEE Journal of Biomedical and Health Informatics (JBHI). Paper: IEEE Xplore | PDF.

MedSegAgent framework

Overview of the MedSegAgent framework: natural language query parsing, coarse-to-fine dataset matching, and final segmentation with result integration.

MedSegAgent is a multi-agent system for instructive medical image segmentation. Instead of training one universal segmentation model, it orchestrates specialized dataset-specific models through natural language understanding, coarse-to-fine dataset matching, and execution-time result integration.

Key Features:

  • Universal & Scalable: Tackle diverse medical image segmentation tasks using natural language instructions.
  • Precise Automation: Automatically selects the most suitable segmentation models.
  • Enhanced Robustness: Improves reliability through multi-model integration and ensemble capabilities.

Overview

MedSegAgent parses a free-form segmentation request, filters candidate datasets from modality to anatomy to label, and then runs the matched segmentation models. The current repository organizes each integrated dataset with a standardized JSON metadata entry in dataset/, making it straightforward to extend the model library with new tasks.

In the paper setting, MedSegAgent integrates 23 datasets and supports 343 segmentation targets across CT, MRI, PET/CT, and ultrasound-related scenarios.

Skill

This repository also includes a reusable skill at skills/medsegagent-nnunet-runner/ for inspecting nnUNet_results, selecting a deployed task, and running or preparing nnUNet inference.

The skill is intended for environments that already have nnUNet v2 available. To run inference, the target environment must provide a configured nnUNet_results path and usable nnUNet CLI or Python API support.

Demo Webapp

webapp/ contains a standalone, ChatGPT-style chat demo: type a free-text segmentation request and upload a CT/MRI .nii.gz volume, and it runs real TotalSegmentator inference (modality auto-detected from the volume) and shows the result overlaid in-browser via Niivue. See webapp/README.md for setup and details. Once dependencies are installed (pip install -r webapp/requirements.txt), launch it with:

uvicorn webapp.backend.main:app --host 0.0.0.0 --port 8000 --reload

Thttp://localhost:8000/`.

Supported Datasets

The repository currently includes metadata for the following datasets and targets. The summary below is adapted from the dataset table in the paper. The links point to official dataset access pages rather than direct-download mirrors hosted by this repository; some datasets still require registration, challenge participation, or a signed data-use agreement before download.

DatasetModalitiesBody RegionRepresentative TargetsData access
TotalSegmentator v2CTWhole-body117 structures including organs, vessels, bones, and brainZenodo
TotalSegmentator MRIMRIWhole-body56 structures including organs, vessels, spine, muscles, and brainZenodo
CT-ORGCTWhole-bodyliver, bladder, lungs, kidneys, bone, brainTCIA
AutoPETPET/CTWhole-bodywhole-body tumor sitesTCIA FDG-PET-CT-Lesions
SegRap2023 Task1CTHead and neck45 OAR structuresGrand Challenge
BraTS21MRIHead and neckwhole tumor, tumor core, enhancing tumorCBICA BraTS 2021
ISLES22MRIHead and neckstroke lesionZenodo
ISLES22 ATLASMRIHead and neckstroke lesionGrand Challenge
Instance22CTHead and neckintracranial hemorrhageGrand Challenge
HECKTOR2022PET/CTHead and neckGTVp, GTVndGrand Challenge
SegRap2023 Task2CTHead and neckGTVp, GTVndGrand Challenge
MM-WHSMRI, CTHeartcardiac chambers, myocardium, great vesselsChallenge site
ACDCMRIHeartleft ventricle, right ventricle, myocardiumChallenge site
ImageCASCTHeartcoronary arteryKaggle
Parse22CTThoraxpulmonary arteryGrand Challenge
ATM22CTThoraxpulmonary airwayGrand Challenge
AbdomenAtlasMiniCTAbdomenkidneys, liver, pancreas, spleen, stomach, vesselsHugging Face
AMOS22 Task2MRI, CTAbdomen15 abdominal and pelvic structuresZenodo
FLARE22CTAbdomen13 abdominal organsGrand Challenge
WORDCTAbdomenabdominal organs, bowel, bladder, femursGitHub
KiTS23CTAbdomenkidneys, renal tumors, renal cystsChallenge site
LiTSCTAbdomenliver, liver tumorKaggle
Adrenal-ACC-Ki67-SegCTAbdomenadrenocortical carcinomaTCIA

Quick Start:

Setup your environment

conda create -n medsegagent python=3.12
conda activate medsegagent
pip install uv
uv pip install -r requirements.txt

Then set your LLM service API keys like OAI_CONFIG_LIST.example, the config file should be named OAI_CONFIG_LIST.

[
    {
        "model": "Qwen/Qwen2.5-32B-Instruct",
        "api_key": "<Your API KEY>",
        "base_url": "https://api.siliconflow.cn/v1",
        "tags": ["silicon"]
    },
    {
        "model": "gpt-4o-2024-08-06",
        "api_key": "<Your API KEY>",
        "base_url": "<your BASE URL>",
        "tags": ["openai"]
    }
]

Test script

Start from eval_example.sh to try our Coarse-to-Fine setting of seg model selection.

python ./evaluate.py \
    --test_file_path "model_selection_test_case.jsonl" \
    --test_pattern "C2F"  \
    --model "gpt-4o-2024-08-06"    \
    --log_to_file

Acknowledgments

This project builds on the open contributions of the medical image segmentation community. We gratefully acknowledge the creators and maintainers of the public datasets integrated in MedSegAgent, whose annotations, benchmarks, and challenge platforms make this system possible.

We also acknowledge nnU-Net, which provides the strong self-configuring segmentation framework used for the dataset-specific models in our study.

TODO

  • Upload the trained segmentation models.

Citation

If you use MedSegAgent in your research, please cite:

@ARTICLE{11455620,
  author={Huang, Ziyan and Wang, Haoyu and Ye, Jin and Ji, Yuanfeng and Hu, Xiaowei and Liu, Lihao and Yang, Zhikai and Li, Wei and Hu, Ming and Su, Yanzhou and Li, Tianbin and Gu, Yun and Zhang, Shaoting and Qiao, Yu and Gu, Lixu and He, Junjun},
  journal={IEEE Journal of Biomedical and Health Informatics},
  title={MedSegAgent: A Universal and Scalable Multi-Agent System for Instructive Medical Image Segmentation},
  year={2026},
  volume={},
  number={},
  pages={1-12},
  keywords={Image segmentation;Medical diagnostic imaging;Filtering;Solid modeling;Natural languages;Computed tomography;Computational modeling;Accuracy;Multi-agent systems;Liver;Universal Medical Image Segmentation;Multi-Agent System;Natural Language Instruction},
  doi={10.1109/JBHI.2026.3677444}
}