diff --git a/yolort/v5/utils/autoanchor.py b/yolort/v5/utils/autoanchor.py index 82d12440..530ff388 100644 --- a/yolort/v5/utils/autoanchor.py +++ b/yolort/v5/utils/autoanchor.py @@ -147,9 +147,9 @@ def print_results(k): print(f"{prefix}Running kmeans for {n} anchors on {len(wh)} points...") s = wh.std(0) # sigmas for whitening k, dist = kmeans(wh / s, n, iter=30) # points, mean distance - assert len(k) == n, ( - f"{prefix}ERROR: scipy.cluster.vq.kmeans requested {n} points but returned only {len(k)}" - ) + assert ( + len(k) == n + ), f"{prefix}ERROR: scipy.cluster.vq.kmeans requested {n} points but returned only {len(k)}" k *= s wh = torch.tensor(wh, dtype=torch.float32) # filtered wh0 = torch.tensor(wh0, dtype=torch.float32) # unfiltered diff --git a/yolort/v5/utils/datasets.py b/yolort/v5/utils/datasets.py index 3a24898a..1a84c8d6 100644 --- a/yolort/v5/utils/datasets.py +++ b/yolort/v5/utils/datasets.py @@ -362,9 +362,9 @@ def __init__( tqdm(None, desc=prefix + d, total=n, initial=n) # display cache results if cache["msgs"]: logging.info("\n".join(cache["msgs"])) # display warnings - assert nf > 0 or not augment, ( - f"{prefix}No labels in {cache_path}. Can not train without labels. See {HELP_URL}" - ) + assert ( + nf > 0 or not augment + ), f"{prefix}No labels in {cache_path}. Can not train without labels. See {HELP_URL}" # Read cache [cache.pop(k) for k in ("hash", "version", "msgs")] # remove items diff --git a/yolort/v5/utils/general.py b/yolort/v5/utils/general.py index 7cbbf77d..cc44b97e 100644 --- a/yolort/v5/utils/general.py +++ b/yolort/v5/utils/general.py @@ -515,9 +515,9 @@ def non_max_suppression( xc = prediction[..., 4] > conf_thres # candidates # Checks - assert 0 <= conf_thres <= 1, ( - f"Invalid Confidence threshold {conf_thres}, valid values are between 0.0 and 1.0" - ) + assert ( + 0 <= conf_thres <= 1 + ), f"Invalid Confidence threshold {conf_thres}, valid values are between 0.0 and 1.0" assert 0 <= iou_thres <= 1, f"Invalid IoU {iou_thres}, valid values are between 0.0 and 1.0" # Settings diff --git a/yolort/v5/utils/torch_utils.py b/yolort/v5/utils/torch_utils.py index 566e43c4..54f4a8d0 100644 --- a/yolort/v5/utils/torch_utils.py +++ b/yolort/v5/utils/torch_utils.py @@ -308,9 +308,7 @@ def model_info(model, verbose=False, img_size=640): except (ImportError, Exception): fs = "" - LOGGER.info( - f"Model Summary: {len(list(model.modules()))} layers, {n_p} parameters, {n_g} gradients{fs}" - ) + LOGGER.info(f"Model Summary: {len(list(model.modules()))} layers, {n_p} parameters, {n_g} gradients{fs}") def load_classifier(name="resnet101", n=2):