matterport / Mask_RCNN

Mask R-CNN for object detection and instance segmentation on Keras and TensorFlow
Other
24.58k stars 11.69k forks source link

changing COCO AP scales (small, medium, large) #1354

Open soroushr opened 5 years ago

soroushr commented 5 years ago

According to COCO Evaluation Metrics, APs can be reported based on small, medium and large-scale objects. These AP Scales are strictly predefined as objects smaller than 32x32 to greater than 96x96 pixels.

Now I have three questions: 1) First of all, how can I get such statistics for my own trained model? I tried running python coco.py evaluate --dataset=/my/data/set/ --model=/my/trained/weights.h5 but I get a shape-matching error as Traceback (most recent call last): File "coco.py", line 474, in <module> model.load_weights(model_path, by_name=True) File "/home/soroushr/projects/Mask_RCNN/mrcnn/model.py", line 2130, in load_weights saving.load_weights_from_hdf5_group_by_name(f, layers) File "/home/soroushr/projects/envs/Planet/lib/python3.6/site-packages/keras/engine/saving.py", line 1149, in load_weights_from_hdf5_group_by_name str(weight_values[i].shape) + '.') ValueError: Layer #391 (named "mrcnn_bbox_fc"), weight <tf.Variable 'mrcnn_bbox_fc/kernel:0' shape=(1024, 324) dtype=float32_ref> has shape (1024, 324), but the saved weight has shape (1024, 8). 2) Is there a way to change what is 'large' or 'small' or 'medium'? 3) Can I customize the range and number of scales for which I am getting my APs? For example, assume I want to get APs for objects in scales ranging from ( < 8x8), (8x8 to 32x32), (32x32 to 64x64), (64x64 to 128x128), (128x128 to 256x256), and (256x256 < ). I understand that it requires tuning the RPN_ANCHOR_SCALES to the needs, but assume that is properly taken care of.

Thanks!

tachikoma777 commented 5 years ago

Did you find a way to change what is 'large' or 'small' or 'medium'?

Dorozhko-Anton commented 3 years ago

You can try to customize code to modify this parameter of the COCOeval class

https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocotools/cocoeval.py

 # areaRng    - [...] A=4 object area ranges for evaluation
markmcd commented 3 years ago

Building on @Dorozhko-Anton's answer, check out the Params class at the bottom of cocoeval.py. You can build one, then set self.areaRng to your bounds & pass it to accumulate() when you call it.