我跟着他們的Github上描述的步驟來安裝Object Detection API然後我跑這個腳本:Tensorflow:有沒有屬性「load_labelmap」
python object_detection/builders/model_builder_test.py
和測試是成功的,所以我認爲一切都設置正確。接下來,我嘗試使用qtconsole運行Jupyter Notebook以檢測測試圖像中的對象。但它返回此錯誤:
AttributeError Traceback (most recent call last)
<ipython-input-3-be6fe1ba8733> in <module>()
----> 1 from utils import label_map_util
2
3 from utils import visualization_utils as vis_util
4
~\Desktop\Objectdetection\models-master\object_detection\utils\label_map_util.py in <module>()
20 import tensorflow as tf
21 from google.protobuf import text_format
---> 22 from object_detection.protos import string_int_label_map_pb2
23
24
~\Desktop\Objectdetection\models-master\object_detection\object_detection.py in <module>()
114
115
--> 116 label_map = label_map_util.load_labelmap(PATH_TO_LABELS)
117 categories = label_map_util.convert_label_map_to_categories(label_map, max_num_classes=NUM_CLASSES, use_display_name=True)
118 category_index = label_map_util.create_category_index(categories)
AttributeError: module 'utils.label_map_util' has no attribute 'load_labelmap'
有沒有人有一個想法是什麼原因導致這個問題?
謝謝。
這追溯介紹了「'IPython中輸入-3' 「然而你顯示了對'python'的命令行調用。你可以通過命令行調用顯示錯誤嗎?如果你不能複製它,那麼它幾乎肯定與問題有關。 IIRC'ipython'與virtualenv搭配不好(除非你在virtualenv中構建/安裝它) –
因此,我將Jupyter Notebook object_detection_tutorial.ipynb轉換爲python腳本,並從命令行通過ipython調用它。我仍然得到同樣的錯誤。 – noobprogrammer
[添加此功能的提交相對較新](https://github.com/tensorflow/models/commit/a4944a57ad2811e1f6a7a87589a9fc8a776e8d3c)。你確定你有一個兼容的版本? –