MIM提供了一个统一的接口,用于启动和安装OpenMMLab项目及其扩展,并管理OpenMMLab模型库。
软件包管理
您可以使用MIM方便地管理OpenMMLab代码库,安装或卸载它们。
模型管理
您可以使用MIM管理OpenMMLab模型库,例如通过名称下载检查点,搜索满足特定条件的检查点。
统一的脚本入口
您可以使用统一的命令执行所有OpenMMLab代码库提供的任何脚本。训练、测试和推理变得前所未有的简单。此外,您可以使用gridsearch
命令进行简单的超参数搜索。
本项目采用Apache 2.0许可证发布。
v0.1.1于2021年6月13日发布。
您可以使用.mimrc
进行自定义。目前我们支持自定义每个子命令的默认值。详情请参阅customization.md。
我们在MIM-Example中提供了一些如何基于OpenMMLAB代码库和MIM构建自定义项目的示例。用户无需担心从现有代码库复制代码和脚本,可以专注于开发新组件,而MIM则帮助集成和运行新项目。
请参阅installation.md进行安装。
命令
# 安装最新版本的mmcv-full > mim install mmcv-full # 轮子 # 安装1.5.0版本 > mim install mmcv-full==1.5.0 # 安装最新版本的mmcls > mim install mmcls # 安装主分支 > mim install git+https://github.com/open-mmlab/mmclassification.git # 安装本地仓库 > git clone https://github.com/open-mmlab/mmclassification.git > cd mmclassification > mim install . # 安装基于OpenMMLab的扩展 mim install git+https://github.com/xxx/mmcls-project.git
API
from mim import install # 安装mmcv install('mmcv-full') # 安装mmcls,如果未安装mmcv,将自动安装 install('mmcls') # 安装基于OpenMMLab的扩展 install('git+https://github.com/xxx/mmcls-project.git')
命令
# 卸载mmcv > mim uninstall mmcv-full # 卸载mmcls > mim uninstall mmcls
API
from mim import uninstall # 卸载mmcv uninstall('mmcv-full') # 卸载mmcls uninstall('mmcls')
命令
> mim list > mim list --all
API
from mim import list_package list_package() list_package(True)
命令
> mim search mmcls > mim search mmcls==0.23.0 --remote > mim search mmcls --config resnet18_8xb16_cifar10 > mim search mmcls --model resnet > mim search mmcls --dataset cifar-10 > mim search mmcls --valid-field > mim search mmcls --condition 'batch_size>45,epochs>100' > mim search mmcls --condition 'batch_size>45 epochs>100' > mim search mmcls --condition '128<batch_size<=256' > mim search mmcls --sort batch_size epochs > mim search mmcls --field epochs batch_size weight > mim search mmcls --exclude-field weight paper
API
from mim import get_model_info get_model_info('mmcls') get_model_info('mmcls==0.23.0', local=False) get_model_info('mmcls', models=['resnet']) get_model_info('mmcls', training_datasets=['cifar-10']) get_model_info('mmcls', filter_conditions='batch_size>45,epochs>100') get_model_info('mmcls', filter_conditions='batch_size>45 epochs>100') get_model_info('mmcls', filter_conditions='128<batch_size<=256') get_model_info('mmcls', sorted_fields=['batch_size', 'epochs']) get_model_info('mmcls', shown_fields=['epochs', 'batch_size', 'weight'])
命令
> mim download mmcls --config resnet18_8xb16_cifar10 > mim download mmcls --config resnet18_8xb16_cifar10 --dest .
API
from mim import download download('mmcls', ['resnet18_8xb16_cifar10']) download('mmcls', ['resnet18_8xb16_cifar10'], dest_root='.')
命令
# 通过将'gpus'设置为0和'launcher'设置为'none'(如果适用)在单个服务器上使用CPU训练模型。 # 如果相应的代码库不支持CPU训练,训练脚本将失败。 > mim train mmcls resnet101_b16x8_cifar10.py --work-dir tmp --gpus 0 # 在单个服务器上使用一个GPU训练模型 > mim train mmcls resnet101_b16x8_cifar10.py --work-dir tmp --gpus 1 # 在单个服务器上使用4个GPU和pytorch分布式训练模型 > mim train mmcls resnet101_b16x8_cifar10.py --work-dir tmp --gpus 4 \ --launcher pytorch # 在具有一个8-GPU节点的slurm HPC上训练模型 > mim train mmcls resnet101_b16x8_cifar10.py --launcher slurm --gpus 8 \ --gpus-per-node 8 --partition partition_name --work-dir tmp # 打印子命令train的帮助信息 > mim train -h # 打印子命令train和mmcls训练脚本的帮助信息 > mim train mmcls -h
API
from mim import train
train(repo='mmcls', config='resnet18_8xb16_cifar10.py', gpus=0, other_args=('--work-dir', 'tmp')) train(repo='mmcls', config='resnet18_8xb16_cifar10.py', gpus=1, other_args=('--work-dir', 'tmp')) train(repo='mmcls', config='resnet18_8xb16_cifar10.py', gpus=4, launcher='pytorch', other_args=('--work-dir', 'tmp')) train(repo='mmcls', config='resnet18_8xb16_cifar10.py', gpus=8, launcher='slurm', gpus_per_node=8, partition='partition_name', other_args=('--work-dir', 'tmp'))
</details>
<details>
<summary>7. test</summary>
- 命令
```bash
# 在单台服务器上使用1个GPU测试模型,报告准确率
> mim test mmcls resnet101_b16x8_cifar10.py --checkpoint \
tmp/epoch_3.pth --gpus 1 --metrics accuracy
# 在单台服务器上使用1个GPU测试模型,保存预测结果
> mim test mmcls resnet101_b16x8_cifar10.py --checkpoint \
tmp/epoch_3.pth --gpus 1 --out tmp.pkl
# 在单台服务器上使用4个GPU测试模型,使用pytorch分布式,报告准确率
> mim test mmcls resnet101_b16x8_cifar10.py --checkpoint \
tmp/epoch_3.pth --gpus 4 --launcher pytorch --metrics accuracy
# 在slurm高性能计算集群上使用一个8-GPU节点测试模型,报告准确率
> mim test mmcls resnet101_b16x8_cifar10.py --checkpoint \
tmp/epoch_3.pth --gpus 8 --metrics accuracy --partition \
partition_name --gpus-per-node 8 --launcher slurm
# 打印test子命令的帮助信息
> mim test -h
# 打印test子命令和mmcls测试脚本的帮助信息
> mim test mmcls -h
API
from mim import test test(repo='mmcls', config='resnet101_b16x8_cifar10.py', checkpoint='tmp/epoch_3.pth', gpus=1, other_args=('--metrics', 'accuracy')) test(repo='mmcls', config='resnet101_b16x8_cifar10.py', checkpoint='tmp/epoch_3.pth', gpus=1, other_args=('--out', 'tmp.pkl')) test(repo='mmcls', config='resnet101_b16x8_cifar10.py', checkpoint='tmp/epoch_3.pth', gpus=4, launcher='pytorch', other_args=('--metrics', 'accuracy')) test(repo='mmcls', config='resnet101_b16x8_cifar10.py', checkpoint='tmp/epoch_3.pth', gpus=8, partition='partition_name', launcher='slurm', gpus_per_node=8, other_args=('--metrics', 'accuracy'))