YizeezLiu/DermAgent

DermAgent: A Self-Reflective Agentic System for Dermatological Image Analysis with Multi-Tool Reasoning and Traceable Decision-Making

10

stars

6

commits

Python

primary language

Jul 12, 2026

updated

README

DermAgent: A Self-Reflective Agentic System for Dermatological Image Analysis with Multi-Tool Reasoning and Traceable Decision-Making

arXiv License: Apache 2.0 Python 3.10+

A self-reflective agentic system for dermatological image analysis, built on LangChain/LangGraph.

DermAgent orchestrates seven specialist vision and language tools (PanDerm, MAKE, DermoGPT, Qwen3-VL, Case RAG, Guideline RAG, Ontology) within a Plan-Execute-Reflect framework, using GPT-4o as the reasoning backbone. A deterministic Critic module performs post-hoc auditing via confidence, coverage, and conflict gates to trigger targeted self-correction, delivering stepwise, traceable diagnostic reasoning.

Architecture

DermAgent Architecture

Project Structure

DermAgent/
├── .agents/skills/              # Repo-level Codex skills
│   └── mayo-dermnet-corpus-pipeline/ # Guideline corpus reproduction contract
├── skin_agent/                  # Core agent framework
│   ├── benchmark_agent.py       # Benchmark agent + Critic + AnswerParser
│   ├── configs.py               # Dataset task configurations
│   ├── tracing.py               # TraceLogger, TracingCallback
│   ├── profiler.py              # Performance profiling
│   ├── resume.py                # Checkpoint/resume for long runs
│   ├── prompts.md               # System prompts
│   ├── tools/
│   │   ├── base.py              # BaseSkinTool, input schemas
│   │   ├── skin_tools.py        # All 7 tool implementations
│   │   ├── executor.py          # Tool execution orchestration
│   │   └── derm_knowledge_tree/ # Disease ontology JSONs
│   └── utils/
│       ├── retry.py             # Rate-limit retry logic
│       └── image_utils.py       # Image path handling
├── benchmark/                   # Unified evaluation framework
│   ├── run.py                   # CLI runner for single-model baselines
│   ├── metrics.py               # Shared metrics (classification, multilabel, captioning, VQA)
│   ├── models/                  # Model wrappers (GPT-4o, LLaVA-Med, HuatuoGPT, etc.)
│   └── datasets/                # Dataset configs with prompts and class lists
├── scripts/                     # All runnable scripts
│   ├── build_qdrant_db.py       # Build image RAG vector database
│   ├── build_qdrant_rag.py      # Build text RAG (guidelines)
│   ├── run_task1_ham10000_500_agent_dermogpt_full_critic.sh
│   ├── run_task1_snu_500_critic.sh
│   ├── run_task2_task3_agent_critic.sh
│   ├── run_task3_loo_ablation.sh
│   └── *.py                     # Python runner scripts
├── baselines/                   # Agent-based baseline reproductions
│   ├── MDAgents/                # MDAgents agent baseline (NeurIPS 2024)
│   ├── MedAgent-Pro/            # MedAgent-Pro agent baseline
│   └── SkinVL/                  # SkinVL-PubMM baseline
├── data/                        # Benchmark CSV metadata
├── requirements.txt
└── .env.example

Setup

1. Environment

conda create -n dermagent python=3.10
conda activate dermagent

# Install PyTorch (match your CUDA version)
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu126

pip install -r requirements.txt

# Download NLTK data (needed for BLEU/ROUGE metrics)
python -c "import nltk; nltk.download('punkt'); nltk.download('punkt_tab')"

2. API Keys

cp .env.example .env
# Edit .env: set OPENAI_API_KEY (required) and other variables as needed

3. External Dependencies

The following external code/data directories are required but not included in this repository due to size or licensing. Place them at the project root:

