Unverified 提交 0be58f16 authored 作者: NauchtanRobotics's avatar NauchtanRobotics 提交者: GitHub

Adjust legend labels for classes without instances (#5174)

* legend-labels Adjust legend labels for classes without instances. * #5158 Re-indexed series names: only classes containing data. * #5158 Re-indexed series names: only classes containing data. * Cleanup Co-authored-by: 's avatarGlenn Jocher <glenn.jocher@ultralytics.com>
上级 1172ac15
...@@ -71,6 +71,8 @@ def ap_per_class(tp, conf, pred_cls, target_cls, plot=False, save_dir='.', names ...@@ -71,6 +71,8 @@ def ap_per_class(tp, conf, pred_cls, target_cls, plot=False, save_dir='.', names
# Compute F1 (harmonic mean of precision and recall) # Compute F1 (harmonic mean of precision and recall)
f1 = 2 * p * r / (p + r + 1e-16) f1 = 2 * p * r / (p + r + 1e-16)
names = [v for k, v in names.items() if k in unique_classes] # list: only classes that have data
names = {i: v for i, v in enumerate(names)} # to dict
if plot: if plot:
plot_pr_curve(px, py, ap, Path(save_dir) / 'PR_curve.png', names) plot_pr_curve(px, py, ap, Path(save_dir) / 'PR_curve.png', names)
plot_mc_curve(px, f1, Path(save_dir) / 'F1_curve.png', names, ylabel='F1') plot_mc_curve(px, f1, Path(save_dir) / 'F1_curve.png', names, ylabel='F1')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论