I am currently encountering a problem, the results of yolov7's test.py and detect.py identifying the same test set are not the same.
How can I make detect.py generate a confusion matrix like test.py when it is executed? I want to see the confusion matrix of detect.py, is this possible?
I have modified the code of yolov7 to generate the confusion matrix, so that the confusion matrix shows the real number instead of the proportion. I thought that when detect.py did not recognize the "B" in the license plate image, the confusion matrix generated using test.py would at least have "1" in the "FN column" of "B", but apparently it doesn't.
Please see attached pictures by the link - i can't post the image in here.
This is test.py confusion matrix:
This is test.py confusion matrix
This is the test set image result of detect.py recognition:
This is the test set image result of detect.py recognition
This is the test set label txt result of detect.py recognition:
This is the test set label txt result of detect.py recognition
This is the test set True label txt:
This is the test set True label txt
Here is the code where I modified yolov7\utils\metrics.py so that it displays real quantities instead of ratios.
Orignal version
def plot(self, save_dir='', names=()):
try:
import seaborn as sn
array = self.matrix / (self.matrix.sum(0).reshape(1, self.nc + 1) + 1E-6) # normalize
array[array < 0.005] = np.nan # don't annotate (would appear as 0.00)
fig = plt.figure(figsize=(12, 9), tight_layout=True)
My version
I just comment out the / (self.matrix.sum(0).reshape(1, self.nc + 1) + 1E-6)
.
def plot(self, save_dir='', names=()):
try:
import seaborn as sn
array = self.matrix #/ (self.matrix.sum(0).reshape(1, self.nc + 1) + 1E-6) # normalize
array[array < 0.005] = np.nan # don't annotate (would appear as 0.00)
fig = plt.figure(figsize=(12, 9), tight_layout=True)