DirectoryPurposeHow to Obtain
Derm1M/src/Custom OpenCLIP fork for PanDerm & RAG encodersClone from the Derm1M repository
MAKE/src/Custom OpenCLIP fork for MAKE concept annotationClone from the MAKE repository
MAKE/concept_annotation/term_lists/ConceptTerms.jsonConcept term definitions for MAKEIncluded in the MAKE repository above
model-weights/DermoGPT-RLDermoGPT-RL fine-tuned model weightsDownload from the DermoGPT repository
MM-Skin/LLaVA package used by the SkinVL-PubMM baselineClone from the MM-Skin repository
model-weights/SkinVL-PubMMSkinVL-PubMM model weights for the baselineDownload from HuggingFace zwq803/SkinVL-PubMM
RAG/dermnet_chunks_cleaned.jsonDermNet guideline chunks for Text RAGFollow the corpus pipeline skill
RAG/mayo_chunks_cleaned.jsonMayo Clinic guideline chunks for Text RAGFollow the corpus pipeline skill
datasets/Derm1M/Derm1M dataset for building image RAG indexDownload from Derm1M

For Text RAG models, pre-download the embedding and reranker models into model-weights/:

# Pre-download Qwen3 Embedding and Reranker for Text RAG
huggingface-cli download Qwen/Qwen3-Embedding-8B --local-dir model-weights/Qwen3-Embedding-8B
huggingface-cli download Qwen/Qwen3-Reranker-0.6B --local-dir model-weights/Qwen3-Reranker-0.6B

4. Datasets

Download the following datasets and place images in the expected directories:

DatasetTaskDownloadImage Directory
HAM10000Diagnosis (7 classes, 642 imgs)ISIC Archivedatasets/ham10000/images/
SNUDiagnosis (134 classes, 500 imgs)SNU Quizdatasets/SNU/images/
Derm7ptConcept Annotation (7 concepts)Derm7ptdatasets/derm7pt/final_images/
SkinConConcept Annotation (32 concepts)SkinCondatasets/skincon/final_images/
SkinCAPCaptioning (100 imgs)SkinCAPdatasets/skin_cap/images/

Benchmark CSV metadata (split definitions) are included in data/.

5. RAG Vector Database

To reproduce the Mayo Clinic and DermNet source corpora without redistributing scraper code or article content, follow the repo-level Mayo + DermNet corpus pipeline skill. It documents the Python environment, final pipeline, and JSON contract expected by scripts/build_qdrant_rag.py.

Install and start Qdrant (vector database server):

# Option A: Docker (recommended)
docker run -d -p 6333:6333 -v $(pwd)/qdrant_storage:/qdrant/storage qdrant/qdrant

# Option B: Local binary — see https://qdrant.tech/documentation/guides/installation/

Build the Qdrant vector databases:

# Image-based case retrieval (requires Derm1M dataset + Derm1M/src/)
python scripts/build_qdrant_db.py

# Guideline-grounded text retrieval (requires RAG/ JSON files)
python scripts/build_qdrant_rag.py

6. Model Weights

Most tool models are auto-downloaded from HuggingFace on first use:

Models that must be manually placed in model-weights/:

  • DermoGPT-RL: See Step 3 above (~16GB VRAM, bfloat16)
  • Qwen3-Embedding-8B / Qwen3-Reranker-0.6B: See Step 3 above (Text RAG)

Total GPU requirement: ~20-22GB for all tools loaded simultaneously.

Table 1: Main Results

ModelTypeHAM10000 (Acc.)SNU (Acc.)Derm7pt (F1-Macro)SkinCon (F1-Macro)SkinCAP (ROUGE-L)
LLaVA-Med-v1.5Medical MLLM0.44240.01200.51700.13100.1532
HuatuoGPTMedical MLLM0.51400.04000.53430.09490.1432
DermoGPT-RLDermatology MLLM0.50000.09200.56860.20720.1541
SkinVL-PubMMDermatology MLLM0.45170.03400.53140.13200.1444
Qwen3-VL-8BGeneral MLLM0.51090.07800.53700.22820.1247
GPT-4oGeneral MLLM0.48910.15000.54140.29560.1633
GPT-5.2General MLLM0.35980.14800.53860.26620.1235
MDAgentsMedical Agent0.16820.11400.36140.23930.1199
MedAgent-ProMedical Agent0.57630.11600.64820.18340.1148
DermAgent (Ours)Medical Agent0.61830.32600.65060.32950.1948

