Fix 6 Flake8 issues (#6541)
* F541 * F821 * F841 * E741 * E302 * E722 * Apply suggestions from code review * Update general.py * Update datasets.py * Update export.py * Update plots.py * Update plots.py Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
1 parent
e1a6a0b100
commit
cba4303d32
10 files changed
+55
-56
No files matched your search
@@ -49,7 +49,7 @@ def git_describe(path=Path(__file__).parent): # path must be a directory
|
||||
s = f'git -C {path} describe --tags --long --always'
|
||||
try:
|
||||
return subprocess.check_output(s, shell=True, stderr=subprocess.STDOUT).decode()[:-1]
|
||||
except subprocess.CalledProcessError as e:
|
||||
except subprocess.CalledProcessError:
|
||||
return '' # not a git repository
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ def device_count():
|
||||
try:
|
||||
cmd = 'nvidia-smi -L | wc -l'
|
||||
return int(subprocess.run(cmd, shell=True, capture_output=True, check=True).stdout.decode().split()[-1])
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
return 0
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ def profile(input, ops, n=10, device=None):
|
||||
tf, tb, t = 0, 0, [0, 0, 0] # dt forward, backward
|
||||
try:
|
||||
flops = thop.profile(m, inputs=(x,), verbose=False)[0] / 1E9 * 2 # GFLOPs
|
||||
except:
|
||||
except Exception:
|
||||
flops = 0
|
||||
|
||||
try:
|
||||
@@ -135,7 +135,7 @@ def profile(input, ops, n=10, device=None):
|
||||
try:
|
||||
_ = (sum(yi.sum() for yi in y) if isinstance(y, list) else y).sum().backward()
|
||||
t[2] = time_sync()
|
||||
except Exception as e: # no backward method
|
||||
except Exception: # no backward method
|
||||
# print(e) # for debug
|
||||
t[2] = float('nan')
|
||||
tf += (t[1] - t[0]) * 1000 / n # ms per op forward
|
||||
|
||||
Reference in new issue
Block a user