glenn-jocher commited on
Commit
4c1784b
·
unverified ·
1 Parent(s): 602d7ff

Use contextlib's suppress method to silence an error (#8668)

Browse files
Files changed (1) hide show
  1. models/yolo.py +2 -3
models/yolo.py CHANGED
@@ -7,6 +7,7 @@ Usage:
7
  """
8
 
9
  import argparse
 
10
  import os
11
  import platform
12
  import sys
@@ -259,10 +260,8 @@ def parse_model(d, ch): # model_dict, input_channels(3)
259
  for i, (f, n, m, args) in enumerate(d['backbone'] + d['head']): # from, number, module, args
260
  m = eval(m) if isinstance(m, str) else m # eval strings
261
  for j, a in enumerate(args):
262
- try:
263
  args[j] = eval(a) if isinstance(a, str) else a # eval strings
264
- except NameError:
265
- pass
266
 
267
  n = n_ = max(round(n * gd), 1) if n > 1 else n # depth gain
268
  if m in (Conv, GhostConv, Bottleneck, GhostBottleneck, SPP, SPPF, DWConv, MixConv2d, Focus, CrossConv,
 
7
  """
8
 
9
  import argparse
10
+ import contextlib
11
  import os
12
  import platform
13
  import sys
 
260
  for i, (f, n, m, args) in enumerate(d['backbone'] + d['head']): # from, number, module, args
261
  m = eval(m) if isinstance(m, str) else m # eval strings
262
  for j, a in enumerate(args):
263
+ with contextlib.suppress(NameError):
264
  args[j] = eval(a) if isinstance(a, str) else a # eval strings
 
 
265
 
266
  n = n_ = max(round(n * gd), 1) if n > 1 else n # depth gain
267
  if m in (Conv, GhostConv, Bottleneck, GhostBottleneck, SPP, SPPF, DWConv, MixConv2d, Focus, CrossConv,