Commands to reproduce DermAgent results:

# HAM10000 Diagnosis
bash scripts/run_task1_ham10000_500_agent_dermogpt_full_critic.sh

# SNU Diagnosis
bash scripts/run_task1_snu_500_critic.sh

# Derm7pt + SkinCon + SkinCAP
bash scripts/run_task2_task3_agent_critic.sh

Commands to reproduce baseline results (see baselines/README.md for agent baselines):

# Single-model MLLM baselines (e.g., GPT-4o on HAM10000)
cd benchmark && python run.py --model gpt4o --dataset HAM10000_500

# MDAgents agent baseline
cd baselines/MDAgents && python run_derm_benchmark.py --dataset HAM10000 --difficulty basic --model gpt-4o

# MedAgent-Pro agent baseline
cd baselines/MedAgent-Pro && python Derm_Case_level.py --task 1 \
    --csv-path ../../datasets/ham10000/HAM10000_benchmark_500.csv \
    --image-dir ../../datasets/ham10000 --max-samples 500

Table 2: Ablation Study (Leave-One-Out on SkinCAP)

ConfigurationROUGE-LDelta (%)
Full Agent (w/ Critic)0.1948+12.8
Full Agent (w/o Critic)0.1727---
  w/o Case RAG0.1580-8.5
  w/o Guideline RAG0.1628-5.7
  w/o DermoGPT0.1672-3.2
  w/o PanDerm0.1676-3.0
  w/o MAKE0.1679-2.8
  w/o Ontology0.1712-0.9

Command to reproduce ablation results:

# Runs 6 leave-one-out experiments sequentially (removes one tool at a time)
bash scripts/run_task3_loo_ablation.sh

The full agent result (w/ Critic, ROUGE-L: 0.1948) is produced by the Task 3 portion of run_task2_task3_agent_critic.sh. The "w/o Critic" baseline (0.1727) is produced by the LOO script's full-tool run without the Critic module.

Tool Descriptions

ToolModelPurpose
PanDerm ClassifierDermLIPZero-shot disease classification via CLIP similarity
MAKE AnnotatorMAKE (OpenCLIP)Dermoscopic concept extraction
DermoGPT VQADermoGPT-RLDermatology-specialized visual QA
Qwen3-VL VQAQwen3-VL-8BGeneral visual question answering
Image RAGDermLIP + QdrantCase retrieval from 413,210 diagnosed cases
Text RAGQwen3-Embedding + QdrantGuideline retrieval from 3,199 document chunks
OntologyKnowledge GraphDisease hierarchy and taxonomy queries

Citation

Paper: arXiv:2605.14403 (MICCAI 2026, early accept).

@article{liu2026dermagent,
  title={DermAgent: A Self-Reflective Agentic System for Dermatological Image
         Analysis with Multi-Tool Reasoning and Traceable Decision-Making},
  author={Liu, Yize and Yan, Siyuan and Hu, Ming and Ju, Lie and Li, Xieji and
          Tang, Feilong and Feng, Wei and Ge, Zongyuan},
  journal={arXiv preprint arXiv:2605.14403},
  year={2026}
}

License

This project is licensed under the Apache License 2.0 — see the LICENSE file for the full text.

DermAgent redistributes adapted code from third-party projects under the baselines/ directory. See NOTICE and the per-baseline ATTRIBUTION.md files for upstream sources, citations, and license status.

Contributors

YizeezLiu

6 commits

YizeezLiu/DermAgent

