Tensorflow HUB - transfer learning for object detection

Hi all,

I am having some trouble with applying transfer learning in object detection models.
The documentation provides a nice tutorial for transfer learning in classification models (إعادة تدريب مصنف الصور  |  TensorFlow Hub). However, I couldn’t find anything similar for the object detection case.

I tried to readapt the object detection tutorial (TensorFlow Hub Object Detection Colab) according to the classification tutorial linked above, but I didn’t manage to progress much and got a bunch of errors that couldn’t solve.
Does anyone have any suggestion in this sense (or can suggest clear tutorials that explain this stuff)?

Thanks :slight_smile:

1 Like

Please note that we are also migrating the detection folder. Read the disclaimer at:


Hi @Bhack, thanks a lot for your reply!

I have been using the tensorflow Object Detection API lately.
There are a few things that I don’t particularly like (absence of Callbacks, for example), and some bugs that arise when trying more custom usages (see for example the bug issue I opened last week: Object detection API - error when finetuning centernet and faster_rcnn models: RuntimeError: Groundtruth tensor weights has not been provided · Issue #10295 · tensorflow/models (github.com)). I also find the code for the models, meta architectures, training, etc. quite obscure (I am not a TF expert), so I was looking for an alternative approach.

I also noticed that the detection folder on the official repo is being deprecated as you are migrating it, and that’s why I was curious to know if there is an alternative approach to transfer learning in object detection that could be used in a similar way to the TF HUB transfer learning for image classification (that I linked in the OP).

If that’s not the case, I guess I’ll have to wait for the official release of object detection :slight_smile:

We had many issues about a pure TFHub approach but I don’t know if we have something in the TFHub roadmap:

@Bhack thanks again!
I somehow missed those issues when I was looking for fine-tuning object detection models in TF Hub.
Do you know if there is any ETA for the new official object detection folder (I suspect the answer is no, but it’s worth asking :P)?

Hi, sorry for being late but as @Bhack mentioned, the Object Detection fine tuning story on TFHub is not perfect. Most of the OD models that were published don’t have the proper api to be fine tuned easily (like the image classification ones you mentioned)

Depending on the project you’re building, I’d suggest you try Model Maker (TensorFlow Lite Model Maker를 사용한 객체 감지) as it’s the simplest solution you’ll find

1 Like

I have tried to use this example for custom object detection… and I get the following error…
—> 60 inputs, attrs, num_outputs)
61 except core._NotOkStatusException as e:
62 if name is not None:

2 root error(s) found.
(0) Unknown: Failed to get convolution algorithm.

It the notebook only seem to work if you set it to CPU mode ( Edit=>Notebook settings to none) which takes a very very long time

Can you try it with GPU but removing the TF instalation on the first line? The training will be much faster

Thanks for the tip. I did try it and it ran much faster; I was able to move beyond the training cell. However, once I got to the evaluate cell… model.evaluate_tflite(“model.tflite”, test_data), I again got an error…
InvalidArgumentError: Incompatible shapes: [1,25] vs. [4] [Op:Mul]

I think that I read somewhere that the order of the outputs were changed??? Do you know how to get past this error?

Sorry for that Winton,
I tried here and got the same issue. Raised a bug and it’ll be fixed soon. I’ll keep you posted!

Thanks… looking forward to a solution.

Hey @all

After going through extensively through each and every like that has been posted here.

I can come to the conclusion that Training Custom Object Detector with tensorflow 2 Object Detection API tutorialhttps://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html is of no use.

As training the entire network on new data has been shown here by one of the user to yield worst results than the pre trained network used for transfer learning before training sourcehttps://github.com/tensorflow/models/issues/2203?#issuecomment-883248328
Have no idea if the user has played around changing the learning rate either case. Could love to preserve the base feature extraction layer and train the prediction final layer

Adding freeze_variable forcefully is not being detected being training also sourcehttps://github.com/tensorflow/models/issues/10167

Can we help each other replicate Transfer learning and fine-tuning on tensorflow where they are using keras for object detection the example on the post is a classification network?

I am willing to contribute for getting this thing working, if anyone can pitch in.

I am having same issue which I have posted on tensorflow/models repo Transfer learning and fine tuning of hidden layers and the final layer by looking at the history of issue comments on that repo I seriously doubt anyone will even reply to the issue.