Adamdad / keras-YOLOv3-mobilenet

I transfer the backend of yolov3 into Mobilenetv1,VGG16,ResNet101 and ResNeXt101
MIT License
563 stars 165 forks source link

ValueError: Cannot create group in read only mode.OSError: Unable to open file (truncated file: eof = 458752, sblock->base_addr = 0, stored_eof = 17225924) #44

Open MRHZBSJ opened 5 years ago

MRHZBSJ commented 5 years ago

Traceback (most recent call last): File "F:/keras-YOLOv3-mobilenet-master-my/yolo_my_1.py", line 61, in generate self.yolo_model = load_model(model_path, compile=False) File "G:\python\lib\site-packages\keras\engine\saving.py", line 419, in load_model model = _deserialize_model(f, custom_objects, compile) File "G:\python\lib\site-packages\keras\engine\saving.py", line 221, in _deserialize_model model_config = f['model_config'] File "G:\python\lib\site-packages\keras\utils\io_utils.py", line 302, in getitem raise ValueError('Cannot create group in read only mode.') ValueError: Cannot create group in read only mode.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "F:/keras-YOLOv3-mobilenet-master-my/yolo_my_1.py", line 234, in detect_img(YOLO()) File "F:/keras-YOLOv3-mobilenet-master-my/yolo_my_1.py", line 35, in init self.boxes, self.scores, self.classes = self.generate() File "F:/keras-YOLOv3-mobilenet-master-my/yolo_my_1.py", line 64, in generate if is_tiny_version else yolo_body(Input(shape=(None,None,3)), num_anchors//3, num_classes) File "F:/keras-YOLOv3-mobilenet-master-my\yolo3\model_Mobilenet.py", line 198, in yolo_body mobilenet = MobileNet(input_tensor=inputs,weights='imagenet') File "G:\python\lib\site-packages\keras\applications__init.py", line 28, in wrapper return base_fun(*args, *kwargs) File "G:\python\lib\site-packages\keras\applications\mobilenet.py", line 11, in MobileNet return mobilenet.MobileNet(args, **kwargs) File "G:\python\lib\site-packages\keras_applications\mobilenet.py", line 320, in MobileNet model.load_weights(weights_path) File "G:\python\lib\site-packages\keras\engine\network.py", line 1157, in load_weights with h5py.File(filepath, mode='r') as f: File "G:\python\lib\site-packages\h5py_hl\files.py", line 312, in init__ fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr) File "G:\python\lib\site-packages\h5py_hl\files.py", line 142, in make_fid fid = h5f.open(name, flags, fapl=fapl) 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 78, in h5py.h5f.open OSError: Unable to open file (truncated file: eof = 458752, sblock->base_addr = 0, stored_eof = 17225924)

lofyol commented 5 years ago

Traceback (most recent call last): File "F:/keras-YOLOv3-mobilenet-master-my/yolo_my_1.py", line 61, in generate self.yolo_model = load_model(model_path, compile=False) File "G:\python\lib\site-packages\keras\engine\saving.py", line 419, in load_model model = _deserialize_model(f, custom_objects, compile) File "G:\python\lib\site-packages\keras\engine\saving.py", line 221, in _deserialize_model model_config = f['model_config'] File "G:\python\lib\site-packages\keras\utils\io_utils.py", line 302, in getitem raise ValueError('Cannot create group in read only mode.') ValueError: Cannot create group in read only mode.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "F:/keras-YOLOv3-mobilenet-master-my/yolo_my_1.py", line 234, in detect_img(YOLO()) File "F:/keras-YOLOv3-mobilenet-master-my/yolo_my_1.py", line 35, in init self.boxes, self.scores, self.classes = self.generate() File "F:/keras-YOLOv3-mobilenet-master-my/yolo_my_1.py", line 64, in generate if is_tiny_version else yolo_body(Input(shape=(None,None,3)), num_anchors//3, num_classes) File "F:/keras-YOLOv3-mobilenet-master-my\yolo3\model_Mobilenet.py", line 198, in yolo_body mobilenet = MobileNet(input_tensor=inputs,weights='imagenet') File "G:\python\lib\site-packages\keras\applicationsinit.py", line 28, in wrapper return base_fun(*args, *kwargs) File "G:\python\lib\site-packages\keras\applications\mobilenet.py", line 11, in MobileNet return mobilenet.MobileNet(args, kwargs) File "G:\python\lib\site-packages\keras_applications\mobilenet.py", line 320, in MobileNet model.load_weights(weights_path) File "G:\python\lib\site-packages\keras\engine\network.py", line 1157, in load_weights with h5py.File(filepath, mode='r') as f: File "G:\python\lib\site-packages\h5py_hl\files.py", line 312, in init** fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr) File "G:\python\lib\site-packages\h5py_hl\files.py", line 142, in make_fid fid = h5f.open(name, flags, fapl=fapl) 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 78, in h5py.h5f.open OSError: Unable to open file (truncated file: eof = 458752, sblock->base_addr = 0, stored_eof = 17225924)

Have you worked it out?

SpaceView commented 5 years ago

I'm not sure I can help on this topic. so I put some words here for your reference.

I had the same error when try keras mobilenet under windows (NOT for YOLO), and I found that my model C:\Users\SpaceVision.keras\models\mobilenet_1_0_224_tf_no_top.h5 was a corrupted file.

Solution: download the model file and put it in the correct place.

Your requirements might be different from mine, and you may use IPython to track the problem to the following line at h5f.open(name, flags, fapl=fapl) Generally the name is the file required by keras, and your model file might have some problem.