Object detection in fast.ai v1

#12

Thanks @msandroid! I am one step further now, again running into an error that seems to come from changes in teh fastai source code…

For anybody working on this, you can use my GIST as a start …

2 Likes

Object Localization (COCO)
(Dien Hoa TRUONG) #13

Thanks @hkristen . So I think play with object detection in fast.ai now is quite difficult because it misses example and the library is still changing. I switch to read last year course with SSD and hope Jeremy will tell something about it in the last session of part 1 v3

0 Likes

#14

No, it won’t be covered until part 2.

4 Likes

(Sebastien Derhy) #15

I think the conv2d_relu can be replaced by conv_layer. Or at least, that’s what I did, and it solved the issue.

I now have a notebook that runs until the learning part (included), but unfortunately, the loss function doesn’t go down when I’m trying to learn :frowning:

One more thing that I had to change in order to make the notebook run was to replace in the FocalLoss definition:

clas_loss = F.binary_cross_entropy_with_logits(clas_pred, encoded_tgt, weights, reduction=‘sum’)

by

weights_no_grad = weights.detach()
clas_loss = F.binary_cross_entropy_with_logits(clas_pred, encoded_tgt, weights_no_grad, reduction=‘sum’)

Otherwise, Pytorch was trying to compute the gradient of the weights and sending an error…

It’s frustrating, I feel like we’re close to making it work !!

3 Likes

(Aaron) #16

I found a working object detection algorithm y’all will find interesting.

4 Likes

Working notebook for Object Detection
(Rohit Singh) #17

@divyansh and I have gotten object detection to work with fastai v1. The dev notebook is at https://github.com/rohitgeo/singleshotdetector

This creates a Dynamic SSD based on the number of grid cells, zoom levels and aspect ratios for the anchor boxes.

We haven’t trained the network fully in the dev notebook… like unfreezing and fine-tuning, and using Focal Loss (which is supported) etc, but are getting good results already. Hope you find it useful!

See Dynamic SSD implementation for fastai v1 for more details.

10 Likes

(Francesco Gianferrari Pini) #18

So the code in fastai v1 for object detection will not be ready until part 2? I see already in the docs the yolov3 architecture… It is not yet 100% ready?

1 Like

#19

There is no YoloV3 in the fastai library and what’s in preparation is Retina Net, but no, it won’t be ready before part 2.

3 Likes

(Pierre Ouannes) #20

I think that what you saw is that darknet is available in the fastai CV model zoo. YOLOv3 uses darknet so that’s why YOLOv3 is mentioned.

0 Likes

(tester) #21

Seems like yolo is more famous. Just for curiosity, why would we pick retina net over yolov3 for lecture? Is retina net easier to teach or other reasons?

0 Likes

(Ben) #22

RetinaNet uses a pretrained ResNet backbone, while Yolov3 uses Darknet53 as a backbone. There is no pretrained Darknet53 model available in fastai, which you would need to implement Yolov3. This is why fastai will use RetinaNet.

FWIW, I tried to load the weights from the original Darknet53 implementation in C into the fastai implementation. I could never get it to quite work. I think the weights were loaded correctly, but since fastai uses a slightly different output layer than the original C implementation, I couldn’t validate it. I’ve since moved on to trying to train fastai Darknet53 on imagenet from scratch. I’ll share my results on the forum when I get the top-1 accuracy into the 70%+ range.

9 Likes

(James Adams) #23

Thanks for this, nice work!

0 Likes

(nick) #24

I have a problem. When I run the code to transfer the pre-training model: learn=create_cnn(…), the code will automatically download the model, but it will be interrupted due to time and network speed, so I download the pre-training model in advance. When you run this code again, it will be stuck here. How can I solve this problem? Please help everyone.

0 Likes

(nick) #25

0 Likes

(andreas) #26

Hi Sgugger,
I am trying to run the dev notebook 102a_coco and I receive the error objectdetectdataset not defined how do I fix this error?
Thanks

0 Likes

(Charm) #27


there are new notebook for retinaNet Objection

1 Like

(Christian Marzahl) #28

Hi,

I tried to put all the pieces for object detection in fast.ai v1 with RetinaNet together.

With kind regrads,
Christian

7 Likes

(Vu Ha) #29

Nice work! Have you tried to train on Pascal VOC and/or COCO datasets and measure mAPs?

0 Likes

(Christian Marzahl) #30

I put everything together to do so including writing a callback for fast.ai, but I´m a little bit short on computational resources to do so.

0 Likes

#31

Thank you very much, this looks great!

My only problem are some imports in:

ObjectDetection/callbacks/callbacks.py

from BoundingBox import BoundingBox
from BoundingBoxes import BoundingBoxes
from Evaluator import *
from utils import *

I’ve never seen those BoundingBox classes before which leads me to think you wrote them yourself and did not commit them.
Also I can’t find Evaluator or utils in the repo.

0 Likes