【问题标题】:Tensorflow and Keras: OSError: unable to create model file, permission deniedTensorflow 和 Keras:OSError:无法创建模型文件,权限被拒绝
【发布时间】:2020-09-08 00:16:37
【问题描述】:

我正在使用 Anaconda Spyder 4.0.1、64 位 Windows 和 TensorFlow 2.0 版。我正在尝试遵循本教程 (https://www.pyimagesearch.com/2020/05/04/covid-19-face-mask-detector-with-opencv-keras-tensorflow-and-deep-learning/),以检测戴口罩和不戴口罩的人。我正在尝试生成一个分类器文件,它给了我这个错误。

[INFO] saving mask detector model...
Traceback (most recent call last):
  File "train_mask_detector.py", line 141, in <module>
   model.save(args["model"], save_format="h5")
File "C:\Users\Ravi\anaconda3\lib\site-packages\tensorflow_core\python\keras\engine\network.py", line 975, in save
signatures, options)
 File "C:\Users\Ravi\anaconda3\lib\site-packages\tensorflow_core\python\keras\saving\save.py", line 112, in save_model
   model, filepath, overwrite, include_optimizer)
File "C:\Users\Ravi\anaconda3\lib\site-packages\tensorflow_core\python\keras\saving\hdf5_format.py", line 92, in save_model_to_hdf5
f = h5py.File(filepath, mode='w')
 File "C:\Users\Ravi\anaconda3\lib\site-packages\h5py\_hl\files.py", line 408, in __init__
swmr=swmr)
 File "C:\Users\Ravi\anaconda3\lib\site-packages\h5py\_hl\files.py", line 179, in make_fid
fid = h5f.create(name, h5f.ACC_TRUNC, fapl=fapl, fcpl=fcpl)
 File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
 File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
 File "h5py\h5f.pyx", line 108, in h5py.h5f.create
OSError: Unable to create file (unable to open file: name = 'C:\Users\Ravi\Downloads\face-mask-detector\face-mask-detector', errno = 13, error message = 'Permission denied', flags = 13, o_flags = 302)

我正在使用此命令在提示符下运行文件。

python train_mask_detector.py --dataset C:\Users\Ravi\Downloads\face-mask-detector\face-mask-detector\dataset --plot C:\Users\Ravi\Downloads\face-mask-detector\face-mask-detector --model C:\Users\Ravi\Downloads\face-mask-detector\face-mask-detector

train_mask_detector.py 中的模型就是这样保存的。

# serialize the model to disk
print("[INFO] saving mask detector model...")
model.save(args["model"], save_format="h5")

我可以做些什么来解决这个问题?

【问题讨论】:

  • 当您打开命令提示符时,尝试以管理员身份启动它。
  • @PrateekDewan 我试过但遇到了同样的问题。还有其他想法吗?
  • 看起来像一个老问题:stackoverflow.com/questions/39289217/…

标签: python tensorflow keras spyder


【解决方案1】:

它通过 model.save ('name_of_model.model') 解决,而不是保存为 'h5' 或 'hdf5' 格式。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多