python-3.x layers,tensorflow中的输入-- TypeError:列表索引必须是整数或切片,而不是str

vc9ivgsu  于 4个月前  发布在  Python
关注(0)|答案(1)|浏览(76)

TLDR:我需要这个来使用确切版本的tensorflow

(EfficientPose) mona@ada:~/EfficientPose$ python evaluate.py --phi 0 --weights weights/Weights/Linemod/object_8/phi_0_linemod_best_ADD.h5  --validation-image-save-path val_imgs linemod data/Linemod_preprocessed/ --object-id 8
2023-11-29 14:32:03.726767: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
WARNING:tensorflow:Deprecation warnings have been disabled. Set TF_ENABLE_DEPRECATION_WARNINGS=1 to re-enable them.
WARNING:tensorflow:From evaluate.py:132: The name tf.ConfigProto is deprecated. Please use tf.compat.v1.ConfigProto instead.

WARNING:tensorflow:From evaluate.py:134: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

2023-11-29 14:32:04.753096: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3096000000 Hz
2023-11-29 14:32:04.757779: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x4308000 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2023-11-29 14:32:04.757816: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
2023-11-29 14:32:04.760137: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcuda.so.1
2023-11-29 14:32:04.835556: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x42dccb0 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2023-11-29 14:32:04.835645: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): NVIDIA RTX 6000 Ada Generation, Compute Capability 8.9
2023-11-29 14:32:04.836612: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1665] Found device 0 with properties: 
name: NVIDIA RTX 6000 Ada Generation major: 8 minor: 9 memoryClockRate(GHz): 2.505
pciBusID: 0000:52:00.0
2023-11-29 14:32:04.836671: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
2023-11-29 14:32:04.864717: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublas.so.11
2023-11-29 14:32:04.868586: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcufft.so.10
2023-11-29 14:32:04.869006: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcurand.so.10
2023-11-29 14:32:04.869649: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusolver.so.11
2023-11-29 14:32:04.870609: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusparse.so.11
2023-11-29 14:32:04.870817: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudnn.so.8
2023-11-29 14:32:04.871189: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1793] Adding visible gpu devices: 0
2023-11-29 14:32:04.871217: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
2023-11-29 14:32:04.876437: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1206] Device interconnect StreamExecutor with strength 1 edge matrix:
2023-11-29 14:32:04.876468: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1212]      0 
2023-11-29 14:32:04.876474: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1225] 0:   N 
2023-11-29 14:32:04.877950: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1351] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 39256 MB memory) -> physical GPU (device: 0, name: NVIDIA RTX 6000 Ada Generation, pci bus id: 0000:52:00.0, compute capability: 8.9)
{'dataset_type': 'linemod', 'rotation_representation': 'axis_angle', 'weights': 'weights/Weights/Linemod/object_8/phi_0_linemod_best_ADD.h5', 'batch_size': 1, 'phi': 0, 'gpu': None, 'score_threshold': 0.5, 'validation_image_save_path': 'val_imgs', 'linemod_path': 'data/Linemod_preprocessed/', 'object_id': 8}

Creating the Generators...
Done!

Building the Model...
input shape is:  (512, 512, 3)
ArgSpec(args=['shape', 'batch_size', 'name', 'dtype', 'sparse', 'tensor', 'ragged'], varargs=None, keywords='kwargs', defaults=(None, None, None, None, False, None, False))
Traceback (most recent call last):
  File "evaluate.py", line 368, in <module>
    main()
  File "evaluate.py", line 111, in main
    _, prediction_model, _ = build_EfficientPose(args.phi,
  File "/home/mona/EfficientPose/model.py", line 105, in build_EfficientPose
    image_input = layers.Input(shape=input_shape)
  File "/home/mona/anaconda3/envs/EfficientPose/lib/python3.8/site-packages/tensorflow_core/python/keras/engine/input_layer.py", line 265, in Input
    input_layer = InputLayer(**input_layer_config)
  File "/home/mona/anaconda3/envs/EfficientPose/lib/python3.8/site-packages/tensorflow_core/python/keras/engine/input_layer.py", line 121, in __init__
    input_tensor = backend.placeholder(
  File "/home/mona/anaconda3/envs/EfficientPose/lib/python3.8/site-packages/tensorflow_core/python/keras/backend.py", line 1051, in placeholder
    x = array_ops.placeholder(dtype, shape=shape, name=name)
  File "/home/mona/anaconda3/envs/EfficientPose/lib/python3.8/site-packages/tensorflow_core/python/ops/array_ops.py", line 2619, in placeholder
    return gen_array_ops.placeholder(dtype=dtype, shape=shape, name=name)
  File "/home/mona/anaconda3/envs/EfficientPose/lib/python3.8/site-packages/tensorflow_core/python/ops/gen_array_ops.py", line 6668, in placeholder
    _, _, _op = _op_def_lib._apply_op_helper(
  File "/home/mona/anaconda3/envs/EfficientPose/lib/python3.8/site-packages/tensorflow_core/python/framework/op_def_library.py", line 792, in _apply_op_helper
    op = g.create_op(op_type_name, inputs, dtypes=None, name=scope,
  File "/home/mona/anaconda3/envs/EfficientPose/lib/python3.8/site-packages/tensorflow_core/python/util/deprecation.py", line 513, in new_func
    return func(*args, **kwargs)
  File "/home/mona/anaconda3/envs/EfficientPose/lib/python3.8/site-packages/tensorflow_core/python/framework/ops.py", line 3356, in create_op
    return self._create_op_internal(op_type, inputs, dtypes, input_types, name,
  File "/home/mona/anaconda3/envs/EfficientPose/lib/python3.8/site-packages/tensorflow_core/python/framework/ops.py", line 3411, in _create_op_internal
    node_def = _NodeDef(op_type, name, device=None, attrs=attrs)
  File "/home/mona/anaconda3/envs/EfficientPose/lib/python3.8/site-packages/tensorflow_core/python/framework/ops.py", line 1552, in _NodeDef
    node_def.attr[k].CopyFrom(v)
  File "/home/mona/anaconda3/envs/EfficientPose/lib/python3.8/site-packages/google/protobuf/internal/containers.py", line 70, in __getitem__
    return self._values[key]
TypeError: list indices must be integers or slices, not str

字符串
model.py的相关代码

#input layers
    print('input shape is: ', input_shape)
    #image_input = layers.Input(input_shape) # original
    print(inspect.getargspec(layers.Input))
    image_input = layers.Input(shape=input_shape)


代码库https://github.com/ybkscht/EfficientPose

nvidia-tensorflow==1.15.4+nv20.12

      - protobuf==4.25.1

Python 3.8.18 (default, Sep 11 2023, 13:40:15) 
[GCC 11.2.0

roqulrg3

roqulrg31#

看起来一些较旧的Tensorflow版本与几个月前发布的protobuf 4.25不兼容。您可以通过安装"protobuf<4.25"来解决这个问题。

相关问题