From 2fdc7f14395f6532ad05fb3e6970150a6a83d290 Mon Sep 17 00:00:00 2001
From: Rohan Patankar <57869463+rohanpatankar926@users.noreply.github.com>
Date: Mon, 2 Jan 2023 01:59:01 +0530
Subject: [PATCH] utils/loss.py minor bug fix (#1344)

* utils/loss.py L.NO 742

* Changed np.int to np.int32 due to deprecation of np.int
---
 utils/datasets.py | 2 +-
 utils/general.py  | 4 ++--
 utils/loss.py     | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/utils/datasets.py b/utils/datasets.py
index b4e56ad..5fe4f7b 100644
--- a/utils/datasets.py
+++ b/utils/datasets.py
@@ -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)
diff --git a/utils/general.py b/utils/general.py
index 6b7edb3..decdcc6 100644
--- a/utils/general.py
+++ b/utils/general.py
@@ -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
diff --git a/utils/loss.py b/utils/loss.py
index a5b7288..2b1d968 100644
--- a/utils/loss.py
+++ b/utils/loss.py
@@ -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(