From f44db0100518c65023095a47e71518c12aa1db90 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 1 Sep 2024 17:35:08 +0200 Subject: [PATCH] PyUpgrade 3.8 updates (#13289) * PyUpgrade 3.8 updates Signed-off-by: Glenn Jocher * Auto-format by https://ultralytics.com/actions --------- Signed-off-by: Glenn Jocher Co-authored-by: UltralyticsAssistant --- classify/predict.py | 2 +- detect.py | 2 +- segment/predict.py | 2 +- utils/metrics.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/classify/predict.py b/classify/predict.py index 33140e9..d77b4af 100644 --- a/classify/predict.py +++ b/classify/predict.py @@ -147,7 +147,7 @@ def run( save_path = str(save_dir / p.name) # im.jpg txt_path = str(save_dir / "labels" / p.stem) + ("" if dataset.mode == "image" else f"_{frame}") # im.txt - s += "%gx%g " % im.shape[2:] # print string + s += "{:g}x{:g} ".format(*im.shape[2:]) # print string annotator = Annotator(im0, example=str(names), pil=True) # Print results diff --git a/detect.py b/detect.py index 57d7787..f404a25 100644 --- a/detect.py +++ b/detect.py @@ -237,7 +237,7 @@ def run( p = Path(p) # to Path save_path = str(save_dir / p.name) # im.jpg txt_path = str(save_dir / "labels" / p.stem) + ("" if dataset.mode == "image" else f"_{frame}") # im.txt - s += "%gx%g " % im.shape[2:] # print string + s += "{:g}x{:g} ".format(*im.shape[2:]) # print string gn = torch.tensor(im0.shape)[[1, 0, 1, 0]] # normalization gain whwh imc = im0.copy() if save_crop else im0 # for save_crop annotator = Annotator(im0, line_width=line_thickness, example=str(names)) diff --git a/segment/predict.py b/segment/predict.py index 0bccaaa..40f7623 100644 --- a/segment/predict.py +++ b/segment/predict.py @@ -164,7 +164,7 @@ def run( p = Path(p) # to Path save_path = str(save_dir / p.name) # im.jpg txt_path = str(save_dir / "labels" / p.stem) + ("" if dataset.mode == "image" else f"_{frame}") # im.txt - s += "%gx%g " % im.shape[2:] # print string + s += "{:g}x{:g} ".format(*im.shape[2:]) # print string imc = im0.copy() if save_crop else im0 # for save_crop annotator = Annotator(im0, line_width=line_thickness, example=str(names)) if len(det): diff --git a/utils/metrics.py b/utils/metrics.py index 85c1a70..e8dc9df 100644 --- a/utils/metrics.py +++ b/utils/metrics.py @@ -347,7 +347,7 @@ def plot_pr_curve(px, py, ap, save_dir=Path("pr_curve.png"), names=()): else: ax.plot(px, py, linewidth=1, color="grey") # plot(recall, precision) - ax.plot(px, py.mean(1), linewidth=3, color="blue", label="all classes %.3f mAP@0.5" % ap[:, 0].mean()) + ax.plot(px, py.mean(1), linewidth=3, color="blue", label=f"all classes {ap[:, 0].mean():.3f} mAP@0.5") ax.set_xlabel("Recall") ax.set_ylabel("Precision") ax.set_xlim(0, 1)