在运行understand_facenet时,由于TensorFlow版本的问题遇到以下错误:
1、AttributeError: module ‘tensorflow’ has no attribute ‘GPUOptions’
原本:gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=gpu_memory_fraction)
改为:gpu_options = tf.compat.v1.GPUOptions(per_process_gpu_memory_fraction=gpu_memory_fraction)
2、AttributeError: module ‘tensorflow’ has no attribute ‘Session’. Did you mean: ‘version’?
原本:sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False))
改成:sess = tf.compat.v1.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False))
3、AttributeError: module ‘tensorflow’ has no attribute ‘ConfigProto’
原本:sess = tf.compat.v1.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False))
改为:sess = tf.compat.v1.Session(config=tf.compat.v1.ConfigProto(gpu_options=gpu_options, log_device_placement=False))
还有其他类似的,都加上compat.v1,不过挺多的可以重新安装一下版本。
4、ValueError: Object arrays cannot be loaded when allow_pickle=False
原本:allow_pickle=allow_pickle
改成:allow_pickle=True
5、AttributeError: ‘int’ object has no attribute ‘value’
原本:feed_in, dim = (inp, input_shape[-1].value)
改为:feed_in, dim = (inp, input_shape[-1])
6、AttributeError: scipy.misc is deprecated and has no attribute imread.
解决:要不降级,要不改用
import imageio
content_image = imageio.imread
7、SyntaxError: from __ future__ imports must occur at the beginning of the file
__ future__ 必须在导入库的开头
python遇到的错误
于 2023-08-11 18:05:28 首次发布