mim

mim

OpenMMLab项目的统一管理和运行工具

MIM为OpenMMLab项目提供统一的管理接口,简化了包的安装卸载和模型库管理。它通过统一入口点简化了训练、测试和推理过程,并支持自定义项目构建和网格搜索,提高了开发效率和实验灵活性。

MIMOpenMMLab包管理模型管理命令行工具Github开源项目

MIM: MIM安装OpenMMLab软件包

MIM提供了一个统一的接口,用于启动和安装OpenMMLab项目及其扩展,并管理OpenMMLab模型库。

主要特性

  • 软件包管理

    您可以使用MIM方便地管理OpenMMLab代码库,安装或卸载它们。

  • 模型管理

    您可以使用MIM管理OpenMMLab模型库,例如通过名称下载检查点,搜索满足特定条件的检查点。

  • 统一的脚本入口

    您可以使用统一的命令执行所有OpenMMLab代码库提供的任何脚本。训练、测试和推理变得前所未有的简单。此外,您可以使用gridsearch命令进行简单的超参数搜索。

许可证

本项目采用Apache 2.0许可证发布。

更新日志

v0.1.1于2021年6月13日发布。

自定义

您可以使用.mimrc进行自定义。目前我们支持自定义每个子命令的默认值。详情请参阅customization.md

使用MIM构建自定义项目

我们在MIM-Example中提供了一些如何基于OpenMMLAB代码库和MIM构建自定义项目的示例。用户无需担心从现有代码库复制代码和脚本,可以专注于开发新组件,而MIM则帮助集成和运行新项目。

安装

请参阅installation.md进行安装。

命令

<details> <summary>1. 安装</summary>
  • 命令

    # 安装最新版本的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')
</details> <details> <summary>2. 卸载</summary>
  • 命令

    # 卸载mmcv > mim uninstall mmcv-full # 卸载mmcls > mim uninstall mmcls
  • API

    from mim import uninstall # 卸载mmcv uninstall('mmcv-full') # 卸载mmcls uninstall('mmcls')
</details> <details> <summary>3. 列表</summary>
  • 命令

    > mim list > mim list --all
  • API

    from mim import list_package list_package() list_package(True)
</details> <details> <summary>4. 搜索</summary>
  • 命令

    > 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'])
</details> <details> <summary>5. 下载</summary>
  • 命令

    > 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='.')
</details> <details> <summary>6. 训练</summary>
  • 命令

    # 通过将'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'))
</details> <details> <summary>8. run</summary>
  • 命令

    # 获取模型的Flops > mim run mmcls get_flops resnet101_b16x8_cifar10.py # 发布模型 > mim run mmcls publish_model input.pth output.pth # 在slurm高性能计算集群上使用一个GPU训练模型 > srun -p partition --gres=gpu:1 mim run mmcls train \ resnet101_b16x8_cifar10.py --work-dir tmp # 在slurm高性能计算集群上使用一个GPU测试模型,报告准确率 > srun -p partition --gres=gpu:1 mim run mmcls test \ resnet101_b16x8_cifar10.py tmp/epoch_3.pth --metrics accuracy # 打印run子命令的帮助信息 > mim run -h # 打印run子命令的帮助信息,列出mmcls代码库中所有可用的脚本 > mim run mmcls -h # 打印run子命令的帮助信息,打印mmcls训练脚本的帮助信息 > mim run mmcls train -h
  • API

    from mim import run run(repo='mmcls', command='get_flops', other_args=('resnet101_b16x8_cifar10.py',)) run(repo='mmcls', command='publish_model', other_args=('input.pth', 'output.pth')) run(repo='mmcls', command='train', other_args=('resnet101_b16x8_cifar10.py', '--work-dir', 'tmp')) run(repo='mmcls', command='test', other_args=('resnet101_b16x8_cifar10.py', 'tmp/epoch_3.pth', '--metrics accuracy'))
</details> <details> <summary>9. gridsearch</summary>
  • 命令
