keras-cv icon indicating copy to clipboard operation
keras-cv copied to clipboard

Port Faster-RCNN to Backbone API

Open stephentyers1975 opened this issue 2 years ago • 7 comments

Hi,

I'm following the documentation on keras-cv website Faster-RCNN model and i can't seem to import the model. I get the below error:

Screenshot 2023-07-19 at 15 21 03

I can see from the repository that Faster-RCNN seems to be in a legacy folder keras_cv/models/legacy/object_detection. How can i access this within my code as an import.

Forgive me if this is a simple question, I'm pretty new to coding in general and using repo's. I would love to do some testing with Faster-RCNN and I can see your implementation uses ROI-Align instead of pooling which is exactly what I'm looking for. I'm trying to build a custom object detector based on Faster-RCNN but with additional output branches.

Out of interest, why is this classic model marked as legacy??

Many thanks

Steve

stephentyers1975 avatar Jul 19 '23 14:07 stephentyers1975

Hey @stephentyers1975! Thanks for pointing this out. This is how you'll need to implement the code: retina_net = keras_cv.models.legacy.FasterRCNN(num_classes=20, bounding_box_format="xywh", backbone=None)

Reference

The legacy models are the ones that we intend to migrate to the unified KerasNLP/KerasCV API but have not yet had the opportunity yet. Hope that helps!

ID6109 avatar Jul 19 '23 23:07 ID6109

Hi @ID6109, Many thanks for getting back to me quickly. That really helped. Looking through the code, I gather I can't use the pretrained weights from Imagenet or PascalVoc using the from_preset method on the legacy models?

I'll just pass like so:

retina_net = keras_cv.models.legacy.FasterRCNN(num_classes=20, bounding_box_format="xywh", backbone=keras_cv.models.ResNetBackbone.from_preset("resnet50_imagenet"))

As i've noticed from the code that it default uses resnet50 as a backbone.

Also what is the best place for me to ask "How to" type questions?? Is it in the discussions? Many thanks again Steve

stephentyers1975 avatar Jul 20 '23 08:07 stephentyers1975

@stephentyers1975 I think FasterRCNN needs to be migrated before you have a good experience. You cannot use migrated (non-legacy) backbones with a non-legacy model. We just keep the legacy models around as a reminder to migrate.

jbischof avatar Jul 20 '23 18:07 jbischof

@jbischof Sorry I'm a bit confused, did you mean i can't use migrated (non-legacy) backbones with a legacy model? If I look at the legacy model code for Faster RCNN it seems to do just that: self.backbone = backbone or keras_cv.models.ResNet50Backbone()

OR did you mean I can't use the preset backbone "resnet50_imagenet"

Any ETA on migrating Faster RCNN ?

Many thanks Steve

stephentyers1975 avatar Jul 20 '23 19:07 stephentyers1975

@stephentyers1975 it looks like we've updated the model to use migrated backbones, great!

We don't have a timeline for migration but if you're interested it would have huge impact.

jbischof avatar Jul 21 '23 14:07 jbischof

@jbischof Thanks for the reply. Once my Python and TensorFlow skills are better I would definitely consider helping move this model. I'm a bit of a newbie if I’m honest, but I’m getting there.

stephentyers1975 avatar Jul 24 '23 16:07 stephentyers1975

Renaming this issue to reflect that FasterRCNN needs to be ported.

ianstenbit avatar Aug 04 '23 17:08 ianstenbit