From 577f298d9b1a0e3874f685f54d641ac09a3cad3d Mon Sep 17 00:00:00 2001 From: Hu Ye Date: Tue, 1 Dec 2020 18:29:59 +0800 Subject: [PATCH] plot_images() scale bug fix (#1566) fix bugs in plot_images --- utils/plots.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/utils/plots.py b/utils/plots.py index 55ecf7b1325d..9095d02f6f56 100644 --- a/utils/plots.py +++ b/utils/plots.py @@ -141,9 +141,12 @@ def plot_images(images, targets, paths=None, fname='images.jpg', names=None, max labels = image_targets.shape[1] == 6 # labels if no conf column conf = None if labels else image_targets[:, 6] # check for confidence presence (label vs pred) - if boxes.shape[1] and boxes.max() <= 1: # if normalized - boxes[[0, 2]] *= w # scale to pixels - boxes[[1, 3]] *= h + if boxes.shape[1]: + if boxes.max() <= 1: # if normalized + boxes[[0, 2]] *= w # scale to pixels + boxes[[1, 3]] *= h + elif scale_factor < 1: # absolute coords need scale if image scales + boxes *= scale_factor boxes[[0, 2]] += block_x boxes[[1, 3]] += block_y for j, box in enumerate(boxes.T):