Object detection using fastai v2

Note that there’s also another tutorial that provides a more fast-ai (better abstraction) like way to run DETR as well here:

https://lgvaz.github.io/mantisshrimp/tutorials/hub_detr_finetune_wheat.html

In my colab I’m trying to stick as close to raw DETR codebase so it’s pretty low level, vs the above is quite elegant in it’s own purpose of providing a friendlier set of abstractions, so two different aspects on working with DETR.

6 Likes

Thanks for sharing @LessW2020 :heart:

We also just finished a self contained colab notebook

This one install all the dependencies and automatically downloads the dataset, just like fastai does :smile:

I hope it’s helpful for anyone starting to explore Detr

7 Likes

I am unable to acces your notebooks/codes are they still available? I am planning on implementing a DETR for image sequences.

The github.io and the colab notebook are unavailable right now. Have the locations changed? Thanks for your help!

@tcapelle and @shimsan, here is the repo and here a quickstart :smiley:

Feel free to ask any questions

3 Likes

Thank you for sharing this. Is it resource hungry ? Will it work on CPU’s ?

@igvaz,I love what you are doing with the icevision library! I was curious if you planning on adding detr, back into the icevision library?

Hi @j.laute,

I am trying to run your notebook “06_Object_Detection_changed”, but it seems there is an issue with the bounding boxes when doing image resizing.

When I remove the resizing (item_tfms = [] (and add unique=True to show_results so that it doesn’t crash, everything works well.

image

However, as soon as I add the resizing (item_tfms = [Resize(224)]), the data loader seems to fail:

image

Btw, I think the same problem happens in @muellerzr’s original notebook when you resize to something else than 128 (which is actually the original image size of the TINY_COCO dataset).

Any idea of the reason of this problem, and how to fix it?

Thanks

1 Like

Hi @j.laute,

Not sure if you’re still checking this post, but I’ve been tinkering with fastai2 and object detection and tried using your notebook. Unfortunately I cannot seem to get past 2 errors.

for lookup_idx in range(NUM_CLASSES):
        metrics.append(LookUpMetric(map_metric, dls.vocab[lookup_idx+1], lookup_idx))

I’m getting the error:

AttributeError: ‘str’ object has no attribute ‘stored_args

And if I skip past it and try to run learn.fit_one_cycle(), I get this error:

TypeError: is_floating_point(): argument ‘input’ (position 1) must be Tensor, not int

I’m not sure if the two are connected. Does anyone have any ideas of what I can do next/where I can look at modifying some code?

Hi all!
Last week, I started walking with fastai😊
I have a question today. How can I make a predition using trained model in this notebook(https://colab.research.google.com/github/muellerzr/Practical-Deep-Learning-for-Coders-2.0/blob/master/Computer%20Vision/06_Object_Detection.ipynb).
I know that there were some discussions why “predict” or “get_preds” do not work. But they were done a half years ago. So I’d like to know the latest information in Jan 2021. Thanks.

2 Likes

I haven’t worked on this at all. Personally, I would use the IceVision library instead, as it’s a much more fleshed out object detection library for fastai.

2 Likes

Thanks for your quick response!
IceVision seems really nice🤗I’ll try it.

1 Like

I tested this implementation and managed to get it running. However it seems that there is something wrong with the RetinaNet or other part of the code, as I also couldn’t train it to acceptable results (mAP didn’t exceed 20%).

I haven’t worked on this at all. Personally, I would use the IceVision library instead, as it’s a much more fleshed out object detection library for fastai.

This is a great library! Object detection works out of the box. Here is a comparison of my struggles with training raw RetinaNet vs. efficientdet from icevision.
image

3 Likes

thanks for the suggestion

Can anyone please help me? while using learn.fit_sgdr , it gives an error of
AttributeError: ‘Learner’ object has no attribute ‘fit_sgdr’
I have used this package for installation
!pip install -U object-detection-fastai

from object_detection_fastai.helper.wsi_loader import *

from object_detection_fastai.loss.RetinaNetFocalLoss import RetinaNetFocalLoss

from object_detection_fastai.models.RetinaNet import RetinaNet

from object_detection_fastai.callbacks.callbacks import BBMetrics, PascalVOCMetricByDistance, PascalVOCMetric, PascalVOCMetricByDistance
if I try using fastai --upgrade it asks for restarting the runtime which is obvious, but I’m not able to use both in same notebook.
i need the object detection package for the earlier part of code for loading the MIDOG 2021 data , I cant use any other option for that .
but I need to use sgdr training too which I am not able to perform in jupyter notebook.
All suggestions are welcome .