DermAgent: A Self-Reflective Agentic System for Dermatological Image Analysis with Multi-Tool Reasoning and Traceable Decision-Making

10

stars

6

commits

Python

primary language

Jul 12, 2026

updated

README

DermAgent: A Self-Reflective Agentic System for Dermatological Image Analysis with Multi-Tool Reasoning and Traceable Decision-Making

arXiv License: Apache 2.0 Python 3.10+

A self-reflective agentic system for dermatological image analysis, built on LangChain/LangGraph.

DermAgent orchestrates seven specialist vision and language tools (PanDerm, MAKE, DermoGPT, Qwen3-VL, Case RAG, Guideline RAG, Ontology) within a Plan-Execute-Reflect framework, using GPT-4o as the reasoning backbone. A deterministic Critic module performs post-hoc auditing via confidence, coverage, and conflict gates to trigger targeted self-correction, delivering stepwise, traceable diagnostic reasoning.

Architecture

DermAgent Architecture

Project Structure

DermAgent/
├── .agents/skills/              # Repo-level Codex skills
│   └── mayo-dermnet-corpus-pipeline/ # Guideline corpus reproduction contract
├── skin_agent/                  # Core agent framework
│   ├── benchmark_agent.py       # Benchmark agent + Critic + AnswerParser
│   ├── configs.py               # Dataset task configurations
│   ├── tracing.py               # TraceLogger, TracingCallback
│   ├── profiler.py              # Performance profiling
│   ├── resume.py                # Checkpoint/resume for long runs
│   ├── prompts.md               # System prompts
│   ├── tools/
│   │   ├── base.py              # BaseSkinTool, input schemas
│   │   ├── skin_tools.py        # All 7 tool implementations
│   │   ├── executor.py          # Tool execution orchestration
│   │   └── derm_knowledge_tree/ # Disease ontology JSONs
│   └── utils/
│       ├── retry.py             # Rate-limit retry logic
│       └── image_utils.py       # Image path handling
├── benchmark/                   # Unified evaluation framework
│   ├── run.py                   # CLI runner for single-model baselines
│   ├── metrics.py               # Shared metrics (classification, multilabel, captioning, VQA)
│   ├── models/                  # Model wrappers (GPT-4o, LLaVA-Med, HuatuoGPT, etc.)
│   └── datasets/                # Dataset configs with prompts and class lists
├── scripts/                     # All runnable scripts
│   ├── build_qdrant_db.py       # Build image RAG vector database
│   ├── build_qdrant_rag.py      # Build text RAG (guidelines)
│   ├── run_task1_ham10000_500_agent_dermogpt_full_critic.sh
│   ├── run_task1_snu_500_critic.sh
│   ├── run_task2_task3_agent_critic.sh
│   ├── run_task3_loo_ablation.sh
│   └── *.py                     # Python runner scripts
├── baselines/                   # Agent-based baseline reproductions
│   ├── MDAgents/                # MDAgents agent baseline (NeurIPS 2024)
│   ├── MedAgent-Pro/            # MedAgent-Pro agent baseline
│   └── SkinVL/                  # SkinVL-PubMM baseline
├── data/                        # Benchmark CSV metadata
├── requirements.txt
└── .env.example

Setup

1. Environment

conda create -n dermagent python=3.10
conda activate dermagent

# Install PyTorch (match your CUDA version)
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu126

pip install -r requirements.txt

# Download NLTK data (needed for BLEU/ROUGE metrics)
python -c "import nltk; nltk.download('punkt'); nltk.download('punkt_tab')"

2. API Keys

cp .env.example .env
# Edit .env: set OPENAI_API_KEY (required) and other variables as needed

3. External Dependencies

The following external code/data directories are required but not included in this repository due to size or licensing. Place them at the project root:

