Replace 'ground truth' with 'labels' (#1337)
* Replace 'ground truth' with 'labels' * Using torch... update
This commit is contained in:
1 parent
1c8464e199
commit
67bf9a974e
4 files changed
+19
-19
No files matched your search
+8
-8
@@ -275,10 +275,10 @@ def ap_per_class(tp, conf, pred_cls, target_cls, plot=False, fname='precision-re
|
||||
ap, p, r = np.zeros(s), np.zeros(s), np.zeros(s)
|
||||
for ci, c in enumerate(unique_classes):
|
||||
i = pred_cls == c
|
||||
n_gt = (target_cls == c).sum() # Number of ground truth objects
|
||||
n_p = i.sum() # Number of predicted objects
|
||||
n_l = (target_cls == c).sum() # number of labels
|
||||
n_p = i.sum() # number of predictions
|
||||
|
||||
if n_p == 0 or n_gt == 0:
|
||||
if n_p == 0 or n_l == 0:
|
||||
continue
|
||||
else:
|
||||
# Accumulate FPs and TPs
|
||||
@@ -286,7 +286,7 @@ def ap_per_class(tp, conf, pred_cls, target_cls, plot=False, fname='precision-re
|
||||
tpc = tp[i].cumsum(0)
|
||||
|
||||
# Recall
|
||||
recall = tpc / (n_gt + 1e-16) # recall curve
|
||||
recall = tpc / (n_l + 1e-16) # recall curve
|
||||
r[ci] = np.interp(-pr_score, -conf[i], recall[:, 0]) # r at pr_score, negative x, xp because xp decreases
|
||||
|
||||
# Precision
|
||||
@@ -1076,8 +1076,8 @@ def plot_images(images, targets, paths=None, fname='images.jpg', names=None, max
|
||||
image_targets = targets[targets[:, 0] == i]
|
||||
boxes = xywh2xyxy(image_targets[:, 2:6]).T
|
||||
classes = image_targets[:, 1].astype('int')
|
||||
gt = image_targets.shape[1] == 6 # ground truth if no conf column
|
||||
conf = None if gt else image_targets[:, 6] # check for confidence presence (gt vs pred)
|
||||
labels = image_targets.shape[1] == 6 # labels if no conf column
|
||||
conf = None if labels else image_targets[:, 6] # check for confidence presence (label vs pred)
|
||||
|
||||
boxes[[0, 2]] *= w
|
||||
boxes[[0, 2]] += block_x
|
||||
@@ -1087,8 +1087,8 @@ def plot_images(images, targets, paths=None, fname='images.jpg', names=None, max
|
||||
cls = int(classes[j])
|
||||
color = color_lut[cls % len(color_lut)]
|
||||
cls = names[cls] if names else cls
|
||||
if gt or conf[j] > 0.3: # 0.3 conf thresh
|
||||
label = '%s' % cls if gt else '%s %.1f' % (cls, conf[j])
|
||||
if labels or conf[j] > 0.3: # 0.3 conf thresh
|
||||
label = '%s' % cls if labels else '%s %.1f' % (cls, conf[j])
|
||||
plot_one_box(box, mosaic, label=label, color=color, line_thickness=tl)
|
||||
|
||||
# Draw image filename labels
|
||||
|
||||
Reference in new issue
Block a user