Skip to content

Commit 26743e6

Browse files
committed
Fix concatenation in , docstring of truths' shape in , infinity in encoded target boxes, zero object detection in , credit to amdegroot#116, amdegroot#144, amdegroot#194
1 parent e128a7b commit 26743e6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

layers/box_utils.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ def center_size(boxes):
2222
Return:
2323
boxes: (tensor) Converted xmin, ymin, xmax, ymax form of boxes.
2424
"""
25-
return torch.cat((boxes[:, 2:] + boxes[:, :2])/2, # cx, cy
26-
boxes[:, 2:] - boxes[:, :2], 1) # w, h
25+
return torch.cat(((boxes[:, 2:] + boxes[:, :2])/2, # cx, cy
26+
boxes[:, 2:] - boxes[:, :2]), 1) # w, h
2727

2828

2929
def intersect(box_a, box_b):
@@ -74,7 +74,7 @@ def match(threshold, truths, priors, variances, labels, loc_t, conf_t, idx):
7474
corresponding to both confidence and location preds.
7575
Args:
7676
threshold: (float) The overlap threshold used when mathing boxes.
77-
truths: (tensor) Ground truth boxes, Shape: [num_obj, num_priors].
77+
truths: (tensor) Ground truth boxes, Shape: [num_obj, 4].
7878
priors: (tensor) Prior boxes from priorbox layers, Shape: [n_priors,4].
7979
variances: (tensor) Variances corresponding to each prior coord,
8080
Shape: [num_priors, 4].
@@ -131,7 +131,7 @@ def encode(matched, priors, variances):
131131
g_cxcy /= (variances[0] * priors[:, 2:])
132132
# match wh / prior wh
133133
g_wh = (matched[:, 2:] - matched[:, :2]) / priors[:, 2:]
134-
g_wh = torch.log(g_wh) / variances[1]
134+
g_wh = torch.log(g_wh + 1e-10) / variances[1]
135135
# return target for smooth_l1_loss
136136
return torch.cat([g_cxcy, g_wh], 1) # [num_priors,4]
137137

@@ -186,7 +186,7 @@ def nms(boxes, scores, overlap=0.5, top_k=200):
186186

187187
keep = scores.new(scores.size(0)).zero_().long()
188188
if boxes.numel() == 0:
189-
return keep
189+
return keep, 0
190190
x1 = boxes[:, 0]
191191
y1 = boxes[:, 1]
192192
x2 = boxes[:, 2]

0 commit comments

Comments
 (0)