kentaroy47 / frcnn-from-scratch-with-keras

:collision:Faster R-CNN from scratch written with Keras
Apache License 2.0
168 stars 107 forks source link

Keyerror using measure_map for custom data using the trained VGG16 model #93

Open sivaramakrishnan-rajaraman opened 4 years ago

sivaramakrishnan-rajaraman commented 4 years ago

I run the measure_map.py using the following syntax:

python measure_map.py -o simple -p test_annotation.txt -n 10 --config_filename config_vgg16.pickle before running the code, i made sure to convert these lines, meant to use for resnet50, to make it compaitble to vgg16 as follows:

num_features = 512
if K.image_dim_ordering() == 'th':
    input_shape_img = (3, None, None)
    input_shape_features = (num_features, None, None)
else:
    input_shape_img = (None, None, 3)
    input_shape_features = (None, None, num_features)

img_input = Input(shape=input_shape_img)
roi_input = Input(shape=(C.num_rois, 4))
feature_map_input = Input(shape=input_shape_features)

Upon running the code, I get the following keyerror KeyError: 'difficult' This results from this piece of code

for gt_box in gt:
        if not gt_box['bbox_matched'] and not gt_box['difficult']:
            if gt_box['class'] not in P:
                P[gt_box['class']] = []
                T[gt_box['class']] = []

            T[gt_box['class']].append(1)
            P[gt_box['class']].append(0)

   return T, P

How to avoid this error?