# 通过将 `gpus` 设置为 0 并将 'launcher' 设置为 'none'(如适用),在单台服务器上使用 CPU 进行参数搜索。 # 如果相应代码库不支持 CPU 训练,其训练脚本将会失败。 > mim gridsearch mmcls resnet101_b16x8_cifar10.py --work-dir tmp --gpus 0 \ --search-args '--optimizer.lr 1e-2 1e-3' # 在单台服务器上使用一个 GPU 进行参数搜索,搜索学习率 > mim gridsearch mmcls resnet101_b16x8_cifar10.py --work-dir tmp --gpus 1 \ --search-args '--optimizer.lr 1e-2 1e-3' # 在单台服务器上使用一个 GPU 进行参数搜索,搜索权重衰减 > mim gridsearch mmcls resnet101_b16x8_cifar10.py --work-dir tmp --gpus 1 \ --search-args '--optimizer.weight_decay 1e-3 1e-4' # 在单台服务器上使用一个 GPU 进行参数搜索,搜索学习率和权重衰减 > mim gridsearch mmcls resnet101_b16x8_cifar10.py --work-dir tmp --gpus 1 \ --search-args '--optimizer.lr 1e-2 1e-3 --optimizer.weight_decay 1e-3 \ 1e-4' # 在 slurm HPC 上使用一个 8-GPU 节点进行参数搜索,搜索学习率和权重衰减 > mim gridsearch mmcls resnet101_b16x8_cifar10.py --work-dir tmp --gpus 8 \ --partition partition_name --gpus-per-node 8 --launcher slurm \ --search-args '--optimizer.lr 1e-2 1e-3 --optimizer.weight_decay 1e-3 \ 1e-4' # 在 slurm HPC 上使用一个 8-GPU 节点进行参数搜索,搜索学习率和权重衰减,最大并行作业数为 2 > mim gridsearch mmcls resnet101_b16x8_cifar10.py --work-dir tmp --gpus 8 \ --partition partition_name --gpus-per-node 8 --launcher slurm \ --max-jobs 2 --search-args '--optimizer.lr 1e-2 1e-3 \ --optimizer.weight_decay 1e-3 1e-4' # 打印子命令 search 的帮助信息 > mim gridsearch -h # 打印子命令 search 的帮助信息以及代码库 mmcls 训练脚本的帮助信息 > mim gridsearch mmcls -h
  • API
from mim import gridsearch gridsearch(repo='mmcls', config='resnet101_b16x8_cifar10.py', gpus=0, search_args='--optimizer.lr 1e-2 1e-3', other_args=('--work-dir', 'tmp')) gridsearch(repo='mmcls', config='resnet101_b16x8_cifar10.py', gpus=1, search_args='--optimizer.lr 1e-2 1e-3', other_args=('--work-dir', 'tmp')) gridsearch(repo='mmcls', config='resnet101_b16x8_cifar10.py', gpus=1, search_args='--optimizer.weight_decay 1e-3 1e-4', other_args=('--work-dir', 'tmp')) gridsearch(repo='mmcls', config='resnet101_b16x8_cifar10.py', gpus=1, search_args='--optimizer.lr 1e-2 1e-3 --optimizer.weight_decay' '1e-3 1e-4', other_args=('--work-dir', 'tmp')) gridsearch(repo='mmcls', config='resnet101_b16x8_cifar10.py', gpus=8, partition='partition_name', gpus_per_node=8, launcher='slurm', search_args='--optimizer.lr 1e-2 1e-3 --optimizer.weight_decay' ' 1e-3 1e-4', other_args=('--work-dir', 'tmp')) gridsearch(repo='mmcls', config='resnet101_b16x8_cifar10.py', gpus=8, partition='partition_name', gpus_per_node=8, launcher='slurm', max_workers=2, search_args='--optimizer.lr 1e-2 1e-3 --optimizer.weight_decay' ' 1e-3 1e-4', other_args=('--work-dir', 'tmp'))

贡献

我们感谢所有为改进 mim 做出的贡献。请参阅 CONTRIBUTING.md 以了解贡献指南。

许可证

该项目基于 Apache 2.0 许可证 发布。

