multi_gpu
This commit is contained in:
parent
f5247b397b
commit
7dba5d0171
8
test.py
8
test.py
|
@ -108,10 +108,10 @@ def test(
|
||||||
correct.append(0)
|
correct.append(0)
|
||||||
|
|
||||||
# Compute Average Precision (AP) per class
|
# Compute Average Precision (AP) per class
|
||||||
AP, AP_class, R, P = ap_per_class(tp=correct,
|
AP, AP_class, R, P = ap_per_class(tp=np.array(correct),
|
||||||
conf=detections[:, 4],
|
conf=detections[:, 4].cpu().numpy(),
|
||||||
pred_cls=detections[:, 6],
|
pred_cls=detections[:, 6].cpu().numpy(),
|
||||||
target_cls=target_cls)
|
target_cls=target_cls.cpu().numpy())
|
||||||
|
|
||||||
# Accumulate AP per class
|
# Accumulate AP per class
|
||||||
AP_accum_count += np.bincount(AP_class, minlength=nC)
|
AP_accum_count += np.bincount(AP_class, minlength=nC)
|
||||||
|
|
|
@ -92,7 +92,7 @@ def weights_init_normal(m):
|
||||||
|
|
||||||
def xyxy2xywh(x):
|
def xyxy2xywh(x):
|
||||||
# Convert bounding box format from [x1, y1, x2, y2] to [x, y, w, h]
|
# Convert bounding box format from [x1, y1, x2, y2] to [x, y, w, h]
|
||||||
y = torch.zeros(x.shape) if x.dtype is torch.float32 else np.zeros(x.shape)
|
y = torch.zeros_like(x) if x.dtype is torch.float32 else np.zeros_like(x)
|
||||||
y[:, 0] = (x[:, 0] + x[:, 2]) / 2
|
y[:, 0] = (x[:, 0] + x[:, 2]) / 2
|
||||||
y[:, 1] = (x[:, 1] + x[:, 3]) / 2
|
y[:, 1] = (x[:, 1] + x[:, 3]) / 2
|
||||||
y[:, 2] = x[:, 2] - x[:, 0]
|
y[:, 2] = x[:, 2] - x[:, 0]
|
||||||
|
@ -102,7 +102,7 @@ def xyxy2xywh(x):
|
||||||
|
|
||||||
def xywh2xyxy(x):
|
def xywh2xyxy(x):
|
||||||
# Convert bounding box format from [x, y, w, h] to [x1, y1, x2, y2]
|
# Convert bounding box format from [x, y, w, h] to [x1, y1, x2, y2]
|
||||||
y = torch.zeros(x.shape) if x.dtype is torch.float32 else np.zeros(x.shape)
|
y = torch.zeros_like(x) if x.dtype is torch.float32 else np.zeros_like(x)
|
||||||
y[:, 0] = (x[:, 0] - x[:, 2] / 2)
|
y[:, 0] = (x[:, 0] - x[:, 2] / 2)
|
||||||
y[:, 1] = (x[:, 1] - x[:, 3] / 2)
|
y[:, 1] = (x[:, 1] - x[:, 3] / 2)
|
||||||
y[:, 2] = (x[:, 0] + x[:, 2] / 2)
|
y[:, 2] = (x[:, 0] + x[:, 2] / 2)
|
||||||
|
@ -134,9 +134,6 @@ def ap_per_class(tp, conf, pred_cls, target_cls):
|
||||||
The average precision as computed in py-faster-rcnn.
|
The average precision as computed in py-faster-rcnn.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# lists/pytorch to numpy
|
|
||||||
tp, conf, pred_cls, target_cls = np.array(tp), np.array(conf), np.array(pred_cls), np.array(target_cls)
|
|
||||||
|
|
||||||
# Sort by objectness
|
# Sort by objectness
|
||||||
i = np.argsort(-conf)
|
i = np.argsort(-conf)
|
||||||
tp, conf, pred_cls = tp[i], conf[i], pred_cls[i]
|
tp, conf, pred_cls = tp[i], conf[i], pred_cls[i]
|
||||||
|
|
Loading…
Reference in New Issue