Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:OpenGVLab InternVL Segmentation Test

From Leeroopedia


Knowledge Sources
Domains Evaluation, Segmentation, Distributed Systems
Last Updated 2026-02-07 14:00 GMT

Overview

Main evaluation script for testing segmentation models using the MMSegmentation framework, supporting single-GPU, multi-GPU, and multi-scale augmented evaluation.

Description

This script serves as the core evaluation entry point for all InternVL segmentation experiments. The parse_args() function accepts a comprehensive set of CLI arguments including config file path, checkpoint path, evaluation metrics (e.g., "mIoU"), work directory, and augmentation options. It supports distributed launchers (pytorch, slurm, mpi) and handles both -\-options (deprecated) and -\-cfg-options for config overrides.

The main() function builds the evaluation pipeline:

  1. Loads the config and applies any CLI overrides
  2. Optionally enables multi-scale augmentation testing with flip and scale ratios [0.5, 0.75, 1.0, 1.25, 1.5, 1.75]
  3. Builds the dataset and dataloader (samples_per_gpu=1)
  4. Constructs the segmentor model and loads the checkpoint with class/palette metadata
  5. Optionally wraps the model in FP16 for efficient inference
  6. Routes to single_gpu_test (MMDataParallel) or multi_gpu_test (MMDistributedDataParallel)
  7. On rank 0, writes evaluation metrics to a timestamped JSON file

Results can be saved as pickle, visualized with configurable opacity, or formatted for Cityscapes-style evaluation.

Usage

Use this script as the entry point for evaluating trained segmentation models, invoked via dist_test.sh or slurm_test.sh shell scripts.

Code Reference

Source Location

Signature

def parse_args(): ...
def main(): ...

Import

# Standalone script:
# python segmentation/test.py <config> <checkpoint> --eval mIoU

I/O Contract

Inputs

Name Type Required Description
config str Yes Path to the MMSeg config file
checkpoint str Yes Path to the model checkpoint
--eval str No Evaluation metrics (e.g., "mIoU")
--aug-test flag No Enable multi-scale flip augmentation
--launcher str No Distributed launcher: none/pytorch/slurm/mpi
--work-dir str No Directory for saving evaluation results
--show-dir str No Directory for saving visualization results

Outputs

Name Type Description
json_file JSON Evaluation metrics (e.g., mIoU) saved as timestamped JSON
out_file pickle Raw prediction results (optional)
visualizations PNG Painted segmentation maps (optional)

Usage Examples

Basic Usage

# Single-GPU evaluation:
# python segmentation/test.py configs/intern_vit_6b.py checkpoint.pth --eval mIoU

# Distributed evaluation:
# bash dist_test.sh configs/intern_vit_6b.py checkpoint.pth 8 --eval mIoU

# Multi-scale augmented test:
# python segmentation/test.py configs/intern_vit_6b.py checkpoint.pth --eval mIoU --aug-test

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment