Auto get version info and git hash (#55)

* Auto get version info and git hash

* bump 0.5.1 and update doc

* fixed docs

* Add change log
pull/74/head
Jerry Jiarui XU 2020-08-11 19:23:35 +08:00 committed by GitHub
parent 5e264c608c
commit 4e29452dbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 89 additions and 2809 deletions

1
.gitignore vendored
View File

@ -103,7 +103,6 @@ venv.bak/
# mypy
.mypy_cache/
mmseg/version.py
data
.vscode
.idea

View File

@ -44,7 +44,8 @@ This project is released under the [Apache 2.0 license](LICENSE).
## Changelog
v0.5.0 was released in 10/7/2020.
v0.5.1 was released in 11/08/2020.
Please refer to [changelog.md](docs/changelog.md) for details and release history.
## Benchmark and model zoo

15
docs/changelog.md 100644
View File

@ -0,0 +1,15 @@
## Changelog
### v0.5.1 (11/08/2020)
**Highlights**
- Support FP16 and more generalized OHEM
**Bug Fixes**
- Fixed Pascal VOC conversion script (#19)
- Fixed OHEM weight assign bug (#54)
- Fixed palette type when palette is not given (#27)
**New Features**
- Support FP16 (#21)
- Generalized OHEM (#54)
**Improvements**
- Add load-from flag (#33)
- Fixed training tricks doc about different learning rates of model (#26)

View File

@ -20,10 +20,17 @@ sys.path.insert(0, os.path.abspath('..'))
project = 'MMSegmentation'
copyright = '2020-2020, OpenMMLab'
author = 'MMSegmentation Authors'
version_file = '../mmseg/version.py'
def get_version():
with open(version_file, 'r') as f:
exec(compile(f.read(), version_file, 'exec'))
return locals()['__version__']
# The full version, including alpha/beta/rc tags
with open('../mmseg/VERSION', 'r') as f:
release = f.read().strip()
release = get_version()
# -- General configuration ---------------------------------------------------

View File

@ -54,10 +54,9 @@ pip install -e . # or "python setup.py develop"
Note:
1. In `dev` mode, the git commit id will be written to the version number with step *d*, e.g. 0.5.0+c415a2e. The version will also be saved in trained models.
It is recommended that you run step *d* each time you pull some updates from github. If C++/CUDA codes are modified, then this step is compulsory.
1. The `version+git_hash` will also be saved in trained models meta, e.g. 0.5.0+c415a2e.
2. When MMsegmentation is installed on `dev` mode, any local modifications made to the code will take effect without the need to reinstall it (unless you submit some commits and want to update the version number).
2. When MMsegmentation is installed on `dev` mode, any local modifications made to the code will take effect without the need to reinstall it.
3. If you would like to use `opencv-python-headless` instead of `opencv-python`,
you can install it before installing MMCV.

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@
0.5.0

View File

@ -1,3 +1,30 @@
from .version import __version__, short_version, version_info
import mmcv
__all__ = ['__version__', 'short_version', 'version_info']
from .version import __version__, version_info
MMCV_MIN = '1.0.5'
MMCV_MAX = '1.0.5'
def digit_version(version_str):
digit_version = []
for x in version_str.split('.'):
if x.isdigit():
digit_version.append(int(x))
elif x.find('rc') != -1:
patch_version = x.split('rc')
digit_version.append(int(patch_version[0]) - 1)
digit_version.append(int(patch_version[1]))
return digit_version
mmcv_min_version = digit_version(MMCV_MIN)
mmcv_max_version = digit_version(MMCV_MAX)
mmcv_version = digit_version(mmcv.__version__)
assert (mmcv_min_version <= mmcv_version <= mmcv_max_version), \
f'MMCV=={mmcv.__version__} is used but incompatible. ' \
f'Please install mmcv>={mmcv_min_version}, <={mmcv_max_version}.'
__all__ = ['__version__', 'version_info']

View File

@ -7,7 +7,7 @@ import cv2
import mmcv
import torch
import torchvision
from mmcv.utils.parrots_wrapper import get_build_config
from mmcv.utils import get_build_config, get_git_hash
import mmseg
@ -53,7 +53,7 @@ def collect_env():
env_info['OpenCV'] = cv2.__version__
env_info['MMCV'] = mmcv.__version__
env_info['MMSegmentation'] = mmseg.__version__
env_info['MMSegmentation'] = f'{mmseg.__version__}+{get_git_hash()[:7]}'
try:
from mmcv.ops import get_compiler_version, get_compiling_cuda_version
env_info['MMCV Compiler'] = get_compiler_version()

18
mmseg/version.py 100644
View File

@ -0,0 +1,18 @@
# Copyright (c) Open-MMLab. All rights reserved.
__version__ = '0.5.1'
def parse_version_info(version_str):
version_info = []
for x in version_str.split('.'):
if x.isdigit():
version_info.append(int(x))
elif x.find('rc') != -1:
patch_version = x.split('rc')
version_info.append(int(patch_version[0]))
version_info.append(f'rc{patch_version[1]}')
return tuple(version_info)
version_info = parse_version_info(__version__)

View File

@ -1,81 +1,19 @@
import os
import subprocess
import time
from setuptools import find_packages, setup
def readme():
with open('README.md', encoding='utf-8') as f:
content = f.read()
return content
version_file = 'mmseg/version.py'
def get_git_hash():
def _minimal_ext_cmd(cmd):
# construct minimal environment
env = {}
for k in ['SYSTEMROOT', 'PATH', 'HOME']:
v = os.environ.get(k)
if v is not None:
env[k] = v
# LANGUAGE is used on win32
env['LANGUAGE'] = 'C'
env['LANG'] = 'C'
env['LC_ALL'] = 'C'
out = subprocess.Popen(
cmd, stdout=subprocess.PIPE, env=env).communicate()[0]
return out
try:
out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD'])
sha = out.strip().decode('ascii')
except OSError:
sha = 'unknown'
return sha
def get_hash():
if os.path.exists('.git'):
sha = get_git_hash()[:7]
elif os.path.exists(version_file):
try:
from mmseg.version import __version__
sha = __version__.split('+')[-1]
except ImportError:
raise ImportError('Unable to get git version')
else:
sha = 'unknown'
return sha
def write_version_py():
content = """# GENERATED VERSION FILE
# TIME: {}
__version__ = '{}'
short_version = '{}'
version_info = ({})
"""
sha = get_hash()
with open('mmseg/VERSION', 'r') as f:
SHORT_VERSION = f.read().strip()
VERSION_INFO = ', '.join(SHORT_VERSION.split('.'))
VERSION = SHORT_VERSION + '+' + sha
version_file_str = content.format(time.asctime(), VERSION, SHORT_VERSION,
VERSION_INFO)
with open(version_file, 'w') as f:
f.write(version_file_str)
def get_version():
with open(version_file, 'r') as f:
exec(compile(f.read(), version_file, 'exec'))
import sys
# return short version for sdist
if 'sdist' in sys.argv or 'bdist_wheel' in sys.argv:
return locals()['short_version']
else:
return locals()['__version__']
return locals()['__version__']
def parse_requirements(fname='requirements.txt', with_version=True):
@ -155,11 +93,12 @@ def parse_requirements(fname='requirements.txt', with_version=True):
if __name__ == '__main__':
write_version_py()
setup(
name='mmsegmentation',
version=get_version(),
description='Open MMLab Semantic Segmentation Toolbox and Benchmark',
long_description=readme(),
long_description_content_type='text/markdown',
author='MMSegmentation Authors',
author_email='openmmlab@gmail.com',
keywords='computer vision, semantic segmentation',

View File

@ -7,7 +7,7 @@ import time
import mmcv
import torch
from mmcv.runner import init_dist
from mmcv.utils import Config, DictAction
from mmcv.utils import Config, DictAction, get_git_hash
from mmseg import __version__
from mmseg.apis import set_random_seed, train_segmentor
@ -141,7 +141,7 @@ def main():
# save mmseg version, config file content and class names in
# checkpoints as meta data
cfg.checkpoint_config.meta = dict(
mmseg_version=__version__,
mmseg_version=f'{__version__}+{get_git_hash()[:7]}',
config=cfg.pretty_text,
CLASSES=datasets[0].CLASSES,
PALETTE=datasets[0].PALETTE)