Models: Inference TF2 Tutorial "PATH_TO_BE_CONFIGURED" and model name mismatch error.

Created on 26 Aug 2020  ·  8Comments  ·  Source: tensorflow/models

Prerequisites

Please answer the following question for yourself before submitting an issue.

  • [X] I checked to make sure that this issue has not been filed already.

1. The entire URL of the documentation with the issue

https://github.com/tensorflow/models/blob/master/research/object_detection/colab_tutorials/inference_tf2_colab.ipynb

2. Describe the issue

For this Colab tutorial I tried to run all the cells but it gives an error at the line configs = config_util.get_configs_from_pipeline_file(pipeline_config)

However I figured out the problem:

In tutorial name of the model is called as
centernet_hg104_512x512_kpts_coco17_tpu-32
but in models/research/object-detection/configs/tf2 folder, where pipeline_config = os.path.join('models/research/object_detection/configs/tf2/', model_name + '.config') statement in the tutorial addresses, the name of the file corresponding that network is ... _hourglass104 _ ... rather than ... _hg104 _....

Then I changed the model_name variable then it worked.

However, I now encountered a new problem that I couldn't fix:

The configuration files in the models/research/object-detection/configs/tf2 directory contains flags called PATH_TO_BE_CONFIGURED ( Check this out.)

Thus, at the label_map = label_map_util.load_labelmap(label_map_path) statement from the tutorial,
NotFoundError: PATH_TO_BE_CONFIGURED/label_map.txt; No such file or directory error arises.

There are also some spaces filled with ????. I couldn't figure them out either. (Check this out.)

Should the API or system environment fill that automatically or I would be the one filling it ? If so, how ?

I couldn't find any file describing that flag (PATH_TO_BE_CONFIGURED) or a issue containing.

Best regards.

research docs

All 8 comments

I trained my own model and now I can understand the paths but the tutorial still remains as failed. You can close this issue if you want so.

@egirgin So is there any way to do this other than retraining?

@nikisix You can try to give your "LabelMap" and "TFRecord" files path for those fields in the configuration file (*.config). However since you are doing one shot learning you need the pretrained weights (aka. checkpoint) as well. I'm not a expert of "One shot learning" but I guess you need to adjust the labels of your own dataset regarding the labels of the pretrained weights. For example, for the pretrained one, class 1 may correspond to cat but in your dataset you may label class 1 as cat, which creates an inconsistency. Probably there is a solution in theory of "one shot learning" but as I mentioned, I don't know the details.

Was able to get predictions for my custom dataset out of this colab by running without keypoints and using the following pathing shim:

label_map_path = '/content/models/research/object_detection/data/mscoco_label_map.pbtxt'
label_map = label_map_util.load_labelmap(label_map_path)
categories = label_map_util.convert_label_map_to_categories(
    label_map,
    max_num_classes=label_map_util.get_max_label_map_index(label_map),
    use_display_name=True)
category_index = label_map_util.create_category_index(categories)
label_map_dict = label_map_util.get_label_map_dict(label_map, use_display_name=True

Hope this is helpful!

@egirgin The label_id's actually lined up with the label_id_offset = 1 as provided in the demo, although the class I'm predicting is one of the stock classes 🤷‍♂️ .

@nikisix I'm glad that you could run but I didn't understand why. Does the * label_id_offset * work like the following way: Assume that, in the coco dataset there is only 10 classes and the checkpoint is trained with that data. Hence do you give ids to your own label map starting from 11 or does the API handle that automatically ? If that is the case, which checkpoint did you used ?

@egirgin The class I'm predicting happens to be one of the 10 (in your example) classes within the coco dataset. Which is why I didn't have to do anything else.

In the general case of predicting a novel class, I'm not sure what to do exactly. Maybe from the team could add some insight here?

Was this page helpful?
0 / 5 - 0 ratings