OSError:SavedModel 文件不存在于:cnnCat2.h5\{saved_model.pbtxt|saved_model.pb}

问题描述 投票:0回答:2

Sublime Text 项目结构

显示错误

2021-06-15 11:48:41.978235: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2021-06-15 11:48:41.978656: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
pygame 2.0.1 (SDL 2.0.14, Python 3.9.4)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "C:\Users\washi\Desktop\Driver-drowsiness-detection-CNN-Keras-OpenCV-master\final.py", line 17, in <module>
    model = load_model('cnnCat2.h5')
  File "D:\Program Files\Python39\lib\site-packages\keras\saving\save.py", line 206, in load_model
    return saved_model_load.load(filepath, compile, options)
  File "D:\Program Files\Python39\lib\site-packages\keras\saving\saved_model\load.py", line 109, in load
    meta_graph_def = loader_impl.parse_saved_model(path).meta_graphs[0]
  File "D:\Program Files\Python39\lib\site-packages\tensorflow\python\saved_model\loader_impl.py", line 113, in parse_saved_model
    raise IOError(
OSError: SavedModel file does not exist at: cnnCat2.h5\{saved_model.pbtxt|saved_model.pb}
[Finished in 5.2s]

以tensorflow为后端运行final.py脚本,该脚本持续监控用户的眼睛状态并分类人是否昏昏欲睡。 model.py 是用于训练 CNN 分类器模型的脚本。但我遇到这种类型的错误我该怎么办?

python tensorflow keras
2个回答
1
投票

在您的代码中尝试使用

""
而不是
''
来指定目录

例如

model_path = os.path.join(join(dirname(realpath(__file__))), "example.h5")

0
投票

“安装 h5py 模块”是唯一正确的解决方案。对于普通程序员来说,将模型设置到错误的路径是不可能的情况

© www.soinside.com 2019 - 2024. All rights reserved.