Feng Wang commited on
Commit
26524ee
·
1 Parent(s): 07f9669

feat(setup): add pip package code (#1079)

Browse files
README.md CHANGED
@@ -70,20 +70,13 @@ This repo is an implementation of PyTorch version YOLOX, there is also a [MegEng
70
  <details>
71
  <summary>Installation</summary>
72
 
73
- Step1. Install YOLOX.
74
  ```shell
75
  git clone git@github.com:Megvii-BaseDetection/YOLOX.git
76
  cd YOLOX
77
- pip3 install -U pip && pip3 install -r requirements.txt
78
  pip3 install -v -e . # or python3 setup.py develop
79
  ```
80
 
81
- Step2. Install [pycocotools](https://github.com/cocodataset/cocoapi).
82
-
83
- ```shell
84
- pip3 install cython; pip3 install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
85
- ```
86
-
87
  </details>
88
 
89
  <details>
 
70
  <details>
71
  <summary>Installation</summary>
72
 
73
+ Step1. Install YOLOX from source.
74
  ```shell
75
  git clone git@github.com:Megvii-BaseDetection/YOLOX.git
76
  cd YOLOX
 
77
  pip3 install -v -e . # or python3 setup.py develop
78
  ```
79
 
 
 
 
 
 
 
80
  </details>
81
 
82
  <details>
exps/default/__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # -*- coding:utf-8 -*-
3
+ # Copyright (c) Megvii, Inc. and its affiliates.
requirements.txt CHANGED
@@ -13,6 +13,8 @@ tabulate
13
  tensorboard
14
 
15
  # verified versions
 
 
16
  onnx==1.8.1
17
  onnxruntime==1.8.0
18
- onnx-simplifier==0.3.5
 
13
  tensorboard
14
 
15
  # verified versions
16
+ # pycocotools corresponds to https://github.com/ppwwyyxx/cocoapi
17
+ pycocotools>=2.0.2
18
  onnx==1.8.1
19
  onnxruntime==1.8.0
20
+ onnx-simplifier==0.3.5
setup.py CHANGED
@@ -8,9 +8,6 @@ from os import path
8
  import torch
9
  from torch.utils.cpp_extension import CppExtension
10
 
11
- torch_ver = [int(x) for x in torch.__version__.split(".")[:2]]
12
- assert torch_ver >= [1, 7], "Requires PyTorch >= 1.7"
13
-
14
 
15
  def get_extensions():
16
  this_dir = path.dirname(path.abspath(__file__))
@@ -40,25 +37,56 @@ def get_extensions():
40
  return ext_modules
41
 
42
 
43
- with open("yolox/__init__.py", "r") as f:
44
- version = re.search(
45
- r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
46
- f.read(), re.MULTILINE
47
- ).group(1)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
 
50
- with open("README.md", "r", encoding="utf-8") as f:
51
- long_description = f.read()
 
 
52
 
53
 
54
  setuptools.setup(
55
  name="yolox",
56
- version=version,
57
- author="basedet team",
 
 
58
  python_requires=">=3.6",
59
- long_description=long_description,
 
 
60
  ext_modules=get_extensions(),
61
- classifiers=["Programming Language :: Python :: 3", "Operating System :: OS Independent"],
 
 
 
62
  cmdclass={"build_ext": torch.utils.cpp_extension.BuildExtension},
63
  packages=setuptools.find_packages(),
 
 
 
 
 
64
  )
 
8
  import torch
9
  from torch.utils.cpp_extension import CppExtension
10
 
 
 
 
11
 
12
  def get_extensions():
13
  this_dir = path.dirname(path.abspath(__file__))
 
37
  return ext_modules
38
 
39
 
40
+ def get_package_dir():
41
+ pkg_dir = {
42
+ "yolox.tools": "tools",
43
+ "yolox.exp.default": "exps/default",
44
+ }
45
+ return pkg_dir
46
+
47
+
48
+ def get_install_requirements():
49
+ with open("requirements.txt", "r", encoding="utf-8") as f:
50
+ reqs = [x.strip() for x in f.read().splitlines()]
51
+ reqs = [x for x in reqs if not x.startswith("#")]
52
+ return reqs
53
+
54
+
55
+ def get_yolox_version():
56
+ with open("yolox/__init__.py", "r") as f:
57
+ version = re.search(
58
+ r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
59
+ f.read(), re.MULTILINE
60
+ ).group(1)
61
+ return version
62
 
63
 
64
+ def get_long_description():
65
+ with open("README.md", "r", encoding="utf-8") as f:
66
+ long_description = f.read()
67
+ return long_description
68
 
69
 
70
  setuptools.setup(
71
  name="yolox",
72
+ version=get_yolox_version(),
73
+ author="megvii basedet team",
74
+ url="https://github.com/Megvii-BaseDetection/YOLOX",
75
+ package_dir=get_package_dir(),
76
  python_requires=">=3.6",
77
+ install_requires=get_install_requirements(),
78
+ long_description=get_long_description(),
79
+ long_description_content_type="text/markdown",
80
  ext_modules=get_extensions(),
81
+ classifiers=[
82
+ "Programming Language :: Python :: 3", "Operating System :: OS Independent",
83
+ "License :: OSI Approved :: Apache Software License",
84
+ ],
85
  cmdclass={"build_ext": torch.utils.cpp_extension.BuildExtension},
86
  packages=setuptools.find_packages(),
87
+ project_urls={
88
+ "Documentation": "https://yolox.readthedocs.io",
89
+ "Source": "https://github.com/Megvii-BaseDetection/YOLOX",
90
+ "Tracker": "https://github.com/Megvii-BaseDetection/YOLOX/issues",
91
+ },
92
  )
tools/__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # -*- coding:utf-8 -*-
3
+ # Copyright (c) Megvii, Inc. and its affiliates.
yolox/__init__.py CHANGED
@@ -5,4 +5,4 @@ from .utils import configure_module
5
 
6
  configure_module()
7
 
8
- __version__ = "0.1.0"
 
5
 
6
  configure_module()
7
 
8
+ __version__ = "0.2.0"
yolox/utils/dist.py CHANGED
@@ -100,11 +100,13 @@ def get_local_rank() -> int:
100
  Returns:
101
  The rank of the current process within the local (per-machine) process group.
102
  """
 
 
 
103
  if not dist.is_available():
104
  return 0
105
  if not dist.is_initialized():
106
  return 0
107
- assert _LOCAL_PROCESS_GROUP is not None
108
  return dist.get_rank(group=_LOCAL_PROCESS_GROUP)
109
 
110
 
 
100
  Returns:
101
  The rank of the current process within the local (per-machine) process group.
102
  """
103
+ if _LOCAL_PROCESS_GROUP is None:
104
+ return get_rank()
105
+
106
  if not dist.is_available():
107
  return 0
108
  if not dist.is_initialized():
109
  return 0
 
110
  return dist.get_rank(group=_LOCAL_PROCESS_GROUP)
111
 
112