DirectoryPurposeHow to Obtain
Derm1M/src/Custom OpenCLIP fork for PanDerm & RAG encodersClone from the Derm1M repository
MAKE/src/Custom OpenCLIP fork for MAKE concept annotationClone from the MAKE repository
MAKE/concept_annotation/term_lists/ConceptTerms.jsonConcept term definitions for MAKEIncluded in the MAKE repository above
model-weights/DermoGPT-RLDermoGPT-RL fine-tuned model weightsDownload from the DermoGPT repository
MM-Skin/LLaVA package used by the SkinVL-PubMM baselineClone from the MM-Skin repository
model-weights/SkinVL-PubMMSkinVL-PubMM model weights for the baselineDownload from HuggingFace zwq803/SkinVL-PubMM
RAG/dermnet_chunks_cleaned.jsonDermNet guideline chunks for Text RAGFollow the corpus pipeline skill
RAG/mayo_chunks_cleaned.jsonMayo Clinic guideline chunks for Text RAGFollow the corpus pipeline skill
datasets/Derm1M/Derm1M dataset for building image RAG indexDownload from Derm1M

For Text RAG models, pre-download the embedding and reranker models into model-weights/:

# Pre-download Qwen3 Embedding and Reranker for Text RAG
huggingface-cli download Qwen/Qwen3-Embedding-8B --local-dir model-weights/Qwen3-Embedding-8B
huggingface-cli download Qwen/Qwen3-Reranker-0.6B --local-dir model-weights/Qwen3-Reranker-0.6B

4. Datasets

Download the following datasets and place images in the expected directories:

DatasetTaskDownloadImage Directory
HAM10000Diagnosis (7 classes, 642 imgs)ISIC Archivedatasets/ham10000/images/
SNUDiagnosis (134 classes, 500 imgs)SNU Quizdatasets/SNU/images/
Derm7ptConcept Annotation (7 concepts)Derm7ptdatasets/derm7pt/final_images/
SkinConConcept Annotation (32 concepts)SkinCondatasets/skincon/final_images/
SkinCAPCaptioning (100 imgs)SkinCAPdatasets/skin_cap/images/

Benchmark CSV metadata (split definitions) are included in data/.

5. RAG Vector Database

To reproduce the Mayo Clinic and DermNet source corpora without redistributing scraper code or article content, follow the repo-level Mayo + DermNet corpus pipeline skill. It documents the Python environment, final pipeline, and JSON contract expected by scripts/build_qdrant_rag.py.

Install and start Qdrant (vector database server):

# Option A: Docker (recommended)
docker run -d -p 6333:6333 -v $(pwd)/qdrant_storage:/qdrant/storage qdrant/qdrant

# Option B: Local binary — see https://qdrant.tech/documentation/guides/installation/

Build the Qdrant vector databases:

# Image-based case retrieval (requires Derm1M dataset + Derm1M/src/)
python scripts/build_qdrant_db.py

# Guideline-grounded text retrieval (requires RAG/ JSON files)
python scripts/build_qdrant_rag.py

6. Model Weights

Most tool models are auto-downloaded from HuggingFace on first use:

Models that must be manually placed in model-weights/:

  • DermoGPT-RL: See Step 3 above (~16GB VRAM, bfloat16)
  • Qwen3-Embedding-8B / Qwen3-Reranker-0.6B: See Step 3 above (Text RAG)

Total GPU requirement: ~20-22GB for all tools loaded simultaneously.

Table 1: Main Results

ModelTypeHAM10000 (Acc.)SNU (Acc.)Derm7pt (F1-Macro)SkinCon (F1-Macro)SkinCAP (ROUGE-L)
LLaVA-Med-v1.5Medical MLLM0.44240.01200.51700.13100.1532
HuatuoGPTMedical MLLM0.51400.04000.53430.09490.1432
DermoGPT-RLDermatology MLLM0.50000.09200.56860.20720.1541
SkinVL-PubMMDermatology MLLM0.45170.03400.53140.13200.1444
Qwen3-VL-8BGeneral MLLM0.51090.07800.53700.22820.1247
GPT-4oGeneral MLLM0.48910.15000.54140.29560.1633
GPT-5.2General MLLM0.35980.14800.53860.26620.1235
MDAgentsMedical Agent0.16820.11400.36140.23930.1199
MedAgent-ProMedical Agent0.57630.11600.64820.18340.1148
DermAgent (Ours)Medical Agent0.61830.32600.65060.32950.1948

