Update TryExcept(msg='...')` (#9261)
This commit is contained in:
1 parent
5d4787baab
commit
15e82d2967
3 files changed
+4
-4
No files matched your search
+2
-2
@@ -9,7 +9,7 @@ import threading
|
|||||||
|
|
||||||
class TryExcept(contextlib.ContextDecorator):
|
class TryExcept(contextlib.ContextDecorator):
|
||||||
# YOLOv5 TryExcept class. Usage: @TryExcept() decorator or 'with TryExcept():' context manager
|
# YOLOv5 TryExcept class. Usage: @TryExcept() decorator or 'with TryExcept():' context manager
|
||||||
def __init__(self, msg='default message here'):
|
def __init__(self, msg=''):
|
||||||
self.msg = msg
|
self.msg = msg
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
@@ -17,7 +17,7 @@ class TryExcept(contextlib.ContextDecorator):
|
|||||||
|
|
||||||
def __exit__(self, exc_type, value, traceback):
|
def __exit__(self, exc_type, value, traceback):
|
||||||
if value:
|
if value:
|
||||||
print(f'{self.msg}: {value}')
|
print(f'{self.msg}{value}')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ def check_anchor_order(m):
|
|||||||
m.anchors[:] = m.anchors.flip(0)
|
m.anchors[:] = m.anchors.flip(0)
|
||||||
|
|
||||||
|
|
||||||
@TryExcept(f'{PREFIX}ERROR:')
|
@TryExcept(f'{PREFIX}ERROR: ')
|
||||||
def check_anchors(dataset, model, thr=4.0, imgsz=640):
|
def check_anchors(dataset, model, thr=4.0, imgsz=640):
|
||||||
# Check anchor fit to data, recompute if necessary
|
# Check anchor fit to data, recompute if necessary
|
||||||
m = model.module.model[-1] if hasattr(model, 'module') else model.model[-1] # Detect()
|
m = model.module.model[-1] if hasattr(model, 'module') else model.model[-1] # Detect()
|
||||||
|
|||||||
+1
-1
@@ -186,7 +186,7 @@ class ConfusionMatrix:
|
|||||||
# fn = self.matrix.sum(0) - tp # false negatives (missed detections)
|
# fn = self.matrix.sum(0) - tp # false negatives (missed detections)
|
||||||
return tp[:-1], fp[:-1] # remove background class
|
return tp[:-1], fp[:-1] # remove background class
|
||||||
|
|
||||||
@TryExcept('WARNING: ConfusionMatrix plot failure')
|
@TryExcept('WARNING: ConfusionMatrix plot failure: ')
|
||||||
def plot(self, normalize=True, save_dir='', names=()):
|
def plot(self, normalize=True, save_dir='', names=()):
|
||||||
import seaborn as sn
|
import seaborn as sn
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user