Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# base ----------------------------------------
matplotlib>=3.2.2
numpy>=1.18.5
numpy==1.23.0
opencv-python>=4.1.2
Pillow
PyYAML>=5.3.1
Expand Down
6 changes: 3 additions & 3 deletions utils/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def __init__(self, path, img_size=640, batch_size=16, augment=False, hyp=None, r
x[:, 0] = 0

n = len(shapes) # number of images
bi = np.floor(np.arange(n) / batch_size).astype(np.int) # batch index
bi = np.floor(np.arange(n) / batch_size).astype(np.int32) # batch index
nb = bi[-1] + 1 # number of batches
self.batch = bi # batch index of image
self.n = n
Expand Down Expand Up @@ -436,7 +436,7 @@ def __init__(self, path, img_size=640, batch_size=16, augment=False, hyp=None, r
elif mini > 1:
shapes[i] = [1, 1 / mini]

self.batch_shapes = np.ceil(np.array(shapes) * img_size / stride + pad).astype(np.int) * stride
self.batch_shapes = np.ceil(np.array(shapes) * img_size / stride + pad).astype(np.int32) * stride

# Cache images into memory for faster training (WARNING: large datasets may exceed system RAM)
self.imgs = [None] * n
Expand Down Expand Up @@ -1034,7 +1034,7 @@ def extract_boxes(path='../coco128/'): # from utils.datasets import *; extract_
b = x[1:] * [w, h, w, h] # box
# b[2:] = b[2:].max() # rectangle to square
b[2:] = b[2:] * 1.2 + 3 # pad
b = xywh2xyxy(b.reshape(-1, 4)).ravel().astype(np.int)
b = xywh2xyxy(b.reshape(-1, 4)).ravel().astype(np.int32)

b[[0, 2]] = np.clip(b[[0, 2]], 0, w) # clip boxes outside of image
b[[1, 3]] = np.clip(b[[1, 3]], 0, h)
Expand Down
4 changes: 3 additions & 1 deletion utils/loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ def build_targets(self, p, targets):

# Append
a = t[:, 6].long() # anchor indices
indices.append((b, a, gj.clamp_(0, gain[3] - 1), gi.clamp_(0, gain[2] - 1))) # image, anchor, grid indices
gj = gj.long().clamp_(0, int(gain[3] - 1))
gi = gi.long().clamp_(0, int(gain[2] - 1))
indices.append((b, a, gj, gi))
tbox.append(torch.cat((gxy - gij, gwh), 1)) # box
anch.append(anchors[a]) # anchors
tcls.append(c) # class
Expand Down