WongKinYiu / yolov7

Implementation of paper - YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors
GNU General Public License v3.0
13.23k stars 4.18k forks source link

How can I calculate the map,TP,FN and AP by running test.py #962

Open vijjisomu opened 1 year ago

yulin010101 commented 1 year ago

Can you describe the problem specifically? Is there a problem with your running test.py or?

vijjisomu commented 1 year ago

Hi I am running test.py on custom dataset by modifying the coco.yaml as follows val : data/cocoTest1.txt nc:14 names:['person','land_vehicle','ambulance','cart','bicycle','bus','golf_cart','motorcycle','tank','train','truck','car','van','taxi']

Then I am getting the error as follows File "test.py", line 322, in test(opt.data, File "test.py", line 189, in test confusion_matrix.process_batch(predn, torch.cat((labels[:, 0:1], tbox), 1)) File "/mnt/fileserver3/Vijayalakshmi/yolov7-main2/utils/metrics.py", line 165, in process_batch self.matrix[dc, self.nc] += 1 # background FN IndexError: index 32 is out of bounds for axis 0 with size 15

If I keep the number of classes as 80 Then I got the result but I need to calculate map for each class . I tried using verbose but didn't get for all the classes

I had the custom images and labels and predicted labels can I find the map for each class using those

yulin010101 commented 1 year ago

Is your model output also 14 categories?

vijjisomu commented 1 year ago

No I am using the yolov7 default model which is having 80 classes as output I changed nc as 14 here .Do I need to change anywhere else

jfightyr commented 10 months ago

No I am using the yolov7 default model which is having 80 classes as output I changed nc as 14 here .Do I need to change anywhere else

Hello! Do you know how to solve it now? I have encountered the same problem as you