python - 没有这样的文件或目录:pretrained_yolov3.h5
问题描述
我尝试使用预训练的 YOLO 模型来完成我的作业,但遇到了以下错误。
OSError Traceback (most recent call last)
<ipython-input-29-40f01161449a> in <module>
5 trainer.setDataDirectory(data_directory=path)
6 trainer.setTrainConfig(object_names_array=["Table"], batch_size=16, num_experiments=200, train_from_pretrained_model="pretrained_yolov3.h5")
----> 7 trainer.trainModel()
~\AppData\Roaming\Python\Python38\site-packages\imageai\Detection\Custom\__init__.py in trainModel(self)
284 )"""
285
--> 286 train_model, infer_model = self._create_model(
287 nb_class=len(labels),
288 anchors=self.__model_anchors,
~\AppData\Roaming\Python\Python38\site-packages\imageai\Detection\Custom\__init__.py in _create_model(self, nb_class, anchors, max_box_per_image, max_grid, batch_size, warmup_batches, ignore_thresh, multi_gpu, lr, grid_scales, obj_scale, noobj_scale, xywh_scale, class_scale)
588 if self.__training_mode:
589 print("Training with transfer learning from pretrained Model")
--> 590 template_model.load_weights(self.__pre_trained_model, by_name=True)
591 else:
592 if self.__training_mode:
~\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\keras\engine\training.py in load_weights(self, filepath, by_name, skip_mismatch, options)
2225 'first, then load the weights.')
2226 self._assert_weights_created()
-> 2227 with h5py.File(filepath, 'r') as f:
2228 if 'layer_names' not in f.attrs and 'model_weights' in f:
2229 f = f['model_weights']
C:\ProgramData\Anaconda3\lib\site-packages\h5py\_hl\files.py in __init__(self, name, mode, driver, libver, userblock_size, swmr, rdcc_nslots, rdcc_nbytes, rdcc_w0, track_order, **kwds)
404 with phil:
405 fapl = make_fapl(driver, libver, rdcc_nslots, rdcc_nbytes, rdcc_w0, **kwds)
--> 406 fid = make_fid(name, mode, userblock_size,
407 fapl, fcpl=make_fcpl(track_order=track_order),
408 swmr=swmr)
C:\ProgramData\Anaconda3\lib\site-packages\h5py\_hl\files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)
171 if swmr and swmr_support:
172 flags |= h5f.ACC_SWMR_READ
--> 173 fid = h5f.open(name, flags, fapl=fapl)
174 elif mode == 'r+':
175 fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)
h5py\_objects.pyx in h5py._objects.with_phil.wrapper()
h5py\_objects.pyx in h5py._objects.with_phil.wrapper()
h5py\h5f.pyx in h5py.h5f.open()
OSError: Unable to open file (unable to open file: name = 'pretrained_yolov3.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
我使用 Windows 10 作为我的操作系统,并尝试了提到的其他解决方案但失败了。任何帮助表示赞赏
解决方案
trainer.setTrainConfig(object_names_array=["Table"], batch_size=16, num_experiments=200, train_from_pretrained_model="pretrained_yolov3.h5")
这里在 train_from_pretrained_model= 中提供 yolov3.h5 路径。
如果您使用的是 google colab,请使用
/content/drive/MyDrive/path/pretrained-yolov3.h5
推荐阅读
- html - 如何在新的 Flutter Web 中添加自定义 html 平台视图
- java - 我们如何将字符串与 Java 中的枚举元素的值进行比较
- python - Python 正则表达式修改 re.sub() 中的组匹配
- azure - 如何使用来自邮递员的多个参数触发 Azure 数据工厂管道
- php - 来自其他服务器图像的 PHPmailer AddEmbeddedImage
- convertigo - ResetDatabase Fullsync 事务不同步本地客户端数据库
- excel - 如何仅显示用户窗体并完全隐藏 excel 窗口?
- php - 在 Ubuntu 18.04 的 Nginx 上同时部署 Reactjs 和 PHP 应用程序
- c++ - 两个代码库具有相同的代码,但一个生成重载解析编译错误,另一个不生成
- c - 实现状态机以在数据闪存中读写数据