aurora95 / Keras-FCN

Keras-tensorflow implementation of Fully Convolutional Networks for Semantic Segmentation(Unfinished)
MIT License
650 stars 268 forks source link

Error in load_weights: no h5 file #3

Closed Fansiee closed 7 years ago

Fansiee commented 7 years ago

When I run python train.py, it goes wrong. I wander where is the h5 format file. Could you please help me with this problem

Traceback (most recent call last):
  File "train.py", line 120, in <module>
    data_dir, label_dir, target_size=target_size, batchnorm_momentum=batchnorm_momentum, resume_training=resume_training)
  File "train.py", line 49, in train
    model = globals()[model_name](weight_decay=weight_decay, input_shape=input_shape, batch_momentum=batchnorm_momentum)
  File "/home/cv/keras-fcn/Keras-FCN-master/models.py", line 209, in AtrousFCN_Resnet50_16s
    model.load_weights(weights_path, by_name=True)
  File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 2702, in load_weights
    f = h5py.File(filepath, mode='r')
  File "/usr/local/lib/python2.7/dist-packages/h5py/_hl/files.py", line 272, in __init__
    fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
  File "/usr/local/lib/python2.7/dist-packages/h5py/_hl/files.py", line 92, in make_fid
    fid = h5f.open(name, flags, fapl=fapl)
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (/tmp/pip-4rPeHA-build/h5py/_objects.c:2684)
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (/tmp/pip-4rPeHA-build/h5py/_objects.c:2642)
  File "h5py/h5f.pyx", line 76, in h5py.h5f.open (/tmp/pip-4rPeHA-build/h5py/h5f.c:1930)
IOError: Unable to open file (Unable to open file: name = '/home/cv/.keras/models/fcn_resnet50_weights_tf_dim_ordering_tf_kernels.h5', errno = 2, error message = 'no such file or directory', flags = 0, o_flags = 0)
SCP-173-cool commented 7 years ago

U need run util/get_weights_path.py and transfer_FCN.py first

Fansiee commented 7 years ago

Thank you very much! I just find it right now! Maybe there should be a simple tutorial for beginners~

simonsayshi commented 6 years ago

@SCP-173-cool hi, I ran the transfer_FCN but it returned an error:

File "C:/Users/simonsayshi/Desktop/python scripts/Keras-FCN-master/Keras-FCN-master/utils/transfer_FCN.py", line 144, in if sys.argv[1] not in {'Vgg16', 'ResNet50'}:

IndexError: list index out of range

I've been struggling for a very long time but have no idea..any suggestion?

RichardSieg commented 6 years ago

Hi @simonsayshi . This means, that you have to specify a keyword argument, either Vgg16 or ResNet50. This means you have to run e.g. python utils/transfer_FCN.py ResNet50

RichardSieg commented 6 years ago

I also got the AttributeError: 'dict' object has no attribute 'has_key' Error. Fixed this by changing to

if layer.name in index:
                index[layer.name].set_weights(weights)
leeivan1007 commented 6 years ago

@RichardSieg thx! it is can work for me

gokberkyar commented 5 years ago

U need run util/get_weights_path.py and transfer_FCN.py first

You save the day