Object Detection


I am working on 1 class object detection problem. I want to use Fastai api for this. But I could not find a example that I can run. My setup is:

=== Software ===
python : 3.6.8
fastai : 1.0.54
fastprogress : 0.1.21
torch : 1.2.0.dev20190622
nvidia driver : 418.56
torch cuda : 10.0.130 / is available
torch cudnn : 7501 / is enabled

I tried following example without any luck:


Can anyone guide me on Object Detection example that runs on fastai 1.0.54 version?

Well I did some experiment on 1.0.5x, you can check it out.

For SSD one, I reimplemented everything based on 2018 part2. so if you have questions, you can always watch part 2 2018 to figure out what’s going on. (It is a re-implementation of SSD 2018 but on v1)

I did my own Retina net, with bounding box and loss function with 2018 video. You can also check it out. I also posted a not well written medium post… you can also check it out

SSD with v1:

Retina Net with v1:


Hope it helps :slight_smile:


Thank you for your reply with the implementation of SSD and RetinaNet. I am running your RetinaNet notebook. I changed the dataset to URLs.COCO_TINY and I changed image size to 224 data = get_data(64,224) to quick test. But I am getting the following error. The error is from act_to_bbox function. The anchor and activation shape do not match.

anchor shape: torch.Size([3069, 4])
activation shape: torch.Size([9441, 4])

Can you guide me what I am doing wrong?

wow, first of all, I would like to say thank you. I never really thought that someone really dig inside to run my code… I probably should document and finish my code in a better way.

Yes, I think the problem happened because I hard code the feature map size (Retina Net, the SSD was too long ago, I really have to think what I did)

Here is what I meant:

  1. Retina Net use FPN, you will need to find the filter size from C3-C5. In order to get right filter size, you will need to know the input image size. Therefore, if you change the input size as my notebook, you will have to change the filter size

     anc_grids = [32,16,8,4,2]

This line here tells the model to calculate the anchor boxes based on the different filter size. As input of the image size 256, you have C3 = 32, C4 = 16 and so on

  1. So the question become how to find right filter size

    encoder = create_body(models.resnet50,cut=-2)
    sfs_szs = model_sizes(encoder,size=(256,256))

This is where this lines coming in.
a. Use fastai create_body to create encoder. remove the head
b. model sizes tells you where the different sizes are, you just have to tell your image size, in your case (224,224)
c. change the anc_grids accordingly.

You should get things going. You can double check if the anchor boxes now are 9441 instead of 3069

I hope this helps.

And thank you so much running my code, next time I will make sure even is some dev notebooks they will be well documented.


1 Like