From 3ccc03dbc22ea488c5ce64ff19aa6a9e18c36190 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Wed, 6 Apr 2022 16:03:08 -0400 Subject: [PATCH 1/6] Initial: yolov5 auto package --- MANIFEST.in | 7 +++++++ build_wheel.sh | 5 +++++ pyproject.toml | 3 +++ requirements.txt | 2 +- setup.cfg | 5 ----- setup.py | 31 +++++++++++++++++++++++++++++++ 6 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 MANIFEST.in create mode 100755 build_wheel.sh create mode 100644 pyproject.toml create mode 100644 setup.py diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 000000000000..d13232decca5 --- /dev/null +++ b/MANIFEST.in @@ -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 requirements.txt \ No newline at end of file diff --git a/build_wheel.sh b/build_wheel.sh new file mode 100755 index 000000000000..9756da3c25c7 --- /dev/null +++ b/build_wheel.sh @@ -0,0 +1,5 @@ +python3 -m pip install --upgrade build +mkdir yolov5 +cp -r data models models_v5.0 utils .pre-commit-config.yaml $(ls *.py) yolov5/ +touch yolov5/__init__.py +python3 -m build \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000000..fa7093a33c04 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools>=42"] +build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 36f39017d6af..c6a19e789077 100755 --- a/requirements.txt +++ b/requirements.txt @@ -35,4 +35,4 @@ seaborn>=0.11.0 # pycocotools>=2.0 # COCO mAP # roboflow thop # FLOPs computation -sparseml[torch,torchvision] >= 0.12 \ No newline at end of file +sparseml[torch,torchvision] >= 0.12 diff --git a/setup.cfg b/setup.cfg index 20ea49a8b4d6..9fd769d06a6d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,11 +1,6 @@ # Project-wide configuration file, can be used for package metadata and other toll configurations # Example usage: global configuration for PEP8 (via flake8) setting or default pytest arguments -[metadata] -license_file = LICENSE -description-file = README.md - - [tool:pytest] norecursedirs = .git diff --git a/setup.py b/setup.py new file mode 100644 index 000000000000..16b401bc50de --- /dev/null +++ b/setup.py @@ -0,0 +1,31 @@ +import setuptools + +def read_requirements(): + with open("requirements.txt") as f: + return f.read().splitlines() + +setuptools.setup( + name="yolov5", + version='6.1.0', + author="", + license="GPL", + description="Packaged version of the Yolov5 object detector", + long_description=open("README.md", "r", encoding="utf-8").read(), + long_description_content_type="text/markdown", + url="https://github.com/ultralytics/yolov5", + packages=setuptools.find_packages(), + python_requires=">=3.6", + install_requires=read_requirements(), + include_package_data=True, + 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", + ] +) \ No newline at end of file From 4154b8c2cbbec391712c02b679277f7332714ce9 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Mon, 11 Apr 2022 10:17:59 -0400 Subject: [PATCH 2/6] Update: bash __init__ --- build_wheel.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/build_wheel.sh b/build_wheel.sh index 9756da3c25c7..04a3e9f3b657 100755 --- a/build_wheel.sh +++ b/build_wheel.sh @@ -1,5 +1,10 @@ python3 -m pip install --upgrade build mkdir yolov5 cp -r data models models_v5.0 utils .pre-commit-config.yaml $(ls *.py) yolov5/ -touch yolov5/__init__.py -python3 -m build \ No newline at end of file +cat > yolov5/__init__.py << EOF +from export import run as export +from train import run as train +from val import run as val +EOF +python3 -m build +rm -r yolov5 \ No newline at end of file From 973887da6aae02bc402d4a021fc5f14cb2cc2777 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Tue, 12 Apr 2022 08:35:06 -0400 Subject: [PATCH 3/6] Update: initial working state --- MANIFEST.in | 2 +- build_wheel.sh | 8 ++++---- setup.py | 7 +++++-- utils/general.py | 4 ++++ 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index d13232decca5..0bd8dd226050 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,4 +4,4 @@ include setup.py recursive-include yolov5/data * recursive-include yolov5/models * recursive-include yolov5/models_v5.0 * -include requirements.txt \ No newline at end of file +include yolov5/requirements.txt \ No newline at end of file diff --git a/build_wheel.sh b/build_wheel.sh index 04a3e9f3b657..48e4e309a2f3 100755 --- a/build_wheel.sh +++ b/build_wheel.sh @@ -1,10 +1,10 @@ python3 -m pip install --upgrade build mkdir yolov5 -cp -r data models models_v5.0 utils .pre-commit-config.yaml $(ls *.py) 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 export import run as export -from train import run as train -from val import run as val EOF python3 -m build rm -r yolov5 \ No newline at end of file diff --git a/setup.py b/setup.py index 16b401bc50de..dbf15b263918 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,9 @@ import setuptools +import os def read_requirements(): - with open("requirements.txt") as f: + 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( @@ -13,10 +15,11 @@ def read_requirements(): long_description=open("README.md", "r", encoding="utf-8").read(), long_description_content_type="text/markdown", url="https://github.com/ultralytics/yolov5", - packages=setuptools.find_packages(), + 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)", diff --git a/utils/general.py b/utils/general.py index dcdbf95ddca1..e5b67319a5ee 100755 --- a/utils/general.py +++ b/utils/general.py @@ -405,7 +405,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 From 7e47c987a9947a4c56dc959cb1527f155c2a5b20 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Tue, 12 Apr 2022 08:38:42 -0400 Subject: [PATCH 4/6] Fix: nits --- MANIFEST.in | 2 +- build_wheel.sh | 2 +- pyproject.toml | 2 +- setup.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 0bd8dd226050..5d7fa0864607 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,4 +4,4 @@ include setup.py recursive-include yolov5/data * recursive-include yolov5/models * recursive-include yolov5/models_v5.0 * -include yolov5/requirements.txt \ No newline at end of file +include yolov5/requirements.txt diff --git a/build_wheel.sh b/build_wheel.sh index 48e4e309a2f3..ef2ea7fd96ea 100755 --- a/build_wheel.sh +++ b/build_wheel.sh @@ -7,4 +7,4 @@ sed -i '$d' yolov5/requirements.txt cat > yolov5/__init__.py << EOF EOF python3 -m build -rm -r yolov5 \ No newline at end of file +rm -r yolov5 diff --git a/pyproject.toml b/pyproject.toml index fa7093a33c04..b0f076532a06 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [build-system] requires = ["setuptools>=42"] -build-backend = "setuptools.build_meta" \ No newline at end of file +build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index dbf15b263918..af77dadf9586 100644 --- a/setup.py +++ b/setup.py @@ -31,4 +31,4 @@ def read_requirements(): "Topic :: Education", "Topic :: Scientific/Engineering :: Artificial Intelligence", ] -) \ No newline at end of file +) From 8fca4125e518fc0cd454e50e2cc940d1986c84b2 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Tue, 12 Apr 2022 08:40:33 -0400 Subject: [PATCH 5/6] Fix: nits --- setup.cfg | 5 +++++ setup.py | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 9fd769d06a6d..20ea49a8b4d6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,11 @@ # Project-wide configuration file, can be used for package metadata and other toll configurations # Example usage: global configuration for PEP8 (via flake8) setting or default pytest arguments +[metadata] +license_file = LICENSE +description-file = README.md + + [tool:pytest] norecursedirs = .git diff --git a/setup.py b/setup.py index af77dadf9586..09083e299981 100644 --- a/setup.py +++ b/setup.py @@ -10,8 +10,6 @@ def read_requirements(): name="yolov5", version='6.1.0', author="", - license="GPL", - description="Packaged version of the Yolov5 object detector", long_description=open("README.md", "r", encoding="utf-8").read(), long_description_content_type="text/markdown", url="https://github.com/ultralytics/yolov5", From fb589b9cbb84515811d6a8f588ff3f89bec8a87f Mon Sep 17 00:00:00 2001 From: Konstantin Date: Tue, 12 Apr 2022 12:42:00 -0400 Subject: [PATCH 6/6] Update: include NM_INTEGRATED --- build_wheel.sh | 1 + utils/general.py | 1 + 2 files changed, 2 insertions(+) diff --git a/build_wheel.sh b/build_wheel.sh index ef2ea7fd96ea..d22717596c27 100755 --- a/build_wheel.sh +++ b/build_wheel.sh @@ -5,6 +5,7 @@ grep --include=\*.py -rnl 'yolov5/' -e "from models" | xargs -i@ sed -i 's/from 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 diff --git a/utils/general.py b/utils/general.py index e5b67319a5ee..4d7f64ac7210 100755 --- a/utils/general.py +++ b/utils/general.py @@ -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