WongKinYiu / ScaledYOLOv4

Scaled-YOLOv4: Scaling Cross Stage Partial Network
GNU General Public License v3.0
2.02k stars 572 forks source link

How to show Average Precision of Each Class #332

Open Jethro-241 opened 2 years ago

Jethro-241 commented 2 years ago

In our object detection model, there's 2 classes: Paper and Plastic. How can I show the average precision of paper and plastic separately and their mAP?

what exception? All I get is mAP, P, R, etc. like this below: image

What I want to get is this: image

I want to get the average precision

Can you demonstrate it to me? Here's the colab link: https://colab.research.google.com/drive/10KL3fJbImLXmMAw8aSLOLlngQsQ6MG5P?usp=sharing

WongKinYiu commented 2 years ago

for your reference. https://medium.datadriveninvestor.com/how-to-create-custom-coco-data-set-for-object-detection-96ec91958f36

i do not find the test script in your colab.

Jethro-241 commented 2 years ago

do you have an email address so we can send our test.py?

WongKinYiu commented 2 years ago

just prepare coco style gt and make sure it is put in the corresponding location as what in test.py, you will get the expected results.

Jethro-241 commented 2 years ago

what line in your test.py will you see the corresponding location? so we can check it out in your code.

WongKinYiu commented 2 years ago

please install pycocotools and put coco style gt file as https://github.com/WongKinYiu/ScaledYOLOv4/blob/yolov4-large/test.py#L228 and set opt.save_json = True https://github.com/WongKinYiu/ScaledYOLOv4/blob/yolov4-large/test.py#L264

Jethro-241 commented 2 years ago

thanks we will try it right now

qutyyds commented 2 years ago

How did you solve this? I have the same problem, too. i want to see per class but only can see "all". what should i do?

WongKinYiu commented 2 years ago

add following code after https://github.com/WongKinYiu/ScaledYOLOv4/blob/yolov4-large/test.py#L235


            for cid in range(80):
                print(names[cid])
                cocoEval.params.catIds = [coco91class[cid]]
                cocoEval.evaluate()
                cocoEval.accumulate()
                cocoEval.summarize()