Mask_RCNN icon indicating copy to clipboard operation
Mask_RCNN copied to clipboard

OSError: Unable to open file (truncated file: eof = 74436151, sblock->base_addr = 0, stored_eof = 257557808)

Open farzadzare opened this issue 6 years ago • 30 comments

I want to use Mask-RCNN demo.py in my jupyter notebook but when i ran the the demo code , i faced such a problem OSError Traceback (most recent call last) in () 3 4 # Load weights trained on MS-COCO ----> 5 model.load_weights(COCO_MODEL_PATH, by_name=True)

~/Mask_RCNN/mrcnn/model.py in load_weights(self, filepath, by_name, exclude) 2102 if h5py is None: 2103 raise ImportError('load_weights requires h5py.') -> 2104 f = h5py.File(filepath, mode='r') 2105 if 'layer_names' not in f.attrs and 'model_weights' in f: 2106 f = f['model_weights']

~/anaconda3/envs/MaskRCNN/lib/python3.6/site-packages/h5py/_hl/files.py in init(self, name, mode, driver, libver, userblock_size, swmr, **kwds) 310 with phil: 311 fapl = make_fapl(driver, libver, **kwds) --> 312 fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr) 313 314 if swmr_support:

~/anaconda3/envs/MaskRCNN/lib/python3.6/site-packages/h5py/_hl/files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr) 140 if swmr and swmr_support: 141 flags |= h5f.ACC_SWMR_READ --> 142 fid = h5f.open(name, flags, fapl=fapl) 143 elif mode == 'r+': 144 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 (truncated file: eof = 74436151, sblock->base_addr = 0, stored_eof = 257557808)

i can not solve my problem can any body help me?? thank's

farzadzare avatar Jun 07 '18 08:06 farzadzare

you are sopposed to download the .h5 file.

WindowsDriver avatar Jun 15 '18 05:06 WindowsDriver

if you mean download the mask_rcnn_coco.h5 file i had downloaded it but i faced this error AttributeError Traceback (most recent call last) in () 3 4 # Load weights trained on MS-COCO ----> 5 model.load_weights(COCO_MODEL_PATH, by_name=True)

~/Downloads/Mask_RCNN/mrcnn/model.py in load_weights(self, filepath, by_name, exclude) 2117 2118 if by_name: -> 2119 topology.load_weights_from_hdf5_group_by_name(f, layers) 2120 else: 2121 topology.load_weights_from_hdf5_group(f, layers)

AttributeError: module 'keras.engine.topology' has no attribute 'load_weights_from_hdf5_group_by_name'

farzadzare avatar Jun 18 '18 11:06 farzadzare

I have the same error,do you solve the problem?

freedom521jin avatar Jul 04 '18 08:07 freedom521jin

@freedom521jin,,,,, I coudn't solve it but i deleted all of anaconda and reinstall all of them and it solved

farzadzare avatar Jul 04 '18 09:07 farzadzare

@farzadzare ....oh!I have made it.I delete the old model ' **.h5 ' , and re-download the pre-train model ,and it works.

freedom521jin avatar Jul 04 '18 10:07 freedom521jin

@freedom521jin It worked

CrookedNoob avatar Aug 10 '18 11:08 CrookedNoob

@freedom521jin can u please tell me where is .h5 file is located

vajpaye avatar Oct 13 '18 08:10 vajpaye

I had the same Problem. I coud fix it by changing the ROOT_DIR (the path to root) in balloon.py. In the Example it is given by ROOT_DIR = '../../' In my case it is ROOT_DIR='../../../' So I just had to go on step futher.

DerOzean avatar Oct 17 '18 13:10 DerOzean

TQ @DerOzean

COCO_MODEL_PATH = os.path.join(ROOT_DIR, "mask_rcnn_balloon.h5") print(COCO_MODEL_PATH)

Download COCO trained weights from Releases if needed

if not os.path.exists(COCO_MODEL_PATH): utils.download_trained_weights(COCO_MODEL_PATH)-> this is the responsible for downloading mask_rcnn_ballon.h5 or mask_rcnn_coco.h5

vajpaye avatar Oct 18 '18 03:10 vajpaye

I have the same problem each time I load coco pretrained model after I clean the data. (rm mask_rcnn_coco.h5). Is the pretrained model corrupted ?

yiakwy avatar Jan 29 '19 11:01 yiakwy

@farzadzare Have you resolve the OSError problem?

yiakwy avatar Jan 29 '19 11:01 yiakwy

I have the same issue of OSError in h5py.h5f.open(). I am using windows python 3.6 and latest h5py version. Any Solution is helpful

AniPrat avatar Feb 13 '19 13:02 AniPrat

I found the solution. The .h5 file was not downloaded completely so it was corrupt. I downloaded it manually by going to the model release page.

AniPrat avatar Feb 13 '19 18:02 AniPrat

I have the same problem, and inspired by you guy. Mine is because that I am training with coco.h5 and I copy this weight file to another dir sothat my demo.ipynb can read it. After I load the original version on demo.ipynb it worked perfect.

