Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metric-Confidence plots feature addition #2057

Merged
merged 8 commits into from
Jan 28, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cleanup
  • Loading branch information
glenn-jocher committed Jan 27, 2021
commit 3027908d0681e7a1244bdcd85e1e54b249cbcc3a
5 changes: 2 additions & 3 deletions utils/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def ap_per_class(tp, conf, pred_cls, target_cls, plot=False, save_dir='precision

# Create Precision-Recall curve and compute AP for each class
px, py = np.linspace(0, 1, 1000), [] # for plotting
# pr_score = np.linspace(0, 1, 100) # score to evaluate P and R https://github.com/ultralytics/yolov3/issues/898
s = [unique_classes.shape[0], tp.shape[1]] # number class, number iou thresholds (i.e. 10 for mAP0.5...0.95)
ap, p, r = np.zeros(s), np.zeros(s + [1000]), np.zeros(s + [1000])
for ci, c in enumerate(unique_classes):
Expand Down Expand Up @@ -210,9 +209,9 @@ def plot_mc_curve(px, py, save_dir='.', names=(), xlabel='Confidence', ylabel='M

if 0 < len(names) < 21: # display per-class legend if < 21 classes
for i, y in enumerate(py.T):
ax.plot(px, y, linewidth=1, label=f'{names[i]}') # plot(recall, precision)
ax.plot(px, y, linewidth=1, label=f'{names[i]}') # plot(confidence, metric)
else:
ax.plot(px, py, linewidth=1, color='grey') # plot(recall, precision)
ax.plot(px, py, linewidth=1, color='grey') # plot(confidence, metric)

y = py.mean(1)
ax.plot(px, y, linewidth=3, color='blue', label=f'all classes {y.max():.2f} at {px[y.argmax()]:.3f}')
Expand Down