### Install MMRotate Source: https://mmrotate.readthedocs.io/en/latest/index Instructions for installing MMRotate, including prerequisites and best practices for a smooth setup. It also covers troubleshooting common installation issues. ```bash # Best Practices # Verify the installation # Customize Installation # Trouble shooting ``` -------------------------------- ### Verify MMRotate Installation Source: https://mmrotate.readthedocs.io/en/latest/install A Python snippet to verify the installation of the MMRotate library by printing its version. This is a crucial step after installation to ensure everything is set up correctly. ```python import mmrotate print(mmrotate.__version__) ``` -------------------------------- ### Install MMRotate and Dependencies on Google Colab Source: https://mmrotate.readthedocs.io/en/latest/install Instructions for installing MMCV and MMDetection using MIM on Google Colab, followed by installing MMRotate from source. This is a common setup for cloud-based development environments. ```bash pip install -U openmim mim install mmcv-full mim install mmdet ``` ```bash git clone https://github.com/open-mmlab/mmrotate.git cd mmrotate pip install -e . ``` -------------------------------- ### Verify MMRotate Inference (Source Install) Source: https://mmrotate.readthedocs.io/en/latest/install This command verifies the MMRotate installation by running an inference demo. It assumes the necessary config and checkpoint files have been downloaded. ```bash python demo/inference_demo.py ``` -------------------------------- ### Install MMRotate from Source Source: https://mmrotate.readthedocs.io/en/latest/install This command installs MMRotate from its source code, enabling development and direct code modifications. The '-v' flag provides verbose output, and '-e' installs in editable mode. ```bash cd mmrotate pip install -v -e . ``` -------------------------------- ### Install MMRotate with Pip Source: https://mmrotate.readthedocs.io/en/latest/install This command installs MMRotate as a package using pip. This is the recommended method for using MMRotate as a dependency or third-party package. ```bash pip install mmrotate ``` -------------------------------- ### Verify MMRotate Inference (Pip Install) Source: https://mmrotate.readthedocs.io/en/latest/install This Python code snippet verifies the MMRotate installation by performing inference on a demo image. It initializes the detector with a config and checkpoint, then runs inference. ```python from mmdet.apis import init_detector, inference_detector import mmrotate config_file = 'oriented_rcnn_r50_fpn_1x_dota_le90.py' checkpoint_file = 'oriented_rcnn_r50_fpn_1x_dota_le90-6d2ce0.pth' model = init_detector(config_file, checkpoint_file, device='cuda:0') inference_detector(model, 'demo/demo.jpg') ``` -------------------------------- ### Install PyTorch Source: https://mmrotate.readthedocs.io/en/latest/install This command installs a specific version of PyTorch along with its corresponding torchvision and CUDA toolkit version. Ensure the CUDA version matches your system's requirements. ```bash conda install pytorch==1.8.0 torchvision==0.9.0 cudatoolkit=10.2 -c pytorch ``` -------------------------------- ### Install MMCV and MMDetection Source: https://mmrotate.readthedocs.io/en/latest/install This command installs the MMCV and MMDetection libraries using MIM. The version constraint '<3.0.0' suggests compatibility with older versions of these foundational libraries. ```bash mim install mmcv-full<3.0.0 mmdet ``` -------------------------------- ### Run MMRotate Docker Container Source: https://mmrotate.readthedocs.io/en/latest/install Command to run the MMRotate Docker container, mounting a local data directory into the container. This allows persistent storage and access to data during runtime. ```bash docker run -it --gpus all -v -8g{DATA_DIR}:/mmrotate/data mmrotate:latest ``` -------------------------------- ### Launch Multiple Jobs with Slurm Source: https://mmrotate.readthedocs.io/en/latest/get_started Provides an example of launching two distributed training jobs using Slurm, where each job is configured with specific GPUs and the number of GPUs per process. This assumes the configuration files have been modified to use different ports. ```bash CUDA_VISIBLE_DEVICES=0,1,2,3 GPUS=4 ${PARTITION} ${JOB_NAME} ${WORK_DIR} CUDA_VISIBLE_DEVICES=4,5,6,7 GPUS=4 ${PARTITION} ${JOB_NAME} ${WORK_DIR} ``` -------------------------------- ### Create Conda Environment Source: https://mmrotate.readthedocs.io/en/latest/install This command creates a new conda environment with a specified Python version. It's a crucial first step for setting up a clean development environment. ```bash conda create -n open-mmlab python=3.8 ``` -------------------------------- ### Install MMCV for MMRotate Compatibility Source: https://mmrotate.readthedocs.io/en/latest/faq This section details the compatible versions of MMCV and MMDetection for different MMRotate versions to avoid installation issues. It lists specific version ranges required for a stable setup. ```text MMRotate version | MMCV version | MMDetection version ---|---|--- main | mmcv-full>=1.5.3, <1.8.0 | mmdet >= 2.25.1, <3.0.0 0.3.4 | mmcv-full>=1.5.3, <1.8.0 | mmdet >= 2.25.1, <3.0.0 0.3.3 | mmcv-full>=1.5.3, <1.7.0 | mmdet >= 2.25.1, <3.0.0 0.3.2 | mmcv-full>=1.5.3, <1.7.0 | mmdet >= 2.25.1, <3.0.0 0.3.1 | mmcv-full>=1.4.5, <1.6.0 | mmdet >= 2.22.0, <3.0.0 0.3.0 | mmcv-full>=1.4.5, <1.6.0 | mmdet >= 2.22.0, <3.0.0 0.2.0 | mmcv-full>=1.4.5, <1.5.0 | mmdet >= 2.19.0, <3.0.0 0.1.1 | mmcv-full>=1.4.5, <1.5.0 | mmdet >= 2.19.0, <3.0.0 0.1.0 | mmcv-full>=1.4.5, <1.5.0 | mmdet >= 2.19.0, <3.0.0 ``` -------------------------------- ### Build Docker Image for MMRotate Source: https://mmrotate.readthedocs.io/en/latest/install This section provides instructions on building a Docker image for MMRotate, specifying the versions of PyTorch and CUDA to be included in the image. It assumes Docker version >=19.03. ```docker # build an image with PyTorch 1.6, CUDA 10.1 # If you prefer other versions, just modified the Dockerfile docker build -t mmrotate . ``` -------------------------------- ### Loading Pre-trained Model Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_config Specifies the path to load a pre-trained model from. If set to 'None', no pre-trained model is loaded, and training starts from scratch. This parameter does not resume training. ```Python load_from = None # load models as a pre-trained model from a given path. This will not resume training. ``` -------------------------------- ### Install MMCV without MIM Source: https://mmrotate.readthedocs.io/en/latest/install This section details how to install MMCV using pip, which requires manually specifying a find-url based on PyTorch and CUDA versions. It's an alternative to using MIM for dependency management. ```bash pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu102/torch1.9.0/index.html ``` -------------------------------- ### Train a Model with MMRotate Source: https://mmrotate.readthedocs.io/en/latest/index Guides on training rotated object detection models using MMRotate. It details training with single or multiple GPUs, managing jobs with Slurm, and launching multiple jobs on a single machine. ```bash # Train with a single GPU # Train with multiple GPUs # Train with multiple machines # Manage jobs with Slurm # Launch multiple jobs on a single machine ``` -------------------------------- ### Define Custom Optimizer (MyOptimizer) Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_runtime Provides an example of defining a new custom optimizer named 'MyOptimizer' in a Python file. It shows how to inherit from PyTorch's Optimizer and use the OPTIMIZERS.register_module() decorator for registration. ```Python from mmdet.core.optimizer.registry import OPTIMIZERS from torch.optim import Optimizer @OPTIMIZERS.register_module() class MyOptimizer(Optimizer): def __init__(self, a, b, c) ``` -------------------------------- ### Implement and Register Custom Hooks in MMRotate Source: https://mmrotate.readthedocs.io/en/latest/tutorials/index This guide explains how to implement a new hook, register it with the MMRotate framework, and then modify the configuration file to utilize the custom hook during training. ```Python 1. Implement a new hook 2. Register the new hook 3. Modify the config ``` -------------------------------- ### Model Serving with MMRotate Source: https://mmrotate.readthedocs.io/en/latest/index Steps for serving trained MMRotate models, including converting models to TorchServe, building Docker images, running the service, and testing deployment. ```bash # 1. Convert model from MMRotate to TorchServe # 2. Build `mmrotate-serve` docker image # 3. Run `mmrotate-serve` # 4. Test deployment ``` -------------------------------- ### Train a model with MMRotate (Single GPU) Source: https://mmrotate.readthedocs.io/en/latest/get_started Command to train a model with MMRotate on a single GPU. Requires a configuration file and optionally allows specifying a working directory. ```Shell ${CONFIG_FILE}[optional] ``` -------------------------------- ### Inspect MMRotate Config Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_config This command allows you to view the complete configuration of a specified config file. It's useful for understanding the structure and parameters of your experiments. ```python python tools/misc/print_config.py /PATH/TO/CONFIG ``` -------------------------------- ### Define Training Data Pipeline Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_config Outlines the sequence of data augmentation and processing steps for the training pipeline, including loading images and annotations, resizing, flipping, normalization, padding, and formatting. ```python train_pipeline = [ dict(type='LoadImageFromFile'), dict(type='LoadAnnotations', with_bbox=True), dict(type='RResize', img_scale=(1024, 1024)), dict(type='RRandomFlip', flip_ratio=0.5, version='oc'), dict( type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict(type='Pad', size_divisor=32), dict(type='DefaultFormatBundle'), dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']) ] ``` -------------------------------- ### Launch Multiple Jobs with dist_train.sh Source: https://mmrotate.readthedocs.io/en/latest/get_started Demonstrates how to launch two distributed training jobs on a single machine using the `dist_train.sh` script. Each job is assigned different GPUs and communication ports to avoid conflicts. ```bash CUDA_VISIBLE_DEVICES=0,1,2,3 PORT=29500 ${CONFIG_FILE} 4 CUDA_VISIBLE_DEVICES=4,5,6,7 PORT=29501 ${CONFIG_FILE} 4 ``` -------------------------------- ### Check MMCV Installation Source: https://mmrotate.readthedocs.io/en/latest/faq Confirms that the MMCV library is installed correctly and its operations can be imported. This helps in troubleshooting 'Segmentation fault' errors when both PyTorch and MMCV are suspected. ```Python import mmcv; import mmcv.ops ``` -------------------------------- ### Train a model with MMRotate (Multiple GPUs) Source: https://mmrotate.readthedocs.io/en/latest/get_started Command to train a model with MMRotate using multiple GPUs. Requires a configuration file and the number of GPUs. Optional arguments include `--no-validate`, `--work-dir`, and `--resume-from`. ```Shell ${CONFIG_FILE}${GPU_NUM}[optional] ``` -------------------------------- ### Install MMCV for Volta GPUs Source: https://mmrotate.readthedocs.io/en/latest/faq Installs the MMCV library with full support for Volta GPUs by setting the TORCH_CUDA_ARCH_LIST environment variable. This is a solution for 'invalid device function' or 'no kernel image is available' errors when using specific GPU architectures. ```Shell TORCH_CUDA_ARCH_LIST=7.0 pip install mmcv-full ``` -------------------------------- ### Dataset Configuration for DOTADataset Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_config Configures the DOTADataset for training and testing. It specifies image paths, annotation files, and a data processing pipeline including image loading, multi-scale flipping augmentation, normalization, padding, and format bundling. The 'version' parameter is set to 'oc'. ```Python dict( type='DOTADataset', ann_file`=[ '../datasets/split_1024_dota1_0/train/images/', '../datasets/split_1024_dota1_0/val/images/' ], img_prefix`=[ '../datasets/split_1024_dota1_0/train/images/', '../datasets/split_1024_dota1_0/val/images/' ], pipeline=[ dict(type='LoadImageFromFile'), dict( type='MultiScaleFlipAug', img_scale=(1024, 1024), flip=False, transforms=[ dict(type='RResize'), dict( type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict(type='Pad', size_divisor=32), dict(type='DefaultFormatBundle'), dict(type='Collect', keys=['img']) ]) ], version='oc'), test=dict( # Test dataset config, modify the ann_file for test-dev/test submission type='DOTADataset', ann_file`= '../datasets/split_1024_dota1_0/test/images/', img_prefix`= '../datasets/split_1024_dota1_0/test/images/', pipeline=[ dict(type='LoadImageFromFile'), dict( type='MultiScaleFlipAug', img_scale=(1024, 1024), flip=False, transforms=[ dict(type='RResize'), dict( type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict(type='Pad', size_divisor=32), dict(type='DefaultFormatBundle'), dict(type='Collect', keys=['img']) ]) ], version='oc')) ``` -------------------------------- ### Use NumClassCheckHook in MMRotate Source: https://mmrotate.readthedocs.io/en/latest/tutorials/index This example shows how to use the pre-implemented `NumClassCheckHook` from MMCV within the MMRotate framework to check class numbers during training. ```Python 4. Example: `NumClassCheckHook` ``` -------------------------------- ### Manage MMRotate jobs with Slurm Source: https://mmrotate.readthedocs.io/en/latest/get_started Script to manage MMRotate training jobs on a cluster using Slurm. Supports single machine training and requires specifying GPU count, partition, job name, config file, and working directory. ```Shell [GPUS=${GPUS}]${PARTITION}${JOB_NAME}${CONFIG_FILE}${WORK_DIR} ``` -------------------------------- ### Configure Training Dataset Parameters Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_config Sets batch size per GPU, number of workers per GPU, and specifies the training dataset configuration including type, annotation file path, image prefix, and the training pipeline. ```python data = dict( samples_per_gpu=2, workers_per_gpu=2, train=dict( type='DOTADataset', ann_file', '../datasets/split_1024_dota1_0/trainval/annfiles/', img_prefix'= '../datasets/split_1024_dota1_0/trainval/images/', pipeline=[ dict(type='LoadImageFromFile'), dict(type='LoadAnnotations', with_bbox=True), dict(type='RResize', img_scale=(1024, 1024)), dict(type='RRandomFlip', flip_ratio=0.5, version='oc'), dict( type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict(type='Pad', size_divisor=32), dict(type='DefaultFormatBundle'), dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']) ], version='oc')) ``` -------------------------------- ### Add New Neck to MMRotate Source: https://mmrotate.readthedocs.io/en/latest/tutorials/index This guide explains how to add a new neck component, like PAFPN, to MMRotate by defining the neck, importing its module, and updating the configuration file accordingly. ```Python 1. Define a neck (e.g. PAFPN) 2. Import the module 3. Modify the config file ``` -------------------------------- ### Concatenate Repeated Datasets Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_dataset A complex example demonstrating the concatenation of datasets that have been repeated multiple times using `RepeatDataset`. This configuration allows for flexible data augmentation and sampling strategies. ```python dataset_A_train = dict( type='RepeatDataset', times=N, dataset=dict( type='Dataset_A', ... pipeline=train_pipeline ) ) dataset_A_val = dict( ... pipeline=test_pipeline ) dataset_A_test = dict( ... pipeline=test_pipeline ) dataset_B_train = dict( type='RepeatDataset', times=M, dataset=dict( type='Dataset_B', ... pipeline=train_pipeline ) ) data = dict( imgs_per_gpu=2, workers_per_gpu=2, train = [ dataset_A_train, dataset_B_train ], val = dataset_A_val, test = dataset_A_test ) ``` -------------------------------- ### Test a model with MMRotate Source: https://mmrotate.readthedocs.io/en/latest/get_started Commands for testing a model using MMRotate on single GPU, multiple GPUs, or multiple nodes in a Slurm environment. Requires configuration and checkpoint files. ```Shell # single-gpu python${CONFIG_FILE}${CHECKPOINT_FILE}[optional] # multi-gpu ./tools/dist_test.sh${CONFIG_FILE}${CHECKPOINT_FILE}${GPU_NUM}[optional] # multi-node in slurm environment python${CONFIG_FILE}${CHECKPOINT_FILE}[optional] ``` -------------------------------- ### Define DOTADataset Configuration Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_config Specifies the dataset type as DOTADataset and defines the root path for the dataset, including paths for annotation files and image prefixes. ```python dataset_type = 'DOTADataset' data_root = '../datasets/split_1024_dota1_0/' ``` -------------------------------- ### Check PyTorch CUDA Availability Source: https://mmrotate.readthedocs.io/en/latest/faq Verifies if PyTorch is installed correctly and can utilize CUDA-enabled GPUs. This is a crucial step in diagnosing 'Segmentation fault' errors related to CUDA operations. ```Python import torch; print(torch.cuda.is_available()) ``` -------------------------------- ### Define Testing Data Pipeline Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_config Specifies the data processing steps for the testing pipeline, utilizing multi-scale flipping augmentation, normalization, padding, and collection of necessary keys. ```python test_pipeline = [ dict(type='LoadImageFromFile'), dict( type='MultiScaleFlipAug', img_scale=(1024, 1024), flip=False, transforms=[ dict(type='RResize'), dict( type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict(type='Pad', size_divisor=32), dict(type='DefaultFormatBundle'), dict(type='Collect', keys=['img']) ]) ] ``` -------------------------------- ### Modify MMRotate Config via Script Arguments Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_config Learn how to modify configuration options directly when running training or testing scripts using the `--cfg-options` argument. This enables in-place updates to config keys within dictionaries, lists, or tuples. ```python python tools/train.py --cfg-options model.backbone.norm_eval=False ``` ```python python tools/train.py --cfg-options data.train.pipeline.0.type=LoadImageFromWebcam ``` ```python python tools/train.py --cfg-options workflow="[(train,1),(val,1)]" ``` -------------------------------- ### Resuming Training from Checkpoint Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_config Specifies the path to resume training from a saved checkpoint. Training will continue from the epoch recorded in the checkpoint file. ```Python resume_from = None # Resume checkpoints from a given path, the training will be resumed from the epoch when the checkpoint's is saved. ``` -------------------------------- ### Use Custom Loss in Model Head Configuration Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_models This configuration example shows how to integrate the custom `MyLoss` into the model's head, specifically for bounding box regression. By setting `loss_bbox` to a dictionary with `type='MyLoss'` and specifying `loss_weight`, the custom loss function is applied during training. ```Python loss_bbox=dict(type='MyLoss', loss_weight=1.0)) ``` -------------------------------- ### Run MMRotate TorchServe Docker Image Source: https://mmrotate.readthedocs.io/en/latest/useful_tools Launches the MMRotate TorchServe Docker image for model serving. This command allows specifying CPU/GPU resources, port mappings, and mounting the model store. It's recommended to use nvidia-docker for GPU support. ```Shell docker run --cpus 8 --gpus device=0 -p 8080:8080 --mount type=bind,source=$MODEL_STORE,target=/home/model-server/model-store mmrotate-serve:latest ``` -------------------------------- ### Configure Validation Dataset Parameters Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_config Defines the validation dataset configuration, including type, annotation file path, image prefix, and the testing pipeline for validation. ```python val=dict( type='DOTADataset', ann_file'= '../datasets/split_1024_dota1_0/trainval/annfiles/', img_prefix'= '../datasets/split_1024_dota1_0/trainval/images/', pipeline=[ dict(type='LoadImageFromFile'), dict( type='MultiScaleFlipAug', img_scale=(1024, 1024), flip=False, transforms=[ dict(type='RResize'), dict( type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) ]) ]) ``` -------------------------------- ### Logging Configuration Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_config Sets up the logging mechanism for the training process. It defines the interval for printing logs (every 50 iterations) and specifies the logger hooks to be used, including 'TextLoggerHook'. Tensorboard logging is commented out but supported. ```Python log_config = dict( # config to register logger hook interval=50, # Interval to print the log hooks=[ # dict(type='TensorboardLoggerHook') # The Tensorboard logger is also supported dict(type='TextLoggerHook') ]) # The logger used to record the training process. ``` -------------------------------- ### Configure Testing Parameters Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_config Sets up hyperparameters for the testing phase, including Non-Maximum Suppression (NMS) thresholds and score thresholds for filtering bounding boxes. ```python test_cfg=dict( nms_pre=2000, min_bbox_size=0, score_thr=0.05, nms=dict(iou_thr=0.1), max_per_img=2000)) ``` -------------------------------- ### Distributed Training Parameters Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_config Specifies parameters for setting up distributed training. It defines the backend for communication as 'nccl', which is commonly used for GPU-based distributed training. ```Python dist_params = dict(backend='nccl') # Parameters to setup distributed training, the port can also be set. ``` -------------------------------- ### Learning Rate Scheduler Configuration Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_config Defines the learning rate scheduling policy. It uses a 'step' policy, meaning the learning rate decays at specific steps. It also includes a 'linear' warmup phase for the first 500 iterations and specifies the decay steps at epochs 8 and 11. ```Python lr_config = dict( # Learning rate scheduler config used to register LrUpdater hook policy='step', # The policy of scheduler warmup='linear', # The warmup policy, also support `exp` and `constant`. warmup_iters=500, # The number of iterations for warmup warmup_ratio=0.3333333333333333, # The ratio of the starting learning rate used for warmup step=[8, 11]) # Steps to decay the learning rate ``` -------------------------------- ### Benchmark FPS with MMRotate Source: https://mmrotate.readthedocs.io/en/latest/index Instructions on how to perform FPS (Frames Per Second) benchmarking for rotated object detection models using MMRotate. ```bash # FPS Benchmark ``` -------------------------------- ### Train a model with MMRotate (Multiple Machines) Source: https://mmrotate.readthedocs.io/en/latest/get_started Commands for training a model with MMRotate across multiple machines connected via ethernet. Requires setting environment variables for node count, rank, port, and address. ```Shell NNODES=2NODE_RANK=0PORT=$MASTER_PORTMASTER_ADDR=$MASTER_ADDR$CONFIG$GPUS NNODES=2NODE_RANK=1PORT=$MASTER_PORTMASTER_ADDR=$MASTER_ADDR$CONFIG$GPUS ``` -------------------------------- ### Working Directory Configuration Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_config Specifies the directory where model checkpoints and logs for the current experiment will be saved. The path is set to './work_dirs/rotated_retinanet_hbb_r50_fpn_1x_dota_oc'. ```Python work_dir = './work_dirs/rotated_retinanet_hbb_r50_fpn_1x_dota_oc' # Directory to save the model checkpoints and logs for the current experiments. ``` -------------------------------- ### Prepare Model for Publishing Source: https://mmrotate.readthedocs.io/en/latest/useful_tools The `publish_model.py` script assists in preparing a model for distribution. It converts model weights to CPU tensors, removes optimizer states, and calculates the hash of the checkpoint file, appending it to the filename. This ensures a consistent and identifiable model artifact. ```bash python tools/model_converters/publish_model.py ${INPUT_FILENAME}${OUTPUT_FILENAME} ``` -------------------------------- ### MMRotate DOTA v1.0 Model Configurations Source: https://mmrotate.readthedocs.io/en/latest/model_zoo This snippet lists various model configurations for object detection on the DOTA v1.0 dataset using the MMRotate framework. It includes details on backbone, mAP, angle settings, learning rate schedule, memory usage, inference time, augmentation, batch size, and links to model and log files. ```text Backbone | mAP | Angle | lr schd | Mem (GB) | Inf Time (fps) | Aug | Batch Size | Configs | Download ---|---|---|---|---|---|---|---|---|--- ResNet50 (1024,1024,200) | 59.44 | oc | 1x | 3.45 | 15.6 | - | 2 | rotated_reppoints_r50_fpn_1x_dota_oc | model | log ResNet50 (1024,1024,200) | 64.55 | oc | 1x | 3.38 | 15.7 | - | 2 | rotated_retinanet_hbb_r50_fpn_1x_dota_oc | model | log ResNet50 (1024,1024,200) | 65.59 | oc | 1x | 3.12 | 18.5 | - | 2 | rotated_atss_hbb_r50_fpn_1x_dota_oc | model | log ResNet50 (1024,1024,200) | 66.45 | oc | 1x | 3.53 | 15.3 | - | 2 | sasm_reppoints_r50_fpn_1x_dota_oc | model | log ResNet50 (1024,1024,200) | 68.42 | le90 | 1x | 3.38 | 16.9 | - | 2 | rotated_retinanet_obb_r50_fpn_1x_dota_le90 | model | log ResNet50 (1024,1024,200) | 68.79 | le90 | 1x | 2.36 | 22.4 | - | 2 | rotated_retinanet_obb_r50_fpn_fp16_1x_dota_le90 | model | log ResNet50 (1024,1024,200) | 69.49 | le135 | 1x | 4.05 | 8.6 | - | 2 | g_reppoints_r50_fpn_1x_dota_le135 | model | log ResNet50 (1024,1024,200) | 69.51 | le90 | 1x | 4.40 | 24.0 | - | 2 | rotated_retinanet_obb_csl_gaussian_r50_fpn_fp16_1x_dota_le90 | model | log ResNet50 (1024,1024,200) | 69.55 | oc | 1x | 3.39 | 15.5 | - | 2 | rotated_retinanet_hbb_gwd_r50_fpn_1x_dota_oc | model | log ResNet50 (1024,1024,200) | 69.60 | le90 | 1x | 3.38 | 15.1 | - | 2 | rotated_retinanet_hbb_kfiou_r50_fpn_1x_dota_le90 | model | log ResNet50 (1024,1024,200) | 69.63 | le135 | 1x | 3.45 | 16.1 | - | 2 | cfa_r50_fpn_1x_dota_le135 | model | log ResNet50 (1024,1024,200) | 69.76 | oc | 1x | 3.39 | 15.6 | - | 2 | rotated_retinanet_hbb_kfiou_r50_fpn_1x_dota_oc | model | log ResNet50 (1024,1024,200) | 69.77 | le135 | 1x | 3.38 | 15.3 | - | 2 | rotated_retinanet_hbb_kfiou_r50_fpn_1x_dota_le135 | model | log ResNet50 (1024,1024,200) | 69.79 | le135 | 1x | 3.38 | 17.2 | - | 2 | rotated_retinanet_obb_r50_fpn_1x_dota_le135 | model | log ResNet50 (1024,1024,200) | 69.80 | oc | 1x | 3.54 | 12.4 | - | 2 | r3det_r50_fpn_1x_dota_oc | model | log ResNet50 (1024,1024,200) | 69.94 | oc | 1x | 3.39 | 15.6 | - | 2 | rotated_retinanet_hbb_kld_r50_fpn_1x_dota_oc | model | log ResNet50 (1024,1024,200) | 70.18 | oc | 1x | 3.23 | 15.6 | - | 2 | r3det_tiny_r50_fpn_1x_dota_oc | model | log ResNet50 (1024,1024,200) | 70.64 | le90 | 1x | 3.12 | 18.2 | - | 2 | rotated_atss_obb_r50_fpn_1x_dota_le90 | model | log ResNet50 (1024,1024,200) | 70.70 | le90 | 1x | 4.18 | | - | 2 | rotated_fcos_sep_angle_r50_fpn_1x_dota_le90 | model | log ResNet50 (1024,1024,200) | 71.28 | le90 | 1x | 4.18 | | - | 2 | rotated_fcos_r50_fpn_1x_dota_le90 | model | log ResNet50 (1024,1024,200) | 71.76 | le90 | 1x | 4.23 | | - | 2 | rotated_fcos_csl_gaussian_r50_fpn_1x_dota_le90 | model | log ResNet50 (1024,1024,200) | 71.83 | oc | 1x | 3.54 | 12.4 | - | 2 | r3det_kld_r50_fpn_1x_dota_oc | model | log ResNet50 (1024,1024,200) | 71.89 | le90 | 1x | 4.18 | | - | 2 | rotated_fcos_kld_r50_fpn_1x_dota_le90 | model | log ResNet50 (1024,1024,200) | 71.94 | le135 | 1x | 3.45 | 16.1 | - | 2 | oriented_reppoints_r50_fpn_1x_dota_le135 | model | log ResNet50 (1024,1024,200) | 72.29 | le135 | 1x | 3.19 | 18.8 | - | 2 | rotated_atss_obb_r50_fpn_1x_dota_le135 | model | log ResNet50 (1024,1024,200) | 72.68 | oc | 1x | 3.62 | 12.2 | - | 2 | r3det_kfiou_ln_r50_fpn_1x_dota_oc | model | log ResNet50 (1024,1024,200) | 72.76 | oc | 1x | 3.44 | 14.0 | - | 2 | r3det_tiny_kld_r50_fpn_1x_dota_oc | model | log ResNet50 (1024,1024,200) | 73.23 | le90 | 1x | 8.45 | 16.4 | - | 2 | gliding_vertex_r50_fpn_1x_dota_le90 | model | log ResNet50 (1024,1024,200) | 73.40 | le90 | 1x | 8.46 | 16.5 | - | 2 | rotated_faster_rcnn_r50_fpn_1x_dota_le90 | model | log ResNet50 (1024,1024,200) | 73.45 | oc | 40e | 3.45 | 16.1 | - | 2 | cfa_r50_fpn_40e_dota_oc | model | log ResNet50 (1024,1024,200) | 73.91 | le135 | 1x | 3.14 | 15.5 | - | 2 | s2anet_r50_fpn_1x_dota_le135 | model | log ResNet50 (1024,1024,200) | 74.19 | le135 | 1x | 2.17 | 17.4 | - | 2 | s2anet_r50_fpn_fp16_1x_dota_le135 | model | log ResNet50 (1024,1024,200) | 75.63 | le90 | 1x | 7.37 | 21.2 | - | 2 | oriented_rcnn_r50_fpn_fp16_1x_dota_le90 | model | log ResNet50 (1024,1024,200) | 75.69 | le90 | 1x | 8.46 | 16.2 | - | 2 | oriented_rcnn_r50_fpn_1x_dota_le90 | model | log ResNet50 (1024,1024,200) | 75.75 | le90 | 1x | 7.56 | 19.3 | - | 2 | roi_trans_r50_fpn_fp16_1x_dota_le90 | model | log ReResNet50 (1024,1024,200) | 75.99 | le90 | 1x | 7.71 | 13.3 | - | 2 | redet_re50_refpn_fp16_1x_dota_le90 | model | log ResNet50 (1024,1024,200) | 76.08 | le90 | 1x | 8.67 | 14.4 | - | 2 | roi_trans_r50_fpn_1x_dota_le90 | model | log ResNet50 (1024,1024,500) | 76.50 | le90 | 1x | | 17.5 | MS+RR | 2 | rotated_retinanet_obb_r50_fpn_1x_dota_ms_rr_le90 | model | log ReResNet50 (1024,1024,200) | 76.68 | le90 | 1x | 9.32 | 10.9 | - | 2 | redet_re50_refpn_1x_dota_le90 | model | log ``` -------------------------------- ### Register Custom Hook via __init__.py Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_runtime Shows how to register a custom hook by importing it into the `__init__.py` file of the relevant directory, allowing the registry to recognize the new hook. ```python from .my_hook import MyHook ``` -------------------------------- ### Define New Backbone (MobileNet) Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_models This Python code defines a new backbone component, MobileNet, for MMrotate. It includes the necessary imports, decorator for registration, and a basic structure for the `__init__` and `forward` methods. ```Python import torch.nn as nn from mmrotate.models.builder import ROTATED_BACKBONES @ROTATED_BACKBONES.register_module() class MobileNet(nn.Module): def __init__(self, arg1, arg2): pass def forward(self, x): # should return a tuple pass ``` -------------------------------- ### MMRotate API Reference - mmrotate.utils Source: https://mmrotate.readthedocs.io/en/latest/api This section details the Application Programming Interface (API) for the mmrotate.utils module. It provides utility functions and tools that support the MMRotate framework. ```Python # mmrotate.utils ``` -------------------------------- ### Configure Image Normalization Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_config Defines the image normalization configuration, including mean, standard deviation, and RGB channel order, typically used for pre-trained backbone models. ```python img_norm_cfg = dict( mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) ``` -------------------------------- ### Specify Custom Optimizer in Config Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_runtime Shows how to use a custom optimizer, 'MyOptimizer', in the configuration file after it has been defined and registered. It provides the syntax for specifying the optimizer type and its custom arguments. ```Python optimizer = dict(type='MyOptimizer', a=a_value, b=b_value, c=c_value) ``` -------------------------------- ### Print Configuration Source: https://mmrotate.readthedocs.io/en/latest/useful_tools The `print_config.py` script displays the entire configuration file verbatim, resolving all imported settings. This is useful for understanding the complete model configuration, including any nested or extended parameters. ```bash python tools/misc/print_config.py ${CONFIG}[-h][--options${OPTIONS [OPTIONS...]}] ``` -------------------------------- ### MMRotate API Reference - mmrotate.core Source: https://mmrotate.readthedocs.io/en/latest/api This section details the Application Programming Interface (API) for the mmrotate.core module. It covers core components such as anchor generation, bounding box manipulation, patch handling, evaluation metrics, post-processing, and visualization utilities. ```Python # mmrotate.core * anchor * bbox * patch * evaluation * post_processing * visualization ``` -------------------------------- ### Customize Optimizer Constructor Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_runtime Demonstrates the structure for a custom optimizer constructor, 'MyOptimizerConstructor'. This class is designed to handle parameter-specific optimization settings, such as weight decay for BatchNorm layers, and is registered using OPTIMIZER_BUILDERS. ```Python from mmcv.utils import build_from_cfg from mmcv.runner.optimizer import OPTIMIZER_BUILDERS, OPTIMIZERS from mmrotate.utils import get_root_logger from .my_optimizer import MyOptimizer @OPTIMIZER_BUILDERS.register_module() class MyOptimizerConstructor(object): def __init__(self, optimizer_cfg, paramwise_cfg=None): def __call__(self, model): return my_optimizer ``` -------------------------------- ### Implement a New Custom Hook Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_runtime Demonstrates the structure for implementing a custom hook in MMRotate by inheriting from `mmcv.runner.Hook`. It includes methods for various stages of the training process. ```python from mmcv.runner import HOOKS, Hook @HOOKS.register_module() class MyHook(Hook): def __init__(self, a, b): pass def before_run(self, runner): pass def after_run(self, runner): pass def before_epoch(self, runner): pass def after_epoch(self, runner): pass def before_iter(self, runner): pass def after_iter(self, runner): pass ``` -------------------------------- ### Benchmark FPS Source: https://mmrotate.readthedocs.io/en/latest/useful_tools The `benchmark.py` script calculates the Frames Per Second (FPS) of a model, including both forward pass and post-processing. For accurate results, it currently supports only single GPU distributed startup mode. Users need to provide the configuration file, checkpoint path, and optionally specify repeat number, max iterations, and log interval. ```bash python tools/analysis_tools/benchmark.py \ =1=${PORT} ${CONFIG} ${CHECKPOINT} [--repeat-num${REPEAT_NUM}] [--max-iter${MAX_ITER}] [--log-interval${LOG_INTERVAL}] ``` ```bash python tools/analysis_tools/benchmark.py \ =1=29500 \ \ \ ``` -------------------------------- ### Configure Logging - Python Source: https://mmrotate.readthedocs.io/en/latest/tutorials/customize_runtime Sets up the logging configuration, enabling multiple logger hooks like TextLoggerHook and TensorboardLoggerHook with a specified logging interval. This allows for detailed monitoring of training progress. ```Python log_config = dict( interval=50, hooks=[ dict(type='TextLoggerHook'), dict(type='TensorboardLoggerHook') ]) ```