{
  "id": 124204,
  "title": "Issue downloading a weights file from the internet",
  "url": "/competitions/bengaliai-cv19/discussion/124204",
  "author_name": "",
  "post_date": "2020-01-02T15:02:48.151566Z",
  "votes": null,
  "comment_count": 3,
  "views": 0,
  "content": "<p>Hi there. \nIt's been a while. Now I try to do my first submission through a notebook. I want to download some weights from the internet. My code and the error message, see below. What did I do wrong? What can I do to fix it? </p>\n\n<p><code>from keras.utils.data_utils import get_file\nweights_path = get_file(\n            'model_weights_modified.h5',\n            'https://www.mightybird.de/model_weights_modified.h5')\nprint ('path command ok...')\nprint (weights_path)\nmodel.load_weights(weights_path)</code></p>\n\n<p><code>\npath command ok...\n/tmp/.keras/datasets/model_weights_modified.h5\n</code></p>\n\n<p>OSError: Unable to open file (file signature not found)</p>\n\n<hr>\n\n<p>OSError                                   Traceback (most recent call last)\n in \n      5 print ('path command ok...')\n      6 print (weights_path)\n----&gt; 7 model.load_weights(weights_path)</p>\n\n<p>/opt/conda/lib/python3.6/site-packages/keras/engine/saving.py in load_wrapper(*args, **kwargs)\n    490                 os.remove(tmp_filepath)\n    491             return res\n--&gt; 492         return load_function(*args, **kwargs)\n    493 \n    494     return load_wrapper</p>\n\n<p>/opt/conda/lib/python3.6/site-packages/keras/engine/network.py in load_weights(self, filepath, by_name, skip_mismatch, reshape)\n   1219         if h5py is None:\n   1220             raise ImportError('<code>load_weights</code> requires h5py.')\n-&gt; 1221         with h5py.File(filepath, mode='r') as f:\n   1222             if 'layer_names' not in f.attrs and 'model_weights' in f:\n   1223                 f = f['model_weights']</p>\n\n<p>/opt/conda/lib/python3.6/site-packages/h5py/_hl/files.py in <strong>init</strong>(self, name, mode, driver, libver, userblock_size, swmr, rdcc_nslots, rdcc_nbytes, rdcc_w0, track_order, **kwds)\n    392                 fid = make_fid(name, mode, userblock_size,\n    393                                fapl, fcpl=make_fcpl(track_order=track_order),\n--&gt; 394                                swmr=swmr)\n    395 \n    396             if swmr_support:</p>\n\n<p>/opt/conda/lib/python3.6/site-packages/h5py/_hl/files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)\n    168         if swmr and swmr_support:\n    169             flags |= h5f.ACC_SWMR_READ\n--&gt; 170         fid = h5f.open(name, flags, fapl=fapl)\n    171     elif mode == 'r+':\n    172         fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)</p>\n\n<p>h5py/_objects.pyx in h5py._objects.with_phil.wrapper()</p>\n\n<p>h5py/_objects.pyx in h5py._objects.with_phil.wrapper()</p>\n\n<p>h5py/h5f.pyx in h5py.h5f.open()</p>\n\n<p>OSError: Unable to open file (file signature not found)</p>",
  "messages": [
    {
      "id": "708696",
      "postDate": "01/02/2020 15:02:48",
      "content": "<p>Hi there. \nIt's been a while. Now I try to do my first submission through a notebook. I want to download some weights from the internet. My code and the error message, see below. What did I do wrong? What can I do to fix it? </p>\n\n<p><code>from keras.utils.data_utils import get_file\nweights_path = get_file(\n            'model_weights_modified.h5',\n            'https://www.mightybird.de/model_weights_modified.h5')\nprint ('path command ok...')\nprint (weights_path)\nmodel.load_weights(weights_path)</code></p>\n\n<p><code>\npath command ok...\n/tmp/.keras/datasets/model_weights_modified.h5\n</code></p>\n\n<p>OSError: Unable to open file (file signature not found)</p>\n\n<hr>\n\n<p>OSError                                   Traceback (most recent call last)\n in \n      5 print ('path command ok...')\n      6 print (weights_path)\n----&gt; 7 model.load_weights(weights_path)</p>\n\n<p>/opt/conda/lib/python3.6/site-packages/keras/engine/saving.py in load_wrapper(*args, **kwargs)\n    490                 os.remove(tmp_filepath)\n    491             return res\n--&gt; 492         return load_function(*args, **kwargs)\n    493 \n    494     return load_wrapper</p>\n\n<p>/opt/conda/lib/python3.6/site-packages/keras/engine/network.py in load_weights(self, filepath, by_name, skip_mismatch, reshape)\n   1219         if h5py is None:\n   1220             raise ImportError('<code>load_weights</code> requires h5py.')\n-&gt; 1221         with h5py.File(filepath, mode='r') as f:\n   1222             if 'layer_names' not in f.attrs and 'model_weights' in f:\n   1223                 f = f['model_weights']</p>\n\n<p>/opt/conda/lib/python3.6/site-packages/h5py/_hl/files.py in <strong>init</strong>(self, name, mode, driver, libver, userblock_size, swmr, rdcc_nslots, rdcc_nbytes, rdcc_w0, track_order, **kwds)\n    392                 fid = make_fid(name, mode, userblock_size,\n    393                                fapl, fcpl=make_fcpl(track_order=track_order),\n--&gt; 394                                swmr=swmr)\n    395 \n    396             if swmr_support:</p>\n\n<p>/opt/conda/lib/python3.6/site-packages/h5py/_hl/files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)\n    168         if swmr and swmr_support:\n    169             flags |= h5f.ACC_SWMR_READ\n--&gt; 170         fid = h5f.open(name, flags, fapl=fapl)\n    171     elif mode == 'r+':\n    172         fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)</p>\n\n<p>h5py/_objects.pyx in h5py._objects.with_phil.wrapper()</p>\n\n<p>h5py/_objects.pyx in h5py._objects.with_phil.wrapper()</p>\n\n<p>h5py/h5f.pyx in h5py.h5f.open()</p>\n\n<p>OSError: Unable to open file (file signature not found)</p>",
      "rawMarkdown": "Hi there. \nIt's been a while. Now I try to do my first submission through a notebook. I want to download some weights from the internet. My code and the error message, see below. What did I do wrong? What can I do to fix it? \n\n\n`from keras.utils.data_utils import get_file\nweights_path = get_file(\n            'model_weights_modified.h5',\n            'https://www.mightybird.de/model_weights_modified.h5')\nprint ('path command ok...')\nprint (weights_path)\nmodel.load_weights(weights_path)`\n\n```\npath command ok...\n/tmp/.keras/datasets/model_weights_modified.h5\n```\n\nOSError: Unable to open file (file signature not found)\n\n\n---------------------------------------------------------------------------\nOSError                                   Traceback (most recent call last)",
      "votes": null
    },
    {
      "id": "708705",
      "postDate": "01/02/2020 15:13:10",
      "content": "<p>Sorry  but Editor keeps truncating my trace..</p>\n\n<p>So maybe here:</p>\n\n<p> in \n      5 print ('path command ok...')\n      6 print (weights_path)\n----&gt; 7 model.load_weights(weights_path)</p>\n\n<p>/opt/conda/lib/python3.6/site-packages/keras/engine/saving.py in load_wrapper(*args, **kwargs)\n    490                 os.remove(tmp_filepath)\n    491             return res\n--&gt; 492         return load_function(*args, **kwargs)\n    493 \n    494     return load_wrapper</p>\n\n<p>/opt/conda/lib/python3.6/site-packages/keras/engine/network.py in load_weights(self, filepath, by_name, skip_mismatch, reshape)\n   1219         if h5py is None:\n   1220             raise ImportError('<code>load_weights</code> requires h5py.')\n-&gt; 1221         with h5py.File(filepath, mode='r') as f:\n   1222             if 'layer_names' not in f.attrs and 'model_weights' in f:\n   1223                 f = f['model_weights']</p>\n\n<p>/opt/conda/lib/python3.6/site-packages/h5py/_hl/files.py in <strong>init</strong>(self, name, mode, driver, libver, userblock_size, swmr, rdcc_nslots, rdcc_nbytes, rdcc_w0, track_order, **kwds)\n    392                 fid = make_fid(name, mode, userblock_size,\n    393                                fapl, fcpl=make_fcpl(track_order=track_order),\n--&gt; 394                                swmr=swmr)\n    395 \n    396             if swmr_support:</p>\n\n<p>/opt/conda/lib/python3.6/site-packages/h5py/_hl/files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)\n    168         if swmr and swmr_support:\n    169             flags |= h5f.ACC_SWMR_READ\n--&gt; 170         fid = h5f.open(name, flags, fapl=fapl)\n    171     elif mode == 'r+':\n    172         fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)</p>\n\n<p>h5py/_objects.pyx in h5py._objects.with_phil.wrapper()</p>\n\n<p>h5py/_objects.pyx in h5py._objects.with_phil.wrapper()</p>\n\n<p>h5py/h5f.pyx in h5py.h5f.open()</p>\n\n<p>OSError: Unable to open file (file signature not found)</p>",
      "rawMarkdown": "Sorry  but Editor keeps truncating my trace..\n\nSo maybe here:",
      "votes": null
    },
    {
      "id": "708707",
      "postDate": "01/02/2020 15:15:51",
      "content": "<p>Trace as attachment</p>",
      "rawMarkdown": "Trace as attachment",
      "votes": null
    },
    {
      "id": "708751",
      "postDate": "01/02/2020 16:14:39",
      "content": "<p>You can't use the internet to make submission as this is KO-competition. The best way would be to upload your model weights as kaggle dataset and use it in your notebook to make submission</p>",
      "rawMarkdown": "You can't use the internet to make submission as this is KO-competition. The best way would be to upload your model weights as kaggle dataset and use it in your notebook to make submission",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 708705,
      "author_name": "mightybird",
      "author_url": "",
      "post_date": "01/02/2020 15:13:10",
      "content": "<p>Sorry  but Editor keeps truncating my trace..</p>\n\n<p>So maybe here:</p>\n\n<p> in \n      5 print ('path command ok...')\n      6 print (weights_path)\n----&gt; 7 model.load_weights(weights_path)</p>\n\n<p>/opt/conda/lib/python3.6/site-packages/keras/engine/saving.py in load_wrapper(*args, **kwargs)\n    490                 os.remove(tmp_filepath)\n    491             return res\n--&gt; 492         return load_function(*args, **kwargs)\n    493 \n    494     return load_wrapper</p>\n\n<p>/opt/conda/lib/python3.6/site-packages/keras/engine/network.py in load_weights(self, filepath, by_name, skip_mismatch, reshape)\n   1219         if h5py is None:\n   1220             raise ImportError('<code>load_weights</code> requires h5py.')\n-&gt; 1221         with h5py.File(filepath, mode='r') as f:\n   1222             if 'layer_names' not in f.attrs and 'model_weights' in f:\n   1223                 f = f['model_weights']</p>\n\n<p>/opt/conda/lib/python3.6/site-packages/h5py/_hl/files.py in <strong>init</strong>(self, name, mode, driver, libver, userblock_size, swmr, rdcc_nslots, rdcc_nbytes, rdcc_w0, track_order, **kwds)\n    392                 fid = make_fid(name, mode, userblock_size,\n    393                                fapl, fcpl=make_fcpl(track_order=track_order),\n--&gt; 394                                swmr=swmr)\n    395 \n    396             if swmr_support:</p>\n\n<p>/opt/conda/lib/python3.6/site-packages/h5py/_hl/files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)\n    168         if swmr and swmr_support:\n    169             flags |= h5f.ACC_SWMR_READ\n--&gt; 170         fid = h5f.open(name, flags, fapl=fapl)\n    171     elif mode == 'r+':\n    172         fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)</p>\n\n<p>h5py/_objects.pyx in h5py._objects.with_phil.wrapper()</p>\n\n<p>h5py/_objects.pyx in h5py._objects.with_phil.wrapper()</p>\n\n<p>h5py/h5f.pyx in h5py.h5f.open()</p>\n\n<p>OSError: Unable to open file (file signature not found)</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 708707,
      "author_name": "mightybird",
      "author_url": "",
      "post_date": "01/02/2020 15:15:51",
      "content": "<p>Trace as attachment</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 708751,
      "author_name": "bibek777",
      "author_url": "",
      "post_date": "01/02/2020 16:14:39",
      "content": "<p>You can't use the internet to make submission as this is KO-competition. The best way would be to upload your model weights as kaggle dataset and use it in your notebook to make submission</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "708696": "Hi there. \nIt's been a while. Now I try to do my first submission through a notebook. I want to download some weights from the internet. My code and the error message, see below. What did I do wrong? What can I do to fix it? \n\n\n`from keras.utils.data_utils import get_file\nweights_path = get_file(\n            'model_weights_modified.h5',\n            'https://www.mightybird.de/model_weights_modified.h5')\nprint ('path command ok...')\nprint (weights_path)\nmodel.load_weights(weights_path)`\n\n```\npath command ok...\n/tmp/.keras/datasets/model_weights_modified.h5\n```\n\nOSError: Unable to open file (file signature not found)\n\n\n---------------------------------------------------------------------------\nOSError                                   Traceback (most recent call last)",
    "708705": "Sorry  but Editor keeps truncating my trace..\n\nSo maybe here:",
    "708707": "Trace as attachment",
    "708751": "You can't use the internet to make submission as this is KO-competition. The best way would be to upload your model weights as kaggle dataset and use it in your notebook to make submission"
  },
  "source": "meta"
}