Search code examples
tensorflowobject-detection-api

Error extending Tensorflow object detection tutorial to multiple classes


I'm trying to extend this example from the tensorflow/models/research/object_detection project to support multiple classes using a custom dataset but I'm hitting an error that I don't understand. I'm a total amateur with machine learning concepts, I'm just trying to get a model trained so that I can do object detection in an application I'm developing.

The error is:

ValueError: No gradients provided for any variable: ['WeightSharedConvolutionalBoxPredictor/WeightSharedConvolutionalBoxHead/BoxPredictor/kernel:0', 'WeightSharedConvolutionalBoxPredictor/WeightSharedConvolutionalBoxHead/BoxPredictor/bias:0', 'WeightSharedConvolutionalBoxPredictor/WeightSharedConvolutionalClassHead/ClassPredictor/kernel:0', 'WeightSharedConvolutionalBoxPredictor/WeightSharedConvolutionalClassHead/ClassPredictor/bias:0'].

A fully working Google Colab notebook showing the issue is here. You should be able to make a copy of the notebook and then click Runtime -> Run All to reproduce the issue.

The changes I've made to the original notebook (annotated with [MITCH] in my notebook) are:

  • Parse labels from a labelmap file rather than hard-code them.
  • Derive the number of classes from the parsed labelmap rather than hard-code.
  • Use custom dataset from google drive (labeled with labelImg).
  • Fix other hard-coded assumptions about the number of classes.

I'm guessing I just missed something else hard-coded but I can't spot it... Any help is greatly appreciated!


Solution

  • I got an answer on Reddit. I was simply missing a call to model.predict()... I must have just fat-fingered it. /facepalm