I got mAP from using evaluate(model, testDatasetLoader, device=device) which give
class1+class2+class3+class4 test dataset = 777 img
Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.736
but when I try to use evaluate(model, testDatasetLoader, device=device) with each class dataset I got
class1 test dataset = 213 img
Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.043
class2 test dataset = 188 img
Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.663
class3 test dataset = 176 img
Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.495
class4 test dataset = 200 img
Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.988
after I calculate (0.043+0.663+0.495+0.988)/4=0.54725 which not equal to mAP from class1+class2+class3+class4 test dataset
How can I find AP for each class correctly?
PS: evaluation function from engine.py