diff --git a/yolort/v5/utils/datasets.py b/yolort/v5/utils/datasets.py index a9baa57d..330304f1 100644 --- a/yolort/v5/utils/datasets.py +++ b/yolort/v5/utils/datasets.py @@ -74,7 +74,7 @@ def exif_size(img): s = (s[1], s[0]) elif rotation == 8: # rotation 90 s = (s[1], s[0]) - except KeyError: + except AttributeError: pass return s @@ -368,7 +368,7 @@ def __init__( assert cache["version"] == 0.4 and cache["hash"] == get_hash( self.label_files + self.img_files ) - except AssertionError: + except FileNotFoundError: cache, exists = self.cache_labels(cache_path, prefix), False # cache # Display cache diff --git a/yolort/v5/utils/torch_utils.py b/yolort/v5/utils/torch_utils.py index 01ddf89c..3aa721ee 100644 --- a/yolort/v5/utils/torch_utils.py +++ b/yolort/v5/utils/torch_utils.py @@ -155,11 +155,11 @@ def profile(input, ops, n=10, device=None): ) # dt forward, backward tf, tb, t = 0.0, 0.0, [0.0, 0.0, 0.0] - try: + if thop is None: + flops = 0 + else: # GFLOPs flops = thop.profile(m, inputs=(x,), verbose=False)[0] / 1e9 * 2 - except ImportError: - flops = 0 try: for _ in range(n):