Package: openmim
MIM: MIM Installs OpenMMLab PackagesMIM provides a unified interface for launching and installing OpenMMLab projects and their extensions, and managing the OpenMMLab model zoo.Major FeaturesPackage ManagementYou can use MIM to manage OpenMMLab codebases, install or uninstall them conveniently.Model ManagementYou can use MIM to manage OpenMMLab model zoo, e.g., download checkpoints by name, search checkpoints that meet specific criteria.Unified Entrypoint for ScriptsYou can execute any script provided by all OpenMMLab codebases with unified commands. Train, test and inference become easier than ever. Besides, you can usegridsearchcommand for vanilla hyper-parameter search.LicenseThis project is released under theApache 2.0 license.Changelogv0.1.1 was released in 13/6/2021.CustomizationYou can use.mimrcfor customization. Now we support customize default values of each sub-command. Please refer tocustomization.mdfor details.Build custom projects with MIMWe provide some examples of how to build custom projects based on OpenMMLAB codebases and MIM inMIM-Example.
Without worrying about copying codes and scripts from existing codebases, users can focus on developing new components and MIM helps integrate and run the new project.InstallationPlease refer toinstallation.mdfor installation.Command1. installcommand# install latest version of mmcv-full>miminstallmmcv-full# wheel# install 1.5.0>miminstallmmcv-full==1.5.0# install latest version of mmcls>miminstallmmcls# install master branch>miminstallgit+https://github.com/open-mmlab/mmclassification.git# install local repo>gitclonehttps://github.com/open-mmlab/mmclassification.git
>cdmmclassification
>miminstall.# install extension based on OpenMMLabmiminstallgit+https://github.com/xxx/mmcls-project.gitapifrommimimportinstall# install mmcvinstall('mmcv-full')# install mmcls will automatically install mmcv if it is not installedinstall('mmcls')# install extension based on OpenMMLabinstall('git+https://github.com/xxx/mmcls-project.git')2. uninstallcommand# uninstall mmcv>mimuninstallmmcv-full# uninstall mmcls>mimuninstallmmclsapifrommimimportuninstall# uninstall mmcvuninstall('mmcv-full')# uninstall mmclsuninstall('mmcls')3. listcommand>mimlist
>mimlist--allapifrommimimportlist_packagelist_package()list_package(True)4. searchcommand>mimsearchmmcls
>mimsearchmmcls==0.23.0--remote
>mimsearchmmcls--configresnet18_8xb16_cifar10
>mimsearchmmcls--modelresnet
>mimsearchmmcls--datasetcifar-10
>mimsearchmmcls--valid-field
>mimsearchmmcls--condition'batch_size>45,epochs>100'>mimsearchmmcls--condition'batch_size>45 epochs>100'>mimsearchmmcls--condition'128<batch_size<=256'>mimsearchmmcls--sortbatch_sizeepochs
>mimsearchmmcls--fieldepochsbatch_sizeweight
>mimsearchmmcls--exclude-fieldweightpaperapifrommimimportget_model_infoget_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'])5. downloadcommand>mimdownloadmmcls--configresnet18_8xb16_cifar10
>mimdownloadmmcls--configresnet18_8xb16_cifar10--dest.apifrommimimportdownloaddownload('mmcls',['resnet18_8xb16_cifar10'])download('mmcls',['resnet18_8xb16_cifar10'],dest_root='.')6. traincommand# Train models on a single server with CPU by setting `gpus` to 0 and# 'launcher' to 'none' (if applicable). The training script of the# corresponding codebase will fail if it doesn't support CPU training.>mimtrainmmclsresnet101_b16x8_cifar10.py--work-dirtmp--gpus0# Train models on a single server with one GPU>mimtrainmmclsresnet101_b16x8_cifar10.py--work-dirtmp--gpus1# Train models on a single server with 4 GPUs and pytorch distributed>mimtrainmmclsresnet101_b16x8_cifar10.py--work-dirtmp--gpus4\--launcherpytorch# Train models on a slurm HPC with one 8-GPU node>mimtrainmmclsresnet101_b16x8_cifar10.py--launcherslurm--gpus8\--gpus-per-node8--partitionpartition_name--work-dirtmp# Print help messages of sub-command train>mimtrain-h# Print help messages of sub-command train and the training script of mmcls>mimtrainmmcls-hapifrommimimporttraintrain(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')7. testcommand# Test models on a single server with 1 GPU, report accuracy>mimtestmmclsresnet101_b16x8_cifar10.py--checkpoint\tmp/epoch_3.pth--gpus1--metricsaccuracy# Test models on a single server with 1 GPU, save predictions>mimtestmmclsresnet101_b16x8_cifar10.py--checkpoint\tmp/epoch_3.pth--gpus1--outtmp.pkl# Test models on a single server with 4 GPUs, pytorch distributed,# report accuracy>mimtestmmclsresnet101_b16x8_cifar10.py--checkpoint\tmp/epoch_3.pth--gpus4--launcherpytorch--metricsaccuracy# Test models on a slurm HPC with one 8-GPU node, report accuracy>mimtestmmclsresnet101_b16x8_cifar10.py--checkpoint\tmp/epoch_3.pth--gpus8--metricsaccuracy--partition\partition_name--gpus-per-node8--launcherslurm# Print help messages of sub-command test>mimtest-h# Print help messages of sub-command test and the testing script of mmcls>mimtestmmcls-hapifrommimimporttesttest(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')8. runcommand# Get the Flops of a model>mimrunmmclsget_flopsresnet101_b16x8_cifar10.py# Publish a model>mimrunmmclspublish_modelinput.pthoutput.pth# Train models on a slurm HPC with one GPU>srun-ppartition--gres=gpu:1mimrunmmclstrain\resnet101_b16x8_cifar10.py--work-dirtmp# Test models on a slurm HPC with one GPU, report accuracy>srun-ppartition--gres=gpu:1mimrunmmclstest\resnet101_b16x8_cifar10.pytmp/epoch_3.pth--metricsaccuracy# Print help messages of sub-command run>mimrun-h# Print help messages of sub-command run, list all available scripts in# codebase mmcls>mimrunmmcls-h# Print help messages of sub-command run, print the help message of# training script in mmcls>mimrunmmclstrain-hapifrommimimportrunrun(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')9. gridsearchcommand# Parameter search on a single server with CPU by setting `gpus` to 0 and# 'launcher' to 'none' (if applicable). The training script of the# corresponding codebase will fail if it doesn't support CPU training.>mimgridsearchmmclsresnet101_b16x8_cifar10.py--work-dirtmp--gpus0\--search-args'--optimizer.lr 1e-2 1e-3'# Parameter search with on a single server with one GPU, search learning# rate>mimgridsearchmmclsresnet101_b16x8_cifar10.py--work-dirtmp--gpus1\--search-args'--optimizer.lr 1e-2 1e-3'# Parameter search with on a single server with one GPU, search# weight_decay>mimgridsearchmmclsresnet101_b16x8_cifar10.py--work-dirtmp--gpus1\--search-args'--optimizer.weight_decay 1e-3 1e-4'# Parameter search with on a single server with one GPU, search learning# rate and weight_decay>mimgridsearchmmclsresnet101_b16x8_cifar10.py--work-dirtmp--gpus1\--search-args'--optimizer.lr 1e-2 1e-3 --optimizer.weight_decay 1e-3 \1e-4'# Parameter search on a slurm HPC with one 8-GPU node, search learning# rate and weight_decay>mimgridsearchmmclsresnet101_b16x8_cifar10.py--work-dirtmp--gpus8\--partitionpartition_name--gpus-per-node8--launcherslurm\--search-args'--optimizer.lr 1e-2 1e-3 --optimizer.weight_decay 1e-3 \1e-4'# Parameter search on a slurm HPC with one 8-GPU node, search learning# rate and weight_decay, max parallel jobs is 2>mimgridsearchmmclsresnet101_b16x8_cifar10.py--work-dirtmp--gpus8\--partitionpartition_name--gpus-per-node8--launcherslurm\--max-jobs2--search-args'--optimizer.lr 1e-2 1e-3 \--optimizer.weight_decay 1e-3 1e-4'# Print the help message of sub-command search>mimgridsearch-h# Print the help message of sub-command search and the help message of the# training script of codebase mmcls>mimgridsearchmmcls-hapifrommimimportgridsearchgridsearch(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')ContributingWe appreciate all contributions to improve mim. Please refer toCONTRIBUTING.mdfor the contributing guideline.LicenseThis project is released under theApache 2.0 license.Projects in OpenMMLabMMEngine: OpenMMLab foundational library for training deep learning models.MMCV: OpenMMLab foundational library for computer vision.MMEval: A unified evaluation library for multiple machine learning libraries.MMPreTrain: OpenMMLab pre-training toolbox and benchmark.MMagic: OpenMMLabAdvanced,Generative andIntelligentCreation toolbox.MMDetection: OpenMMLab detection toolbox and benchmark.MMYOLO: OpenMMLab YOLO series toolbox and benchmark.MMDetection3D: OpenMMLab's next-generation platform for general 3D object detection.MMRotate: OpenMMLab rotated object detection toolbox and benchmark.MMTracking: OpenMMLab video perception toolbox and benchmark.MMPose: OpenMMLab pose estimation toolbox and benchmark.MMSegmentation: OpenMMLab semantic segmentation toolbox and benchmark.MMOCR: OpenMMLab text detection, recognition, and understanding toolbox.MMHuman3D: OpenMMLab 3D human parametric model toolbox and benchmark.MMSelfSup: OpenMMLab self-supervised learning toolbox and benchmark.MMFewShot: OpenMMLab fewshot learning toolbox and benchmark.MMAction2: OpenMMLab's next-generation action understanding toolbox and benchmark.MMFlow: OpenMMLab optical flow toolbox and benchmark.MMDeploy: OpenMMLab model deployment framework.MMRazor: OpenMMLab model compression toolbox and benchmark.Playground: A central hub for gathering and showcasing amazing projects built upon OpenMMLab.