Commit
•
b77c8d9
1
Parent(s):
3f3852e
Added `YOLOv5_AUTOINSTALL` environment variable (#7505)
Browse files* Added a way to skip dependency auto-installation.
Setting the environment variable `YOLOv5_AUTOINSTALL=False` will
skip installing any missing dependencies as if the user had passed
`install=False` to `check_requirements`.
* Cleanup
Co-authored-by: Glenn Jocher <[email protected]>
- utils/general.py +2 -1
utils/general.py
CHANGED
@@ -40,6 +40,7 @@ FILE = Path(__file__).resolve()
|
|
40 |
ROOT = FILE.parents[1] # YOLOv5 root directory
|
41 |
DATASETS_DIR = ROOT.parent / 'datasets' # YOLOv5 datasets directory
|
42 |
NUM_THREADS = min(8, max(1, os.cpu_count() - 1)) # number of YOLOv5 multiprocessing threads
|
|
|
43 |
VERBOSE = str(os.getenv('YOLOv5_VERBOSE', True)).lower() == 'true' # global verbose mode
|
44 |
FONT = 'Arial.ttf' # https://ultralytics.com/assets/Arial.ttf
|
45 |
|
@@ -338,7 +339,7 @@ def check_requirements(requirements=ROOT / 'requirements.txt', exclude=(), insta
|
|
338 |
pkg.require(r)
|
339 |
except Exception: # DistributionNotFound or VersionConflict if requirements not met
|
340 |
s = f"{prefix} {r} not found and is required by YOLOv5"
|
341 |
-
if install:
|
342 |
LOGGER.info(f"{s}, attempting auto-update...")
|
343 |
try:
|
344 |
assert check_online(), f"'pip install {r}' skipped (offline)"
|
|
|
40 |
ROOT = FILE.parents[1] # YOLOv5 root directory
|
41 |
DATASETS_DIR = ROOT.parent / 'datasets' # YOLOv5 datasets directory
|
42 |
NUM_THREADS = min(8, max(1, os.cpu_count() - 1)) # number of YOLOv5 multiprocessing threads
|
43 |
+
AUTOINSTALL = str(os.getenv('YOLOv5_AUTOINSTALL', True)).lower() == 'true' # global auto-install mode
|
44 |
VERBOSE = str(os.getenv('YOLOv5_VERBOSE', True)).lower() == 'true' # global verbose mode
|
45 |
FONT = 'Arial.ttf' # https://ultralytics.com/assets/Arial.ttf
|
46 |
|
|
|
339 |
pkg.require(r)
|
340 |
except Exception: # DistributionNotFound or VersionConflict if requirements not met
|
341 |
s = f"{prefix} {r} not found and is required by YOLOv5"
|
342 |
+
if install and AUTOINSTALL: # check environment variable
|
343 |
LOGGER.info(f"{s}, attempting auto-update...")
|
344 |
try:
|
345 |
assert check_online(), f"'pip install {r}' skipped (offline)"
|