updates
This commit is contained in:
parent
324f860235
commit
cf54fa7468
|
@ -236,7 +236,9 @@ class LoadImagesAndLabels(Dataset): # for training/testing
|
||||||
nL = len(labels) # number of labels
|
nL = len(labels) # number of labels
|
||||||
if nL:
|
if nL:
|
||||||
# convert xyxy to xywh
|
# convert xyxy to xywh
|
||||||
labels[:, 1:5] = xyxy2xywh(labels[:, 1:5]) / self.img_size
|
labels[:, 1:5] = xyxy2xywh(labels[:, 1:5])
|
||||||
|
labels[:, [2, 4]] /= img.shape[0] # height
|
||||||
|
labels[:, [1, 3]] /= img.shape[1] # width
|
||||||
|
|
||||||
if self.augment:
|
if self.augment:
|
||||||
# random left-right flip
|
# random left-right flip
|
||||||
|
|
|
@ -500,13 +500,14 @@ def plot_images(imgs, targets, fname='images.jpg'):
|
||||||
targets = targets.cpu().numpy()
|
targets = targets.cpu().numpy()
|
||||||
|
|
||||||
fig = plt.figure(figsize=(10, 10))
|
fig = plt.figure(figsize=(10, 10))
|
||||||
img_size = imgs.shape[3]
|
bs, _, h, w = imgs.shape # batch size, _, height, width
|
||||||
bs = imgs.shape[0] # batch size
|
ns = np.ceil(bs ** 0.5) # number of subplots
|
||||||
sp = np.ceil(bs ** 0.5) # subplots
|
|
||||||
|
|
||||||
for i in range(bs):
|
for i in range(bs):
|
||||||
boxes = xywh2xyxy(targets[targets[:, 0] == i, 2:6]).T * img_size
|
boxes = xywh2xyxy(targets[targets[:, 0] == i, 2:6]).T
|
||||||
plt.subplot(sp, sp, i + 1).imshow(imgs[i].transpose(1, 2, 0))
|
boxes[[0, 2]] *= w
|
||||||
|
boxes[[1, 3]] *= h
|
||||||
|
plt.subplot(ns, ns, i + 1).imshow(imgs[i].transpose(1, 2, 0))
|
||||||
plt.plot(boxes[[0, 2, 2, 0, 0]], boxes[[1, 1, 3, 3, 1]], '.-')
|
plt.plot(boxes[[0, 2, 2, 0, 0]], boxes[[1, 1, 3, 3, 1]], '.-')
|
||||||
plt.axis('off')
|
plt.axis('off')
|
||||||
fig.tight_layout()
|
fig.tight_layout()
|
||||||
|
|
Loading…
Reference in New Issue