Return smaller array for box_ids, scores, bboxes

Hi there, I’m using gluon and a pretrained ssd model for object detection.

I’m running code similar to this:
from matplotlib import pyplot as plt
import gluoncv
from gluoncv import model_zoo, data, utils

net = model_zoo.get_model('faster_rcnn_resnet50_v1b_voc', pretrained=True)

im_fname = utils.download('https://github.com/dmlc/web-data/blob/master/' +
                      'gluoncv/detection/biking.jpg?raw=true',
                      path='biking.jpg')
x, orig_img = data.transforms.presets.rcnn.load_test(im_fname)

box_ids, scores, bboxes = net(x)
ax = utils.viz.plot_bbox(orig_img, bboxes[0], scores[0], box_ids[0], class_names=net.classes)

plt.show()

When running net(x) a large array of 80000 is returned for box_ids, scores and bboxes. This takes a long time for the model to compute. How can I set it so that a smaller array is returned?

Thanks,
David

You could try changing some of Faster RCNNs parameter e.g. https://github.com/dmlc/gluon-cv/blob/master/gluoncv/model_zoo/faster_rcnn/faster_rcnn.py#L58

I’ve just tried changing nms_topk & post_nms to 5 (from -1 as the default, letting any amount of classes) however it still returns 80000 scores, many of which have a value of -1…

Any suggestions on other parameters I could change?