[英]"Read less bytes than requested" error while trying to load tensorflow using tf.saved_model.load()
I've been trying to run a web server locally that my colleague created which contains a deployed model that processes object detection requests.我一直在尝试在本地运行我的同事创建的 Web 服务器,其中包含一个处理对象检测请求的已部署模型。 There've been a lot of compatibility issues because he's on Windows and I'm on MacOS.
因为他在 Windows 而我在 MacOS,所以出现了很多兼容性问题。
I've been able to resolve all the compatibility issues with the dependencies and get the web server running, but I've been running into this issue when trying to load the object detection model from the saved_model directory.我已经能够解决所有依赖项的兼容性问题并让 Web 服务器运行,但是当我尝试从 saved_model 目录加载对象检测模型时遇到了这个问题。 The structure of the directory is:
目录结构为:
saved_model/保存的模型/
variables/变量/
variables.data-00000-of-00001 variables.data-00000-of-00001
variables.index变量.index
saved_model.pb saved_model.pb
I created a test script to try isolate the problem, which looks as follows:我创建了一个测试脚本来尝试隔离问题,如下所示:
import tensorflow as tf
model = tf.saved_model.load("./saved_model")
# print model summary
print("loaded model")
print(model.summary())
When I run the script, I get the following error, which is the same error that I get when running the web server.当我运行脚本时,出现以下错误,这与运行 Web 服务器时出现的错误相同。
Traceback (most recent call last): File "/Users/alexandrospouroullis/programming-projects/elevat3d/backend/workspace/training_demo/exported-models/my_model_1024/testFile.py", line 4, in model = tf.saved_model.load("./saved_model") File "/Users/alexandrospouroullis/opt/miniconda3/envs/elevat3d-api/lib/python3.10/site-packages/tensorflow/python/saved_model/load.py", line 782, in load result = load_partial(export_dir, None, tags, options)["root"] File "/Users/alexandrospouroullis/opt/miniconda3/envs/elevat3d-api/lib/python3.10/site-packages/tensorflow/python/saved_model/load.py", line 912, in load_partial loader = Loader(object_graph_proto, saved_model_proto, export_dir, File "/Users/alexandrospouroullis/opt/miniconda3/envs/elevat3d-api/lib/python3.10/site-packages/tensorflow/python/saved_model/load.py", line 189, in init self._restore_checkpoint() File "/Users/alexandrospouroullis/opt/miniconda3/envs/elevat3d-api/lib/python3.10/site-packages/tensorflow/python/saved_model/load.py", line 5
回溯(最近一次通话最后一次):文件“/Users/alexandrospourullis/programming-projects/elevat3d/backend/workspace/training_demo/exported-models/my_model_1024/testFile.py”,第 4 行,在 model = tf.saved_model.load( “./saved_model”)文件“/Users/alexandrospourullis/opt/miniconda3/envs/elevat3d-api/lib/python3.10/site-packages/tensorflow/python/saved_model/load.py”,第 782 行,加载结果= load_partial(export_dir, None, tags, options)["root"] 文件 "/Users/alexandrospourullis/opt/miniconda3/envs/elevat3d-api/lib/python3.10/site-packages/tensorflow/python/saved_model/load .py", line 912, in load_partial loader = Loader(object_graph_proto, saved_model_proto, export_dir, File "/Users/alexandrospourullis/opt/miniconda3/envs/elevat3d-api/lib/python3.10/site-packages/tensorflow/python/ saved_model/load.py”,第 189 行,在init self._restore_checkpoint() 文件中“/Users/alexandrospourullis/opt/miniconda3/envs/elevat3d-api/lib/python3.10/site-packages/tensorflow/python/saved_model/加载.py”,第 5 行07, in _restore_checkpoint load_status = saver.restore(variables_path, self._checkpoint_options) File "/Users/alexandrospouroullis/opt/miniconda3/envs/elevat3d-api/lib/python3.10/site-packages/tensorflow/python/training/tracking/util.py", line 1430, in restore object_graph_string = reader.get_tensor(base.OBJECT_GRAPH_PROTO_KEY) File "/Users/alexandrospouroullis/opt/miniconda3/envs/elevat3d-api/lib/python3.10/site-packages/tensorflow/python/training/py_checkpoint_reader.py", line 66, in get_tensor return CheckpointReader.CheckpointReader_GetTensor( IndexError: Read less bytes than requested
07、在_restore_checkpoint load_status = saver.restore(variables_path, self._checkpoint_options) 文件"/Users/alexandrospourullis/opt/miniconda3/envs/elevat3d-api/lib/python3.10/site-packages/tensorflow/python/training/tracking /util.py", line 1430, in restore object_graph_string = reader.get_tensor(base.OBJECT_GRAPH_PROTO_KEY) File "/Users/alexandrospouroullis/opt/miniconda3/envs/elevat3d-api/lib/python3.10/site-packages/tensorflow/ python/training/py_checkpoint_reader.py”,第 66 行,在 get_tensor 中 return CheckpointReader.CheckpointReader_GetTensor( IndexError: Read less bytes than requested
I understand that things like Docker were made for this;我知道像 Docker 这样的东西就是为此而生的; I actually created a docker-compose.yaml file that I managed to get up and running as well, but it faced this exact same issue.
我实际上创建了一个 docker-compose.yaml 文件,我也设法启动并运行它,但它面临着完全相同的问题。
I've looked around on the web, but this doesn't seem to be a common issue and no remedy, as far as I know, exists.我在网上四处张望,但这似乎不是一个常见问题,据我所知,不存在任何补救措施。
What could be going wrong?可能出了什么问题?
There are two things you will have to check:您必须检查两件事:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.