【问题标题】:Tensorflow error can't figure out what it isTensorflow错误无法弄清楚它是什么
【发布时间】:2021-03-31 16:46:50
【问题描述】:

我正在做 tensorflow 对象检测项目以使用 google colab 检测手语
我得到 tensorflow has no attribute gflie 错误,我发现我必须降级到 tensorflow 1
所以我在我的 colab 单元中运行 !pip install tensorflow==1.13.0rc1
但是现在当我运行同一个单元格时,我得到了这个错误,我无法弄清楚如何解决
代码 -

!python {SCRIPTS_PATH + 'generate_tfrecord.py'} -x {IMAGE_PATH + 'train'} -l {ANNOTATION_PATH + 'label_map.pbtxt'} -o {ANNOTATION_PATH + 'train.record'}
!python {SCRIPTS_PATH + 'generate_tfrecord.py'} -x{IMAGE_PATH + 'test'} -l {ANNOTATION_PATH + 'label_map.pbtxt'} -o {ANNOTATION_PATH + 'test.record'}

错误 -

/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/dtypes.py:528: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/dtypes.py:529: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/dtypes.py:530: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/dtypes.py:535: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
Traceback (most recent call last):
  File "Tensorflow/scripts/generate_tfrecord.py", line 62, in <module>
    label_map_dict = label_map_util.get_label_map_dict(label_map)
  File "/usr/local/lib/python3.7/dist-packages/object_detection/utils/label_map_util.py", line 164, in get_label_map_dict
    label_map = load_labelmap(label_map_path)
  File "/usr/local/lib/python3.7/dist-packages/object_detection/utils/label_map_util.py", line 133, in load_labelmap
    label_map_string = fid.read()
  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/lib/io/file_io.py", line 125, in read
    self._preread_check()
  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/lib/io/file_io.py", line 85, in _preread_check
    compat.as_bytes(self.__name), 1024 * 512, status)
  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/util/compat.py", line 61, in as_bytes
    (bytes_or_text,))
TypeError: Expected binary or unicode string, got item {
  name: "Hello"
  id: 1
}
item {
  name: "Yes"
  id: 2
}
item {
  name: "Thank You"
  id: 3
}
item {
  name: "I Love You"
  id: 5
}
item {
  name: "No"
  id: 5
}

/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/dtypes.py:528: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/dtypes.py:529: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/dtypes.py:530: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/dtypes.py:535: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
Traceback (most recent call last):
  File "Tensorflow/scripts/generate_tfrecord.py", line 62, in <module>
    label_map_dict = label_map_util.get_label_map_dict(label_map)
  File "/usr/local/lib/python3.7/dist-packages/object_detection/utils/label_map_util.py", line 164, in get_label_map_dict
    label_map = load_labelmap(label_map_path)
  File "/usr/local/lib/python3.7/dist-packages/object_detection/utils/label_map_util.py", line 133, in load_labelmap
    label_map_string = fid.read()
  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/lib/io/file_io.py", line 125, in read
    self._preread_check()
  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/lib/io/file_io.py", line 85, in _preread_check
    compat.as_bytes(self.__name), 1024 * 512, status)
  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/util/compat.py", line 61, in as_bytes
    (bytes_or_text,))
TypeError: Expected binary or unicode string, got item {
  name: "Hello"
  id: 1
}
item {
  name: "Yes"
  id: 2
}
item {
  name: "Thank You"
  id: 3
}
item {
  name: "I Love You"
  id: 5
}
item {
  name: "No"
  id: 5
}

我的 colab 文件的其他单元格

WORKSPACE_PATH = 'Tensorflow/workspace/'
SCRIPTS_PATH = 'Tensorflow/scripts/'
APIMODEL_PATH = 'Tensorflow/models/'
ANNOTATION_PATH = WORKSPACE_PATH+'annotations/'
IMAGE_PATH = WORKSPACE_PATH+'images/'
MODEL_PATH = WORKSPACE_PATH+'models/'
PRETRAINED_MODEL_PATH = WORKSPACE_PATH+'pre-trained-models/'
CONFIG_PATH = MODEL_PATH+'my_ssd_mobnet/pipeline.config'
CHECKPOINT_PATH = MODEL_PATH+'my_ssd_mobnet/'
labels = [
  {'name':'Hello', 'id':1},
  {'name':'Yes', 'id':2},
  {'name':'Thank You', 'id':3},
  {'name':'I Love You', 'id':5},
  {'name':'No', 'id':5}
]

with open(ANNOTATION_PATH + 'label_map.pbtxt', 'w') as f:
    for label in labels:
        f.write('item { \n')
        f.write('\tname:\'{}\'\n'.format(label['name']))
        f.write('\tid:{}\n'.format(label['id']))
        f.write('}\n')

【问题讨论】:

    标签: python tensorflow object-detection


    【解决方案1】:

    generate_tfrecords.py中,删除第61行并将第62行更改为label_map_dict = label_map_util.get_label_map_dict(args.labels_path),如果pipeline.config文件中有任何行显示fine_tune_checkpoint_version,请删除该行并尝试

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-26
      • 2012-08-23
      • 1970-01-01
      • 1970-01-01
      • 2020-09-01
      • 2016-05-04
      相关资源
      最近更新 更多