Simplify check_requirements() usage (#4855)
* Simplify `check_requirements()` usage * remove assert, print()
This commit is contained in:
1 parent
4d1a2ac87e
commit
4c839eeb10
6 files changed
+9
-6
No files matched your search
+1
-1
@@ -127,7 +127,7 @@ def kmean_anchors(dataset='./data/coco128.yaml', n=9, img_size=640, thr=4.0, gen
|
||||
print(f'{prefix}Running kmeans for {n} anchors on {len(wh)} points...')
|
||||
s = wh.std(0) # sigmas for whitening
|
||||
k, dist = kmeans(wh / s, n, iter=30) # points, mean distance
|
||||
assert len(k) == n, print(f'{prefix}ERROR: scipy.cluster.vq.kmeans requested {n} points but returned only {len(k)}')
|
||||
assert len(k) == n, f'{prefix}ERROR: scipy.cluster.vq.kmeans requested {n} points but returned only {len(k)}'
|
||||
k *= s
|
||||
wh = torch.tensor(wh, dtype=torch.float32) # filtered
|
||||
wh0 = torch.tensor(wh0, dtype=torch.float32) # unfiltered
|
||||
|
||||
+4
-1
@@ -37,6 +37,9 @@ pd.options.display.max_columns = 10
|
||||
cv2.setNumThreads(0) # prevent OpenCV from multithreading (incompatible with PyTorch DataLoader)
|
||||
os.environ['NUMEXPR_MAX_THREADS'] = str(min(os.cpu_count(), 8)) # NumExpr max threads
|
||||
|
||||
FILE = Path(__file__).resolve()
|
||||
ROOT = FILE.parents[1] # YOLOv5 root directory
|
||||
|
||||
|
||||
class Profile(contextlib.ContextDecorator):
|
||||
# Usage: @Profile() decorator or 'with Profile():' context manager
|
||||
@@ -222,7 +225,7 @@ def check_version(current='0.0.0', minimum='0.0.0', name='version ', pinned=Fals
|
||||
|
||||
|
||||
@try_except
|
||||
def check_requirements(requirements='requirements.txt', exclude=(), install=True):
|
||||
def check_requirements(requirements=ROOT / 'requirements.txt', exclude=(), install=True):
|
||||
# Check installed dependencies meet requirements (pass *.txt file or list of packages)
|
||||
prefix = colorstr('red', 'bold', 'requirements:')
|
||||
check_python() # check python version
|
||||
|
||||
Reference in new issue
Block a user