[Feature] Support mim (#376)

* Support mim extention

* Fix lint.

* Remove extra `demo` setting in mim related files.
pull/370/head^2
Ma Zerun 2021-07-27 05:58:04 -04:00 committed by GitHub
parent 99e3d4e49e
commit 0f4cae4d3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 87 additions and 29 deletions

1
.gitignore vendored
View File

@ -112,6 +112,7 @@ data
*.pkl.json *.pkl.json
*.log.json *.log.json
work_dirs/ work_dirs/
mmcls/.mim
# Pytorch # Pytorch
*.pth *.pth

View File

@ -1,3 +1,3 @@
include mmcls/model-index.yml include mmcls/.mim/model-index.yml
recursive-include mmcls/configs *.py *.yml recursive-include mmcls/.mim/configs *.py *.yml
recursive-include mmcls/tools *.sh *.py recursive-include mmcls/.mim/tools *.py *.sh

View File

@ -85,6 +85,7 @@ We wish that the toolbox and benchmark could serve the growing research communit
## Projects in OpenMMLab ## Projects in OpenMMLab
- [MMCV](https://github.com/open-mmlab/mmcv): OpenMMLab foundational library for computer vision. - [MMCV](https://github.com/open-mmlab/mmcv): OpenMMLab foundational library for computer vision.
- [MIM](https://github.com/open-mmlab/mim): MIM Installs OpenMMLab Packages.
- [MMClassification](https://github.com/open-mmlab/mmclassification): OpenMMLab image classification toolbox and benchmark. - [MMClassification](https://github.com/open-mmlab/mmclassification): OpenMMLab image classification toolbox and benchmark.
- [MMDetection](https://github.com/open-mmlab/mmdetection): OpenMMLab detection toolbox and benchmark. - [MMDetection](https://github.com/open-mmlab/mmdetection): OpenMMLab detection toolbox and benchmark.
- [MMDetection3D](https://github.com/open-mmlab/mmdetection3d): OpenMMLab's next-generation platform for general 3D object detection. - [MMDetection3D](https://github.com/open-mmlab/mmdetection3d): OpenMMLab's next-generation platform for general 3D object detection.

View File

@ -72,6 +72,7 @@ MMClassification 是一款由不同学校和公司共同贡献的开源项目。
## OpenMMLab 的其他项目 ## OpenMMLab 的其他项目
- [MMCV](https://github.com/open-mmlab/mmcv): OpenMMLab 计算机视觉基础库 - [MMCV](https://github.com/open-mmlab/mmcv): OpenMMLab 计算机视觉基础库
- [MIM](https://github.com/open-mmlab/mim): MIM 是 OpenMMlab 项目、算法、模型的统一入口
- [MMDetection](https://github.com/open-mmlab/mmdetection): OpenMMLab 检测工具箱与测试基准 - [MMDetection](https://github.com/open-mmlab/mmdetection): OpenMMLab 检测工具箱与测试基准
- [MMDetection3D](https://github.com/open-mmlab/mmdetection3d): OpenMMLab 新一代通用 3D 目标检测平台 - [MMDetection3D](https://github.com/open-mmlab/mmdetection3d): OpenMMLab 新一代通用 3D 目标检测平台
- [MMSegmentation](https://github.com/open-mmlab/mmsegmentation): OpenMMLab 语义分割工具箱与测试基准 - [MMSegmentation](https://github.com/open-mmlab/mmsegmentation): OpenMMLab 语义分割工具箱与测试基准

107
setup.py
View File

@ -1,3 +1,8 @@
import os
import os.path as osp
import shutil
import sys
import warnings
from setuptools import find_packages, setup from setuptools import find_packages, setup
@ -90,29 +95,79 @@ def parse_requirements(fname='requirements.txt', with_version=True):
return packages return packages
setup( def add_mim_extention():
name='mmcls', """Add extra files that are required to support MIM into the package.
version=get_version(),
description='OpenMMLab Image Classification Toolbox and Benchmark', These files will be added by creating a symlink to the originals if the
long_description=readme(), package is installed in `editable` mode (e.g. pip install -e .), or by
long_description_content_type='text/markdown', copying from the originals otherwise.
author='OpenMMLab', """
author_email='openmmlab@gmail.com',
keywords='computer vision, image classification', # parse installment mode
url='https://github.com/open-mmlab/mmclassification', if 'develop' in sys.argv:
packages=find_packages(exclude=('configs', 'tools', 'demo')), # installed by `pip install -e .`
include_package_data=True, mode = 'symlink'
classifiers=[ elif 'sdist' in sys.argv or 'bdist_wheel' in sys.argv:
'Development Status :: 4 - Beta', # installed by `pip install .`
'License :: OSI Approved :: Apache Software License', # or create source distribution by `python setup.py sdist`
'Operating System :: OS Independent', mode = 'copy'
'Programming Language :: Python :: 3', else:
'Programming Language :: Python :: 3.5', return
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7', filenames = ['tools', 'configs', 'model-index.yml']
'Programming Language :: Python :: 3.8', repo_path = osp.dirname(__file__)
], mim_path = osp.join(repo_path, 'mmcls', '.mim')
license='Apache License 2.0', os.makedirs(mim_path, exist_ok=True)
tests_require=parse_requirements('requirements/tests.txt'),
install_requires=parse_requirements('requirements/runtime.txt'), for filename in filenames:
zip_safe=False) if osp.exists(filename):
src_path = osp.join(repo_path, filename)
tar_path = osp.join(mim_path, filename)
if osp.isfile(tar_path) or osp.islink(tar_path):
os.remove(tar_path)
elif osp.isdir(tar_path):
shutil.rmtree(tar_path)
if mode == 'symlink':
src_relpath = osp.relpath(src_path, osp.dirname(tar_path))
os.symlink(src_relpath, tar_path)
elif mode == 'copy':
if osp.isfile(src_path):
shutil.copyfile(src_path, tar_path)
elif osp.isdir(src_path):
shutil.copytree(src_path, tar_path)
else:
warnings.warn(f'Cannot copy file {src_path}.')
else:
raise ValueError(f'Invalid mode {mode}')
if __name__ == '__main__':
add_mim_extention()
setup(
name='mmcls',
version=get_version(),
description='OpenMMLab Image Classification Toolbox and Benchmark',
long_description=readme(),
long_description_content_type='text/markdown',
author='OpenMMLab',
author_email='openmmlab@gmail.com',
keywords='computer vision, image classification',
url='https://github.com/open-mmlab/mmclassification',
packages=find_packages(exclude=('configs', 'tools', 'demo')),
include_package_data=True,
classifiers=[
'Development Status :: 4 - Beta',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
],
license='Apache License 2.0',
tests_require=parse_requirements('requirements/tests.txt'),
install_requires=parse_requirements('requirements/runtime.txt'),
zip_safe=False)