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构建的精彩项目的中心平台。

编辑推荐精选

Trae

Trae

字节跳动发布的AI编程神器IDE

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

热门AI工具生产力协作转型TraeAI IDE
问小白

问小白

全能AI智能助手,随时解答生活与工作的多样问题

问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。

聊天机器人AI助手热门AI工具AI对话
Transly

Transly

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

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

讯飞智文

讯飞智文

一键生成PPT和Word,让学习生活更轻松

讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。

热门AI工具AI办公办公工具讯飞智文AI在线生成PPTAI撰写助手多语种文档生成AI自动配图
讯飞星火

讯飞星火

深度推理能力全新升级,全面对标OpenAI o1

科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。

模型训练热门AI工具内容创作智能问答AI开发讯飞星火大模型多语种支持智慧生活
Spark-TTS

Spark-TTS

一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型

Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。

咔片PPT

咔片PPT

AI助力,做PPT更简单!

咔片是一款轻量化在线演示设计工具,借助 AI 技术,实现从内容生成到智能设计的一站式 PPT 制作服务。支持多种文档格式导入生成 PPT,提供海量模板、智能美化、素材替换等功能,适用于销售、教师、学生等各类人群,能高效制作出高品质 PPT,满足不同场景演示需求。

讯飞绘文

讯飞绘文

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

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

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

材料星

专业的AI公文写作平台,公文写作神器

AI 材料星,专业的 AI 公文写作辅助平台,为体制内工作人员提供高效的公文写作解决方案。拥有海量公文文库、9 大核心 AI 功能,支持 30 + 文稿类型生成,助力快速完成领导讲话、工作总结、述职报告等材料,提升办公效率,是体制打工人的得力写作神器。

openai-agents-python

openai-agents-python

OpenAI Agents SDK,助力开发者便捷使用 OpenAI 相关功能。

openai-agents-python 是 OpenAI 推出的一款强大 Python SDK,它为开发者提供了与 OpenAI 模型交互的高效工具,支持工具调用、结果处理、追踪等功能,涵盖多种应用场景,如研究助手、财务研究等,能显著提升开发效率,让开发者更轻松地利用 OpenAI 的技术优势。

下拉加载更多