问题:YOLOv5训练时会产生label.jpg的图片,如下所示。但是看不到具体列别的实例数据,在写论文的时候需要此数据描述数据集。
需要更多程序资料以及答疑欢迎大家关注——微信公众号:人工智能AI算法工程师
解决方法:在plot.py中增加打印实例数据的代码,具体代码如下所示
def plot_labels(labels, names=(), save_dir=Path('')):
# plot dataset labels
LOGGER.info(f"Plotting labels to {save_dir / 'labels.jpg'}... ")
#实例
x=np.array(labels)
print("总实例数:",x.shape[0])
#实例
c, b = labels[:, 0], labels[:, 1:].transpose() # classes, boxes
nc = int(c.max() + 1) # number of classes
x = pd.DataFrame(b.transpose(), columns=['x', 'y', 'width', 'height'])
# seaborn correlogram
sn.pairplot(x, corner=True, diag_kind='auto', kind='hist', diag_kws=dict(bins=50), plot_kws=dict(pmax=0.9))
plt.savefig(save_dir / 'labels_correlogram.jpg', dpi=200)
plt.close()
# matplotlib labels
matplotlib.use('svg') # faster
ax = plt.subplots(2, 2, figsize=(8, 8), tight_layout=True)[1].ravel()
y = ax[0].hist(c, bins=np.linspace(0, nc, nc + 1) - 0.5, rwidth=0.8)
#实例
print(y)
#实例
添加的代码为:
#实例
x=np.array(labels)
print("总实例数:",x.shape[0])
#实例
#实例
print(y)
#实例
处理结果:运行train.py就可得到总实例数。
需要更多程序资料以及答疑欢迎大家关注——微信公众号:人工智能AI算法工程师
码字不易,觉得有帮助,请点赞关注支持一下吧,后续会出更多的深度学习方向内容,谢谢ღ( ´・ᴗ・` )~~如果有问题欢迎留言或者私信我哦~~