首页 > 解决方案 > UnicodeDecodeError:“utf-8”编解码器无法解码位置 71 中的字节 0xcd:无效的继续字节

问题描述

错误:

Traceback (most recent call last):
  File "C:\Users\Lenovo\Emergency-Vehicle-Detection-using-Image-Processing\objectdetection1.py", line 59, in <module>
    serialized_graph = fid.read()
  File "C:\Python39\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 117, in read
    self._preread_check()
  File "C:\Python39\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 79, in _preread_check
    self._read_buf = _pywrap_file_io.BufferedInputStream(
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcd in position 71: invalid continuation byte
    # Load the Tensorflow model into memory. 

代码:

detection_graph = tf.Graph() 

with detection_graph.as_default(): 

    od_graph_def = tf.compat.v1.GraphDef() 
    with tf.compat.v1.gfile.GFile(PATH_TO_CKPT, 'rb') as fid:
 
        
        serialized_graph = fid.read()
        od_graph_def.ParseFromString(serialized_graph) 
        tf.import_graph_def(od_graph_def, name ='')

标签: pythontensorflowencoding

解决方案


推荐阅读