mirror of https://github.com/WongKinYiu/yolov7.git
utils/loss.py minor bug fix (#1344)
* utils/loss.py L.NO 742 * Changed np.int to np.int32 due to deprecation of np.intpull/1229/head^2
parent
48052c42c4
commit
2fdc7f1439
|
@ -1200,7 +1200,7 @@ def pastein(image, labels, sample_labels, sample_images, sample_masks):
|
|||
r_image = cv2.resize(sample_images[sel_ind], (r_w, r_h))
|
||||
temp_crop = image[ymin:ymin+r_h, xmin:xmin+r_w]
|
||||
m_ind = r_mask > 0
|
||||
if m_ind.astype(np.int).sum() > 60:
|
||||
if m_ind.astype(np.int32).sum() > 60:
|
||||
temp_crop[m_ind] = r_image[m_ind]
|
||||
#print(sample_labels[sel_ind])
|
||||
#print(sample_images[sel_ind].shape)
|
||||
|
|
|
@ -219,7 +219,7 @@ def labels_to_class_weights(labels, nc=80):
|
|||
return torch.Tensor()
|
||||
|
||||
labels = np.concatenate(labels, 0) # labels.shape = (866643, 5) for COCO
|
||||
classes = labels[:, 0].astype(np.int) # labels = [class xywh]
|
||||
classes = labels[:, 0].astype(np.int32) # labels = [class xywh]
|
||||
weights = np.bincount(classes, minlength=nc) # occurrences per class
|
||||
|
||||
# Prepend gridpoint count (for uCE training)
|
||||
|
@ -234,7 +234,7 @@ def labels_to_class_weights(labels, nc=80):
|
|||
|
||||
def labels_to_image_weights(labels, nc=80, class_weights=np.ones(80)):
|
||||
# Produces image weights based on class_weights and image contents
|
||||
class_counts = np.array([np.bincount(x[:, 0].astype(np.int), minlength=nc) for x in labels])
|
||||
class_counts = np.array([np.bincount(x[:, 0].astype(np.int32), minlength=nc) for x in labels])
|
||||
image_weights = (class_weights.reshape(1, nc) * class_counts).sum(1)
|
||||
# index = random.choices(range(n), weights=image_weights, k=1) # weight image sample
|
||||
return image_weights
|
||||
|
|
|
@ -739,7 +739,7 @@ class ComputeLossOTA:
|
|||
+ 3.0 * pair_wise_iou_loss
|
||||
)
|
||||
|
||||
matching_matrix = torch.zeros_like(cost, device="cpu")
|
||||
matching_matrix = torch.zeros_like(cost, device=device)
|
||||
|
||||
for gt_idx in range(num_gt):
|
||||
_, pos_idx = torch.topk(
|
||||
|
|
Loading…
Reference in New Issue