h94 commited on
Commit
577f298
·
unverified ·
1 Parent(s): b6ed110

plot_images() scale bug fix (#1566)

Browse files
Files changed (1) hide show
  1. utils/plots.py +6 -3
utils/plots.py CHANGED
@@ -141,9 +141,12 @@ def plot_images(images, targets, paths=None, fname='images.jpg', names=None, max
141
  labels = image_targets.shape[1] == 6 # labels if no conf column
142
  conf = None if labels else image_targets[:, 6] # check for confidence presence (label vs pred)
143
 
144
- if boxes.shape[1] and boxes.max() <= 1: # if normalized
145
- boxes[[0, 2]] *= w # scale to pixels
146
- boxes[[1, 3]] *= h
 
 
 
147
  boxes[[0, 2]] += block_x
148
  boxes[[1, 3]] += block_y
149
  for j, box in enumerate(boxes.T):
 
141
  labels = image_targets.shape[1] == 6 # labels if no conf column
142
  conf = None if labels else image_targets[:, 6] # check for confidence presence (label vs pred)
143
 
144
+ if boxes.shape[1]:
145
+ if boxes.max() <= 1: # if normalized
146
+ boxes[[0, 2]] *= w # scale to pixels
147
+ boxes[[1, 3]] *= h
148
+ elif scale_factor < 1: # absolute coords need scale if image scales
149
+ boxes *= scale_factor
150
  boxes[[0, 2]] += block_x
151
  boxes[[1, 3]] += block_y
152
  for j, box in enumerate(boxes.T):