未验证 提交 ca9bc378 编写于 作者: F Feng Wang 提交者: GitHub

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

上级 25f116b3
......@@ -70,20 +70,13 @@ This repo is an implementation of PyTorch version YOLOX, there is also a [MegEng
<details>
<summary>Installation</summary>
Step1. Install YOLOX.
Step1. Install YOLOX from source.
```shell
git clone git@github.com:Megvii-BaseDetection/YOLOX.git
cd YOLOX
pip3 install -U pip && pip3 install -r requirements.txt
pip3 install -v -e . # or python3 setup.py develop
```
Step2. Install [pycocotools](https://github.com/cocodataset/cocoapi).
```shell
pip3 install cython; pip3 install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
```
</details>
<details>
......
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# Copyright (c) Megvii, Inc. and its affiliates.
......@@ -13,6 +13,8 @@ tabulate
tensorboard
# verified versions
# pycocotools corresponds to https://github.com/ppwwyyxx/cocoapi
pycocotools>=2.0.2
onnx==1.8.1
onnxruntime==1.8.0
onnx-simplifier==0.3.5
\ No newline at end of file
onnx-simplifier==0.3.5
......@@ -8,9 +8,6 @@ from os import path
import torch
from torch.utils.cpp_extension import CppExtension
torch_ver = [int(x) for x in torch.__version__.split(".")[:2]]
assert torch_ver >= [1, 7], "Requires PyTorch >= 1.7"
def get_extensions():
this_dir = path.dirname(path.abspath(__file__))
......@@ -40,25 +37,56 @@ def get_extensions():
return ext_modules
with open("yolox/__init__.py", "r") as f:
version = re.search(
r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
f.read(), re.MULTILINE
).group(1)
def get_package_dir():
pkg_dir = {
"yolox.tools": "tools",
"yolox.exp.default": "exps/default",
}
return pkg_dir
def get_install_requirements():
with open("requirements.txt", "r", encoding="utf-8") as f:
reqs = [x.strip() for x in f.read().splitlines()]
reqs = [x for x in reqs if not x.startswith("#")]
return reqs
def get_yolox_version():
with open("yolox/__init__.py", "r") as f:
version = re.search(
r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
f.read(), re.MULTILINE
).group(1)
return version
with open("README.md", "r", encoding="utf-8") as f:
long_description = f.read()
def get_long_description():
with open("README.md", "r", encoding="utf-8") as f:
long_description = f.read()
return long_description
setuptools.setup(
name="yolox",
version=version,
author="basedet team",
version=get_yolox_version(),
author="megvii basedet team",
url="https://github.com/Megvii-BaseDetection/YOLOX",
package_dir=get_package_dir(),
python_requires=">=3.6",
long_description=long_description,
install_requires=get_install_requirements(),
long_description=get_long_description(),
long_description_content_type="text/markdown",
ext_modules=get_extensions(),
classifiers=["Programming Language :: Python :: 3", "Operating System :: OS Independent"],
classifiers=[
"Programming Language :: Python :: 3", "Operating System :: OS Independent",
"License :: OSI Approved :: Apache Software License",
],
cmdclass={"build_ext": torch.utils.cpp_extension.BuildExtension},
packages=setuptools.find_packages(),
project_urls={
"Documentation": "https://yolox.readthedocs.io",
"Source": "https://github.com/Megvii-BaseDetection/YOLOX",
"Tracker": "https://github.com/Megvii-BaseDetection/YOLOX/issues",
},
)
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# Copyright (c) Megvii, Inc. and its affiliates.
......@@ -5,4 +5,4 @@ from .utils import configure_module
configure_module()
__version__ = "0.1.0"
__version__ = "0.2.0"
......@@ -100,11 +100,13 @@ def get_local_rank() -> int:
Returns:
The rank of the current process within the local (per-machine) process group.
"""
if _LOCAL_PROCESS_GROUP is None:
return get_rank()
if not dist.is_available():
return 0
if not dist.is_initialized():
return 0
assert _LOCAL_PROCESS_GROUP is not None
return dist.get_rank(group=_LOCAL_PROCESS_GROUP)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册