Skip to content

Commit 240d7a3

Browse files
authored
[Fix]: convert scale_factors from list to array to prevent torch tensor UserWarning (#7937)
1 parent 73b4e65 commit 240d7a3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

mmdet/models/dense_heads/yolo_head.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import warnings
55

6+
import numpy as np
67
import torch
78
import torch.nn as nn
89
import torch.nn.functional as F
@@ -235,7 +236,8 @@ def get_bboxes(self,
235236
"""
236237
assert len(pred_maps) == self.num_levels
237238
cfg = self.test_cfg if cfg is None else cfg
238-
scale_factors = [img_meta['scale_factor'] for img_meta in img_metas]
239+
scale_factors = np.array(
240+
[img_meta['scale_factor'] for img_meta in img_metas])
239241

240242
num_imgs = len(img_metas)
241243
featmap_sizes = [pred_map.shape[-2:] for pred_map in pred_maps]

mmdet/models/dense_heads/yolox_head.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright (c) OpenMMLab. All rights reserved.
22
import math
33

4+
import numpy as np
45
import torch
56
import torch.nn as nn
67
import torch.nn.functional as F
@@ -249,7 +250,8 @@ def get_bboxes(self,
249250
"""
250251
assert len(cls_scores) == len(bbox_preds) == len(objectnesses)
251252
cfg = self.test_cfg if cfg is None else cfg
252-
scale_factors = [img_meta['scale_factor'] for img_meta in img_metas]
253+
scale_factors = np.array(
254+
[img_meta['scale_factor'] for img_meta in img_metas])
253255

254256
num_imgs = len(img_metas)
255257
featmap_sizes = [cls_score.shape[2:] for cls_score in cls_scores]

0 commit comments

Comments
 (0)