I tried to use a pre-trained YOLO model for my assignment and got stuck on the following error.
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)
I am using windows 10 as my OS and tried other solutions mentioned but failed. Any help is appreciated
trainer.setTrainConfig(object_names_array=["Table"], batch_size=16, num_experiments=200, train_from_pretrained_model="pretrained_yolov3.h5")
Here in train_from_pretrained_model= provide the yolov3.h5 path.
If you are using google colab use
/content/drive/MyDrive/path/pretrained-yolov3.h5