OpenMMLab 中的项目

  • MMEngine:OpenMMLab用于训练深度学习模型的基础库。
  • MMCV:OpenMMLab计算机视觉基础库。
  • MMEval:适用于多个机器学习库的统一评估库。
  • MMPreTrain:OpenMMLab预训练工具箱和基准测试。
  • MMagic:OpenMMLab先进、生成式和智能创作工具箱。
  • MMDetection:OpenMMLab检测工具箱和基准测试。
  • MMYOLO:OpenMMLab YOLO系列工具箱和基准测试。
  • MMDetection3D:OpenMMLab新一代通用3D目标检测平台。
  • MMRotate:OpenMMLab旋转目标检测工具箱和基准测试。
  • MMTracking:OpenMMLab视频感知工具箱和基准测试。
  • MMPose:OpenMMLab姿态估计工具箱和基准测试。
  • MMSegmentation:OpenMMLab语义分割工具箱和基准测试。
  • MMOCR:OpenMMLab文本检测、识别和理解工具箱。
  • MMHuman3D:OpenMMLab 3D人体参数化模型工具箱和基准测试。
  • MMSelfSup:OpenMMLab自监督学习工具箱和基准测试。
  • MMFewShot:OpenMMLab小样本学习工具箱和基准测试。
  • MMAction2:OpenMMLab新一代动作理解工具箱和基准测试。
  • MMFlow:OpenMMLab光流工具箱和基准测试。
  • MMDeploy:OpenMMLab模型部署框架。
  • MMRazor:OpenMMLab模型压缩工具箱和基准测试。
  • Playground:汇集和展示基于OpenMMLab构建的精彩项目的中心平台。

编辑推荐精选

博思AIPPT

博思AIPPT

AI一键生成PPT,就用博思AIPPT!

博思AIPPT,新一代的AI生成PPT平台,支持智能生成PPT、AI美化PPT、文本&链接生成PPT、导入Word/PDF/Markdown文档生成PPT等,内置海量精美PPT模板,涵盖商务、教育、科技等不同风格,同时针对每个页面提供多种版式,一键自适应切换,完美适配各种办公场景。

AI办公办公工具AI工具博思AIPPTAI生成PPT智能排版海量精品模板AI创作热门
潮际好麦

潮际好麦

AI赋能电商视觉革命,一站式智能商拍平台

潮际好麦深耕服装行业,是国内AI试衣效果最好的软件。使用先进AIGC能力为电商卖家批量提供优质的、低成本的商拍图。合作品牌有Shein、Lazada、安踏、百丽等65个国内外头部品牌,以及国内10万+淘宝、天猫、京东等主流平台的品牌商家,为卖家节省将近85%的出图成本,提升约3倍出图效率,让品牌能够快速上架。

iTerms

iTerms

企业专属的AI法律顾问

iTerms是法大大集团旗下法律子品牌,基于最先进的大语言模型(LLM)、专业的法律知识库和强大的智能体架构,帮助企业扫清合规障碍,筑牢风控防线,成为您企业专属的AI法律顾问。

SimilarWeb流量提升

SimilarWeb流量提升

稳定高效的流量提升解决方案,助力品牌曝光

稳定高效的流量提升解决方案,助力品牌曝光

Sora2视频免费生成

Sora2视频免费生成

最新版Sora2模型免费使用,一键生成无水印视频

最新版Sora2模型免费使用,一键生成无水印视频

Transly

Transly

实时语音翻译/同声传译工具

Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。

讯飞绘文

讯飞绘文

选题、配图、成文,一站式创作,让内容运营更高效

讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。

热门AI辅助写作AI工具讯飞绘文内容运营AI创作个性化文章多平台分发AI助手
TRAE编程

TRAE编程

AI辅助编程,代码自动修复

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

AI工具TraeAI IDE协作生产力转型热门
商汤小浣熊

商汤小浣熊

最强AI数据分析助手

小浣熊家族Raccoon,您的AI智能助手,致力于通过先进的人工智能技术,为用户提供高效、便捷的智能服务。无论是日常咨询还是专业问题解答,小浣熊都能以快速、准确的响应满足您的需求,让您的生活更加智能便捷。

imini AI

imini AI

像人一样思考的AI智能体

imini 是一款超级AI智能体,能根据人类指令,自主思考、自主完成、并且交付结果的AI智能体。

下拉加载更多