Command-line reference#
medvision_bm ships almost no importable Python API — the top-level package
exposes only __version__. Everything you actually run is an argparse entry
point invoked as a module:
python -m medvision_bm.<subpackage>.<module> [flags]
This page is the exhaustive flag reference for every user-facing command,
grouped by workflow stage. Defaults shown are the argparse defaults baked into
the source; a blank default means the flag is optional with no default (usually
None) or is required.
Note
Several commands read configuration from environment variables
(MedVision_DATA_DIR, MedVision_PLANNER_VERSION, MedVision_ACK_RELEASE,
HF_TOKEN, and friends). Those are documented on the
Installation page, not repeated here.
Conventions used below:
Boolean flags marked store_true are switches — pass the flag with no value.
Flags typed str2bool (SFT only) take an explicit truthy/falsy value, e.g.
--process_img true.Where a command accepts
-p, it is the short alias for--processes.
Benchmarking (evaluation entry points)#
Every model has its own eval__<model> driver under
medvision_bm.benchmark, but they share one loop: set up the environment,
read a task list, and for each task shell out to the vendored lmms_eval
runner, writing per-sample JSONL into <results_dir>/<model_name>/. Completed
tasks are recorded in the status JSON so a re-run resumes where it stopped.
The flag surface splits into two shapes — a vLLM / local-weights shape
(represented by eval__qwen2_5_vl) and an API shape (represented by
eval__openai and eval__claude). Both are documented in full below; the
remaining drivers reuse one of these shapes plus a few model-specific extras.
eval__qwen2_5_vl (representative vLLM driver)#
Run local-weight vision-language models through vLLM.
python -m medvision_bm.benchmark.eval__qwen2_5_vl \
--model_name Qwen2.5-VL-7B-Instruct \
--model_hf_id Qwen/Qwen2.5-VL-7B-Instruct \
--tasks_list_json_path tasks_list/TL.json \
--data_dir "$MedVision_DATA_DIR" \
--results_dir Results/TL \
--task_status_json_path completed_tasks/TL_qwen25vl.json
Flag |
Default |
Description |
|---|---|---|
|
|
Name of the |
|
|
Hugging Face model ID of the base weights. |
|
Hugging Face path to a LoRA adapter; leave unset for full weights. |
|
|
|
Display name; becomes the results subfolder and status-file key. |
|
|
Weight dtype passed to vLLM ( |
|
Force-resize every image to |
|
|
|
Max tokens generated per sample. |
|
One or more stop sequences (e.g. |
|
|
|
Per-GPU batch size; multiplied by the detected GPU count for the effective batch. |
|
|
vLLM GPU memory fraction. |
|
Path to the task-list JSON to evaluate. |
|
|
Root directory for per-sample outputs. |
|
|
Path to the resumable completed-tasks JSON. |
|
|
MedVision data directory. |
|
|
|
Max samples evaluated per task. |
|
Evaluate a subset by index; accepts |
|
|
off |
store_true — also record the system prompt in each JSONL row. |
|
off |
store_true — skip package/env installation (debug only). |
|
off |
store_true — do not mark tasks complete (debug only). |
|
off |
store_true — install the environment and exit without evaluating. |
|
|
Lower bound of the pixel-size scaling range for |
|
|
Upper bound of the pixel-size scaling range for |
eval__openai (OpenAI / OpenRouter API driver)#
Evaluate hosted OpenAI models directly or via OpenRouter.
export OPENAI_API_KEY=sk-...
python -m medvision_bm.benchmark.eval__openai \
--openai_model_code gpt-5.5 \
--model_name gpt-5.5 \
--tasks_list_json_path tasks_list/Detection.json \
--data_dir "$MedVision_DATA_DIR" \
--results_dir Results/Detection \
--task_status_json_path completed_tasks/Detection_openai.json
Flag |
Default |
Description |
|---|---|---|
|
required |
Provider model ID (e.g. |
|
|
Provider: |
|
required |
Display name; results subfolder and status-file key. |
|
Reasoning effort for reasoning models ( |
|
|
|
Default max output tokens; a per-task |
|
Force-resize every image to |
|
|
|
Requests batched together. |
|
required |
Path to the task-list JSON. |
|
required |
Root directory for per-sample outputs. |
|
required |
Path to the resumable completed-tasks JSON. |
|
required |
MedVision data directory. |
|
|
Max samples per task. |
|
Index subset selector ( |
|
|
off |
store_true — record the system prompt in each JSONL row. |
|
Stop sequences. Note: OpenAI reasoning models (gpt-5.x / o-series) may reject the |
|
|
off |
store_true — skip environment setup (debug only). |
|
off |
store_true — do not mark tasks complete (debug only). |
|
off |
store_true — install the environment and exit. |
|
|
Lower bound of the |
|
|
Upper bound of the |
eval__claude (Anthropic / OpenRouter API driver)#
Same shape as eval__openai, with Claude-specific thinking control instead of
reasoning effort.
export ANTHROPIC_API_KEY=sk-ant-...
python -m medvision_bm.benchmark.eval__claude \
--anthropic_model_code claude-fable-5 \
--model_name claude-fable-5 \
--tasks_list_json_path tasks_list/AD.json \
--data_dir "$MedVision_DATA_DIR" \
--results_dir Results/AD \
--task_status_json_path completed_tasks/AD_claude.json
Flag |
Default |
Description |
|---|---|---|
|
required |
Provider model ID (e.g. |
|
|
Provider: |
|
required |
Display name; results subfolder and status-file key. |
|
on |
Toggle adaptive thinking. |
|
|
Default max output tokens; a per-task |
|
Force-resize every image to |
|
|
|
Requests batched together. |
|
required |
Path to the task-list JSON. |
|
required |
Root directory for outputs. |
|
required |
Path to the completed-tasks JSON. |
|
required |
MedVision data directory. |
|
|
Max samples per task. |
|
Index subset selector; overrides |
|
|
off |
store_true — record the system prompt in each JSONL row. |
|
Stop sequences. |
|
|
off |
store_true — skip environment setup (debug only). |
|
off |
store_true — do not mark tasks complete (debug only). |
|
off |
store_true — install the environment and exit. |
|
|
Lower bound of the |
|
|
Upper bound of the |
Other evaluation drivers#
The following modules follow the same command shape — the vLLM shape for
local-weight models, the API shape for hosted ones — with model-specific extras
(different --lmmseval_module default, tailored install pins, or provider
options). Consult --help on the specific driver for its exact surface.
vLLM / local-weight drivers:
eval__qwen3_vl eval__gemma3 eval__gemma4
eval__glm4v eval__healthgpt eval__huatuogpt_vision
eval__intern_vl3 eval__kimi eval__lingshu
eval__llama3_2_vision eval__llava_med eval__llava_onevision
eval__meddr eval__medgemma eval__minimax_m3
eval__medvision-model-rft
API drivers:
eval__openai eval__claude eval__gemini
Tip
eval__gemini extends the API shape with Google-specific controls —
--google_model_code, --media_resolution, --thinking_level,
--thinkingBudget, --use_tool, and --json_output — on top of the common
flags shown above.
See Running evaluations for the
end-to-end workflow and the script/benchmark-*/eval__*.sh launchers that wrap
these drivers.
Dataset & environment#
download_datasets#
Fetch MedVision datasets named either by a configuration CSV or by a task-list
JSON. Exactly one of --configs_csv / --tasks_json is required.
python -m medvision_bm.benchmark.download_datasets \
--data_dir "$MedVision_DATA_DIR" \
--tasks_json tasks_list/TL.json --split test
Flag |
Default |
Description |
|---|---|---|
|
required |
Directory where datasets and dataset code are stored. |
|
off |
store_true — re-download even if the data is already present. |
|
CSV whose first column lists dataset configurations to fetch. |
|
|
Task-list JSON whose keys name the datasets to fetch. |
|
|
|
Split to download: |
env_setup#
Provision a full evaluation environment: vendored lmms_eval, the dataset
package, the CUDA toolkit, vLLM, and any extra requirements file.
python -m medvision_bm.benchmark.env_setup \
-r requirements.txt --data_dir "$MedVision_DATA_DIR" \
--cuda_version 12.4 --vllm_version 0.10.0
Flag |
Default |
Description |
|---|---|---|
|
required |
Path to a |
|
required |
Directory for datasets and dataset code. |
|
Optional-dependency group to install with |
|
|
|
CUDA toolkit version to install. |
|
|
vLLM version to install. |
install_medvision_ds#
Install only the MedVision dataset package (medvision_ds) into the current
environment.
python -m medvision_bm.benchmark.install_medvision_ds --data_dir "$MedVision_DATA_DIR"
Flag |
Default |
Description |
|---|---|---|
|
required |
Directory for datasets and dataset code (created if missing). |
install_vendored_lmms_eval#
Install only the vendored lmms_eval package, optionally with an extras group.
python -m medvision_bm.benchmark.install_vendored_lmms_eval --lmms_eval_opt_deps qwen2_5_vl
Flag |
Default |
Description |
|---|---|---|
|
Optional-dependency group to install alongside |
Parsing & summarizing#
These run after evaluation, on the JSONL files under a results directory. Step 2
(parse_outputs) extracts predictions and computes per-sample metrics; step 3
(summarize_*) aggregates them into per-model, per-anatomy summaries. Point
each command at a --task_dir (all model subfolders) or a single --model_dir.
parse_outputs#
Extract predictions from raw JSONL and write parsed files plus updated
per-file summaries. Requires --task_type and one of --task_dir / --model_dir.
python -m medvision_bm.benchmark.parse_outputs \
--task_type TL --task_dir Results/TL -p 16
Flag |
Default |
Description |
|---|---|---|
|
required |
Task family: |
|
Task directory whose model subfolders are all processed. |
|
|
Single model directory to process. |
|
|
Cap on samples processed per JSONL file. |
|
|
off |
store_true — skip files that already have parsed output. |
|
|
Worker processes; |
|
off |
store_true — delete the existing |
summarize_AD_task#
Aggregate Angle/Distance metrics (MAE, MRE, nMAE, SuccessRate) per model, grouped by anatomy (FeTA-Distance, Ceph-Angle, Ceph-Distance).
python -m medvision_bm.benchmark.summarize_AD_task --task_dir Results/AD -p 16
Flag |
Default |
Description |
|---|---|---|
|
Task directory containing model result folders. |
|
|
Single model directory to summarize. |
|
|
|
Cap on samples per JSONL file; unset processes all. |
|
off |
store_true — skip models with no |
|
|
Worker processes for metric calculation. |
Note
summarize_* requires either --task_dir or --model_dir, and
--skip_model_wo_parsed_files may only be combined with --task_dir.
summarize_TL_task#
Aggregate Tumour/Lesion-size metrics (MAE, MRE, nMAE, SuccessRate, in mm). Shares the AD flags and adds removed-sample filtering.
python -m medvision_bm.benchmark.summarize_TL_task --task_dir Results/TL -p 16
Flag |
Default |
Description |
|---|---|---|
|
Task directory containing model result folders. |
|
|
Single model directory to summarize. |
|
|
|
Cap on samples per JSONL file; unset processes all. |
|
off |
store_true — skip models without a |
|
|
Worker processes for metric calculation. |
|
|
Root of per-dataset removed-samples JSONs (e.g. |
|
|
Filename of the removed-samples JSON inside each dataset subdirectory. |
summarize_detection_task#
Aggregate Detection metrics (IoU, Precision, Recall, F1, SuccessRate) per model, grouped by anatomy.
python -m medvision_bm.benchmark.summarize_detection_task --task_dir Results/Detection -p 16
Flag |
Default |
Description |
|---|---|---|
|
Task directory containing model result folders. |
|
|
Single model directory to summarize. |
|
|
|
Cap on samples per JSONL file; unset processes all. |
|
off |
store_true — skip models without a |
|
|
Worker processes. |
See Parsing and summarizing for how these fit together and where the output files land.
Fine-tuning (SFT)#
Supervised fine-tuning drivers live under medvision_bm.sft as
train__<variant>__<family> modules (e.g. train__SFT-CoT__qwen2_5_vl,
train__fullFT-CoT__qwen2_5_vl). They all parse the same argument surface
(parse_validate_args_multiTask), so the flags below apply to every driver.
python -m medvision_bm.sft.train__SFT-CoT__qwen2_5_vl \
--model_family_name qwen2_5_vl \
--base_model_hf Qwen/Qwen2.5-VL-7B-Instruct \
--data_dir "$MedVision_DATA_DIR" \
--tasks_list_json_path_TL tasks_list/TL.json \
--run_name my-sft-run
At least one of --tasks_list_json_path_AD, --tasks_list_json_path_detect, or
--tasks_list_json_path_TL must be provided.
Model & run identity
Flag |
Default |
Description |
|---|---|---|
|
Human-readable name for the run. |
|
|
required |
Family key selecting the shared image processor / collate logic; validated against supported models. |
|
required |
Hugging Face ID of the base model. |
|
Local path for the LoRA checkpoint. |
|
|
Hugging Face repo ID for the merged model. |
|
|
Local path for the merged model. |
Weights & Biases logging
Flag |
Default |
Description |
|---|---|---|
|
|
Resume mode ( |
|
Directory for wandb logs. |
|
|
Project name. |
|
|
Run name. |
|
|
Run ID for resuming. |
Data & preprocessing
Flag |
Default |
Description |
|---|---|---|
|
required |
Dataset folder. |
|
Task-list JSON for the Angle/Distance task. |
|
|
Task-list JSON for the Detection task. |
|
|
Task-list JSON for the Tumour/Lesion-size task. |
|
|
|
Process images during dataset formatting. |
|
|
Prepare the dataset and exit without training. |
|
|
Skip formatting and load a prepared dataset from disk. |
|
Path to a prepared dataset to load from disk. |
|
|
|
Save processed images as PNGs during formatting. |
|
Resize target as two ints |
|
|
|
|
Training loop
Flag |
Default |
Description |
|---|---|---|
|
|
Number of training epochs. |
|
|
Steps between checkpoints. |
|
|
Steps between evaluations. |
|
|
Steps between log lines. |
|
|
Max checkpoints kept. |
|
|
Train batch size per device. |
|
|
Eval batch size per device. |
|
|
Accumulation steps before an update. |
|
|
Enable FlashAttention-2. |
|
|
Trade compute for memory via checkpointing. |
|
|
Pin host memory for faster transfer. |
|
|
Resume from the latest checkpoint. |
Dataloader workers
Flag |
Default |
Description |
|---|---|---|
|
|
Workers for concatenating per-task datasets (≤ number of tasks). |
|
|
Workers for dataset formatting. |
|
|
Workers for data loading. |
Sample limits
Flag |
Default |
Description |
|---|---|---|
|
|
Per-task train cap; |
|
|
Per-task validation cap. |
|
|
Train cap for the AD task. |
|
|
Validation cap for the AD task. |
|
|
Train cap for the Detection task. |
|
|
Validation cap for the Detection task. |
|
|
Train cap for the TL task. |
|
|
Validation cap for the TL task. |
|
|
Total train cap across tasks; |
|
|
Total validation cap across tasks. |
LoRA / merge control
Flag |
Default |
Description |
|---|---|---|
|
|
Push the LoRA checkpoint to the Hub after each save. |
|
|
Push the merged model to the Hub after merging. |
|
|
Merge LoRA into the base model after training. |
|
|
Merge and push only — no training. |
Temperature sampler (multi-task)
Flag |
Default |
Description |
|---|---|---|
|
|
Use temperature-weighted random sampling across tasks. |
|
|
Temperature |
|
|
Prepared-dataset column holding task labels. |
|
|
Samples drawn per epoch; |
See Supervised fine-tuning for the full workflow.
RFT (reinforcement fine-tuning)#
build_parquet_ds#
Build the train/validation Parquet dataset consumed by the
verl trainer. Output is
written under <data_dir>/verl_datasets/<model_family_name>/….
python -m medvision_bm.rft.verl.build_parquet_ds \
--model_family_name qwen2_5_vl \
--model_hf Qwen/Qwen2.5-VL-7B-Instruct \
--data_dir "$MedVision_DATA_DIR" \
--tasks_list_json_path_TL tasks_list/TL.json
Flag |
Default |
Description |
|---|---|---|
|
required |
Family key identifying the shared image processor. |
|
required |
Hugging Face ID whose image processor drives preprocessing. |
|
required |
Dataset folder (also the Parquet output root). |
|
Path to a prepared dataset to load from disk. |
|
|
|
|
|
Resize target as two ints |
|
|
off |
store_true — omit CoT instructions from prompts (deprecated; kept for parity with SFT-CoT). |
|
Task-list JSON for the Angle/Distance task. |
|
|
Task-list JSON for the Detection task. |
|
|
Task-list JSON for the Tumour/Lesion-size task. |
|
|
|
Workers for concatenating per-task datasets. |
|
|
Workers for dataset formatting. |
|
|
Workers for data loading. |
|
|
Per-task train cap; |
|
|
Per-task validation cap. |
|
|
Train cap for the AD task. |
|
|
Validation cap for the AD task. |
|
|
Train cap for the Detection task. |
|
|
Validation cap for the Detection task. |
|
|
Train cap for the TL task. |
|
|
Validation cap for the TL task. |
|
|
Total train cap; |
|
|
Total validation cap; |
See Reinforcement fine-tuning for how the Parquet dataset feeds the trainer.
Utilities#
Both utilities turn a configuration CSV (ConfigurationsList_*.csv) into a JSON
artifact, sharing an identical filter/flag surface. Streaming the dataset is the
default; --no-count skips loading entirely for a fast naming-only pass.
configs_to_tasks#
Emit a task-list JSON (task name → sample count) from a config CSV.
python -m medvision_bm.utils.configs_to_tasks \
--data_dir "$MedVision_DATA_DIR" \
--configs_csv ConfigurationsList_TL.csv \
--out tasks_list/TL.json
Flag |
Default |
Description |
|---|---|---|
|
required |
MedVision data/code directory. |
|
required |
Path to the |
|
required |
Output task-list JSON path. |
|
|
Comma-separated task families to include. |
|
|
Comma-separated imaging planes to include. |
|
|
Split to include and count: |
|
off |
store_true — append |
|
Cap the number of configs (for quick tests). |
|
|
off |
store_true — skip dataset loading; write |
|
off |
store_true — count via |
configs_to_pixel_sizes#
Emit per-task raw pixel-size (in-plane spacing) distributions plus an
isotropic/anisotropic rollup, writing a second __summary sibling file.
python -m medvision_bm.utils.configs_to_pixel_sizes \
--data_dir "$MedVision_DATA_DIR" \
--configs_csv ConfigurationsList_TL.csv \
--out pixel_sizes_TL.json
Flag |
Default |
Description |
|---|---|---|
|
required |
MedVision data/code directory. |
|
required |
Path to the |
|
required |
Output pixel-size JSON path ( |
|
|
Comma-separated task families to include. |
|
|
Comma-separated imaging planes to include. |
|
|
Split to include and count: |
|
off |
store_true — append |
|
Cap the number of configs (for quick tests). |
|
|
off |
store_true — skip dataset loading; write empty distributions. |
|
off |
store_true — count via |