проблема кодирования при попытке использовать модель графа с Google Drive - PullRequest
0 голосов
/ 07 июля 2019

Я пытаюсь сохранить модель из замороженного графика .pb в тензорный поток. Я использую Google Colab. Я попытался Pydrive загрузить файл как saved_model2.pb, но при попытке использовать .from_frozen_graph он выдал ошибку

auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)

file_obj = drive.CreateFile({'id': '15vnDl_fBztBT4nzVYQgzJFbPBMofQ2KJ'})      
file_obj.GetContentFile('saved_model2.pb')
import tensorflow as tf
graph_def_file = "saved_model2.pb"
tflite_file = "retrained_graph_eyes1z.lite"


input_arrays = ["input"]
output_arrays = ["kinetics-i3d/Predictions/Softmax"]
converter = tf.lite.TFLiteConverter.from_frozen_graph(
        graph_def_file,
    input_arrays, 
    output_arrays)
tflite_model = converter.convert()
open(tflite_file, "wb").write(tflite_model)
interpreter = tf.lite.Interpreter(model_content=tflite_model)
interpreter.allocate_tensors()
files.download(tflite_file)

вот что я получаю как сообщение об ошибке

DecodeError                               Traceback (most recent call last)

/usr/local/lib/python3.6/dist-packages/tensorflow/lite/python/lite.py in from_frozen_graph(cls, graph_def_file, input_arrays, output_arrays, input_shapes)
    607           graph_def = _graph_pb2.GraphDef()
--> 608           graph_def.ParseFromString(file_content)
    609         except (_text_format.ParseError, DecodeError):

DecodeError: Error parsing message


During handling of the above exception, another exception occurred:

UnicodeDecodeError                        Traceback (most recent call last)

1 frames

/usr/local/lib/python3.6/dist-packages/tensorflow/lite/python/lite.py in from_frozen_graph(cls, graph_def_file, input_arrays, output_arrays, input_shapes)
    613             if not isinstance(file_content, str):
    614               if PY3:
--> 615                 file_content = file_content.decode("utf-8")
    616               else:
    617                 file_content = file_content.encode("utf-8")

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xdb in position 1: invalid continuation byte
...