From 4c1784bd158d3215aa7170b33578e1032442a160 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Thu, 21 Jul 2022 23:12:49 +0200 Subject: [PATCH] Use contextlib's suppress method to silence an error (#8668) --- models/yolo.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/models/yolo.py b/models/yolo.py index 02660e6c4130..56846815e08a 100644 --- a/models/yolo.py +++ b/models/yolo.py @@ -7,6 +7,7 @@ """ import argparse +import contextlib import os import platform import sys @@ -259,10 +260,8 @@ def parse_model(d, ch): # model_dict, input_channels(3) for i, (f, n, m, args) in enumerate(d['backbone'] + d['head']): # from, number, module, args m = eval(m) if isinstance(m, str) else m # eval strings for j, a in enumerate(args): - try: + with contextlib.suppress(NameError): args[j] = eval(a) if isinstance(a, str) else a # eval strings - except NameError: - pass n = n_ = max(round(n * gd), 1) if n > 1 else n # depth gain if m in (Conv, GhostConv, Bottleneck, GhostBottleneck, SPP, SPPF, DWConv, MixConv2d, Focus, CrossConv,