pissw2016 avatar Mar 20 '19 07:03 pissw2016

OSError: Unable to open file (truncated file: eof = 218,644,480, sblock->base_addr = 0, stored_eof = 257,557,808)

the solution is: wget -c https://github.com/matterport/Mask_RCNN/releases/download/v2.0/mask_rcnn_coco.h5

sliawatimena avatar Jul 10 '19 19:07 sliawatimena

OSError: Unable to open file (truncated file: eof = 286720, sblock->base_addr = 0, stored_eof = 17225924)

farabee22 avatar Oct 15 '19 10:10 farabee22

I've got the same error. And I checked the file name. I've downloaded the wrong file mask_rcnn_ballon.h5. Then I downloaded the right file mask_rcnn_coco.h5, it worked smoothly.

YeShangguan avatar Nov 26 '19 08:11 YeShangguan

We solved the problem by downloading the file from microsoft coco website manually. Actually you can use wget or curl to download it directly.

YeShangguan [email protected] 于2019年11月26日周二 下午4:05写道:

I've got the same error. And I checked the file name. I've downloaded the wrong file mask_rcnn_ballon.h5. Then I downloaded the right file mask_rcnn_coco.h5, it worked smoothly.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/matterport/Mask_RCNN/issues/653?email_source=notifications&email_token=ACA526AVXD7Y3GZPE2KI3MLQVTKEVA5CNFSM4FDYAE22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFFDALY#issuecomment-558510127, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACA526ATA4ZQT4W4WKXU6JTQVTKEVANCNFSM4FDYAE2Q .

yiakwy avatar Dec 03 '19 15:12 yiakwy

The thread should be marked as closed because this was resolved many many months ago.

Yiak Wang Yi [email protected] 于2019年12月3日周二 下午11:13写道:

We solved the problem by downloading the file from microsoft coco website manually. Actually you can use wget or curl to download it directly.

YeShangguan [email protected] 于2019年11月26日周二 下午4:05写道:

I've got the same error. And I checked the file name. I've downloaded the wrong file mask_rcnn_ballon.h5. Then I downloaded the right file mask_rcnn_coco.h5, it worked smoothly.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/matterport/Mask_RCNN/issues/653?email_source=notifications&email_token=ACA526AVXD7Y3GZPE2KI3MLQVTKEVA5CNFSM4FDYAE22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFFDALY#issuecomment-558510127, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACA526ATA4ZQT4W4WKXU6JTQVTKEVANCNFSM4FDYAE2Q .

yiakwy avatar Dec 03 '19 15:12 yiakwy

It is solved by deleting the old h5 and redownload it again

omdxp avatar Apr 12 '20 21:04 omdxp

Solution! You need to delet the corrupted h5 file first. If you want to see where it is located, jut print the path directly as follow;

VGG_Weights_path = keras.utils.get_file( pretrained_url.split("/")[-1], pretrained_url) print(VGG_Weights_path)

shghahremani avatar Jun 20 '20 04:06 shghahremani

You just need to clear the keras model cache "del %USERPROFILE%.keras\models*"

massimobortolato avatar Oct 22 '21 07:10 massimobortolato

Traceback (most recent call last):

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 106, in h5py.h5f.open OSError: Unable to open file (truncated file: eof = 218934659, sblock->base_addr = 0, stored_eof = 450781856)

prashantmore277 avatar Jul 15 '22 09:07 prashantmore277

I'm still having the same issue while doing this in google colab. I already uploaded my model.h5 file in google drive, .made a simple script hosted in colab in the same directory as model.h5. Whenever I run my script, an error is returned. In my case its another model, not mask rcnn

script error struct

cyberkarim avatar Aug 11 '22 14:08 cyberkarim

Hi I'm getting the same error did u resolve it?

Dhaval-Mainkar avatar Sep 13 '22 20:09 Dhaval-Mainkar

Hi I'm getting the same error did u resolve it? Yes, there was a problem with the .h5 file. It wasn't uploaded correctly to drive. I had to reupload the correct version of the file.

cyberkarim avatar Sep 13 '22 22:09 cyberkarim

Hi I'm getting the same error did u resolve it?

@Dhaval-Mainkar Its happens due to intterupt during downloading files at starts👈 Hey if you are getting this error in G-colab then just use Above solution and if you get this error in your terminal in local machine then just go to cache folder and delete .ht5 cache files and then start the process of installing models again.

You can also Use This Method to delete cache👈 You just need to clear the keras model cache "del %USERPROFILE%.keras\models*"

prashantmore277 avatar Sep 14 '22 11:09 prashantmore277

Hi I'm

Re-download the h5 weight file

xiaobaiaaaaa avatar Apr 09 '23 04:04 xiaobaiaaaaa

how and where can I download the .h5 file??

abhinavaxid avatar Jul 24 '23 18:07 abhinavaxid

just clear cache and start the process again no need to download .h5 file

prashantmore277 avatar Jul 25 '23 17:07 prashantmore277