Commands to reproduce DermAgent results:

# HAM10000 Diagnosis
bash scripts/run_task1_ham10000_500_agent_dermogpt_full_critic.sh

# SNU Diagnosis
bash scripts/run_task1_snu_500_critic.sh

# Derm7pt + SkinCon + SkinCAP
bash scripts/run_task2_task3_agent_critic.sh

Commands to reproduce baseline results (see baselines/README.md for agent baselines):

# Single-model MLLM baselines (e.g., GPT-4o on HAM10000)
cd benchmark && python run.py --model gpt4o --dataset HAM10000_500

# MDAgents agent baseline
cd baselines/MDAgents && python run_derm_benchmark.py --dataset HAM10000 --difficulty basic --model gpt-4o

# MedAgent-Pro agent baseline
cd baselines/MedAgent-Pro && python Derm_Case_level.py --task 1 \
    --csv-path ../../datasets/ham10000/HAM10000_benchmark_500.csv \
    --image-dir ../../datasets/ham10000 --max-samples 500

Table 2: Ablation Study (Leave-One-Out on SkinCAP)

ConfigurationROUGE-LDelta (%)
Full Agent (w/ Critic)0.1948+12.8
Full Agent (w/o Critic)0.1727---
  w/o Case RAG0.1580-8.5
  w/o Guideline RAG0.1628-5.7
  w/o DermoGPT0.1672-3.2
  w/o PanDerm0.1676-3.0
  w/o MAKE0.1679-2.8
  w/o Ontology0.1712-0.9

Command to reproduce ablation results:

# Runs 6 leave-one-out experiments sequentially (removes one tool at a time)
bash scripts/run_task3_loo_ablation.sh

The full agent result (w/ Critic, ROUGE-L: 0.1948) is produced by the Task 3 portion of run_task2_task3_agent_critic.sh. The "w/o Critic" baseline (0.1727) is produced by the LOO script's full-tool run without the Critic module.

Tool Descriptions

ToolModelPurpose
PanDerm ClassifierDermLIPZero-shot disease classification via CLIP similarity
MAKE AnnotatorMAKE (OpenCLIP)Dermoscopic concept extraction
DermoGPT VQADermoGPT-RLDermatology-specialized visual QA
Qwen3-VL VQAQwen3-VL-8BGeneral visual question answering
Image RAGDermLIP + QdrantCase retrieval from 413,210 diagnosed cases
Text RAGQwen3-Embedding + QdrantGuideline retrieval from 3,199 document chunks
OntologyKnowledge GraphDisease hierarchy and taxonomy queries

Citation

Paper: arXiv:2605.14403 (MICCAI 2026, early accept).

@article{liu2026dermagent,
  title={DermAgent: A Self-Reflective Agentic System for Dermatological Image
         Analysis with Multi-Tool Reasoning and Traceable Decision-Making},
  author={Liu, Yize and Yan, Siyuan and Hu, Ming and Ju, Lie and Li, Xieji and
          Tang, Feilong and Feng, Wei and Ge, Zongyuan},
  journal={arXiv preprint arXiv:2605.14403},
  year={2026}
}

License

This project is licensed under the Apache License 2.0 — see the LICENSE file for the full text.

DermAgent redistributes adapted code from third-party projects under the baselines/ directory. See NOTICE and the per-baseline ATTRIBUTION.md files for upstream sources, citations, and license status.

Contributors

YizeezLiu

6 commits

Languages

Python

95.9%

Shell

4.1%