TP=np.diag(confusion_matrix)FP=np.sum(confusion_matrix,axis=0)-TPFN=np.sum(confusion_matrix,axis=1)-TPprecision=TP/(TP+FP)recall=TP/(TP+FN)average_precision=np.mean(precision[:-1])average_recall=np.mean(recall[:-1])f1=2*(average_precision*average_recall)/(average_precision+average_recall)print('\n===Averaging all classes===')print('AP:',average_precision)print('AR:',average_recall)print('F1:',f1)print('Classes',dataset.metainfo['classes']+('background',))print('Precision',precision)print('Recall',recall)