Configuration System Overview

This project uses a flexible and powerful configuration system based on Python files, heavily influenced by the MMEngine library. This approach allows for modular, inheritable, and easily modifiable experiment setups.

Basic Usage

All training, testing, and utility scripts are launched via tools/dist.sh and require a configuration file as a primary argument.

# General command structure
bash tools/dist.sh [command] [path/to/your/config.py] [num_gpus]

# Example: Training with a specific config on 8 GPUs
bash tools/dist.sh train seg/configs/clip2sam/clip2sam_coco_rn50x16.py 8

Config File Structure

A typical configuration file defines several key Python dictionaries:

  • model: Specifies the model architecture, including the backbone, neck, heads, and any other components.
  • data_preprocessor: Defines how input data (images, annotations) is normalized, padded, and batched.
  • train_dataloader, val_dataloader, test_dataloader: Define the datasets, data pipelines (augmentations and transformations), and sampler settings for each split.
  • train_cfg, val_cfg, test_cfg: Configure the training loop (e.g., number of epochs) and evaluation behavior.
  • optim_wrapper & param_scheduler: Define the optimizer (e.g., AdamW) and learning rate schedule.

Base Configs and Inheritance

To avoid repetition and promote modularity, configs often inherit from base configurations using _base_.

For example, seg/configs/clip2sam/clip2sam_coco_rn50x16.py might start with:

from mmengine.config import read_base

with read_base():
    from .._base_.default_runtime import *
    from .._base_.datasets.coco_ov_instance_lsj import *
    from .._base_.schedules.schedule_12e import *

This imports and merges predefined settings for the runtime environment, COCO dataset, and a 12-epoch training schedule. The rest of the file then defines or overrides specific parts, such as the model architecture.

This system allows you to easily compose new experiments by mixing and matching different base components.