Skip to content

Commit

Permalink
Merge pull request #28 from neuralmagic/auto-package
Browse files Browse the repository at this point in the history
Auto package Yolov5
  • Loading branch information
KSGulin authored Apr 13, 2022
2 parents 7c07fde + fb589b9 commit b6974c9
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 1 deletion.
7 changes: 7 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include *.md
include LICENSE
include setup.py
recursive-include yolov5/data *
recursive-include yolov5/models *
recursive-include yolov5/models_v5.0 *
include yolov5/requirements.txt
11 changes: 11 additions & 0 deletions build_wheel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
python3 -m pip install --upgrade build
mkdir yolov5
cp -r data models models_v5.0 utils .pre-commit-config.yaml $(ls *.py) requirements.txt yolov5/
grep --include=\*.py -rnl 'yolov5/' -e "from models" | xargs -i@ sed -i 's/from models/from yolov5.models/g' @
grep --include=\*.py -rnl 'yolov5/' -e "from utils" | xargs -i@ sed -i 's/from utils/from yolov5.utils/g' @
sed -i '$d' yolov5/requirements.txt
cat > yolov5/__init__.py << EOF
from yolov5.utils.general import NM_INTEGRATED
EOF
python3 -m build
rm -r yolov5
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools>=42"]
build-backend = "setuptools.build_meta"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ seaborn>=0.11.0
# pycocotools>=2.0 # COCO mAP
# roboflow
thop # FLOPs computation
sparseml[torch,torchvision] >= 0.12
sparseml[torch,torchvision] >= 0.12
32 changes: 32 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import setuptools
import os

def read_requirements():
build_dir = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(build_dir, "yolov5", "requirements.txt")) as f:
return f.read().splitlines()

setuptools.setup(
name="yolov5",
version='6.1.0',
author="",
long_description=open("README.md", "r", encoding="utf-8").read(),
long_description_content_type="text/markdown",
url="https://github.com/ultralytics/yolov5",
packages=['yolov5', 'yolov5.models', 'yolov5.utils'],
python_requires=">=3.6",
install_requires=read_requirements(),
include_package_data=True,
package_data={'': ['yolov5/models/*.yaml', 'yolov5/data/*']},
classifiers=[
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Operating System :: OS Independent",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Programming Language :: Python :: 3",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Education",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
]
)
5 changes: 5 additions & 0 deletions utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
NUM_THREADS = min(8, max(1, os.cpu_count() - 1)) # number of YOLOv5 multiprocessing threads
VERBOSE = str(os.getenv('YOLOv5_VERBOSE', True)).lower() == 'true' # global verbose mode
FONT = 'Arial.ttf' # https://ultralytics.com/assets/Arial.ttf
NM_INTEGRATED=True

torch.set_printoptions(linewidth=320, precision=5, profile='long')
np.set_printoptions(linewidth=320, formatter={'float_kind': '{:11.5g}'.format}) # format short g, %precision=5
Expand Down Expand Up @@ -405,7 +406,11 @@ def check_file(file, suffix=''):
return file
else: # search
files = []
if "models_v5.0/" in file:
files.extend(glob.glob(str(ROOT / '**' / file), recursive=True))
for d in 'data', 'models', 'utils': # search directories
if file.startswith(d + os.path.sep):
file = file[len(d)+1:]
files.extend(glob.glob(str(ROOT / d / '**' / file), recursive=True)) # find file
assert len(files), f'File not found: {file}' # assert file was found
assert len(files) == 1, f"Multiple files match '{file}', specify exact path: {files}" # assert unique
Expand Down

0 comments on commit b6974c9

Please sign in to comment.