abbypa / NNProject_DeepMask

Deep Neural Network for object segmentation.
187 stars 60 forks source link

Loading model problem #2

Closed ouceduxzk closed 8 years ago

ouceduxzk commented 8 years ago

I am running the FullNetGenerator to test the model loading, comes with such problem

Using gpu device 1: Tesla K80 (CNMeM is disabled, cuDNN 4007) Traceback (most recent call last): File "FullNetGenerator.py", line 40, in fn = fng.create_full_net() File "FullNetGenerator.py", line 12, in create_full_net net = vgg_provider.get_vgg_partial_graph(weights_path=self.weights_path, with_output=False) File "/home/zaikun/dl/statefarm/NNProject_DeepMask/VggDNetGraphProvider.py", line 60, in get_vgg_partial_graph model = self.get_vgg_full_graph(weights_path, False) File "/home/zaikun/dl/statefarm/NNProject_DeepMask/VggDNetGraphProvider.py", line 56, in get_vgg_full_graph model.load_weights(weights_path) File "/users/zaikun/anaconda2/lib/python2.7/site-packages/keras/legacy/models.py", line 775, in load_weights super(Graph, self).load_weights(fname) File "/users/zaikun/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 2309, in load_weights str(len(flattened_layers)) + '.') Exception: You are trying to load a weight file containing 37 layers into a model with 0.

abbypa commented 8 years ago

You are correct- there is an issue here. If you downloaded the weights from the link in the readme file, they suit a sequential model, whereas my model is a graph (to allow a split net). You should run HelperScripts/CreateVggGraphWeights.py first to create a weights file suited for a graph. I will add this to the readme- thank you!

ouceduxzk commented 8 years ago

this HelperScripts/CreateVggGraphWeights.py runs with error

File "HelperScripts/CreateVggGraphWeights.py", line 150, in graph.set_weights(model.get_weights()) File "/users/zaikun/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 841, in set_weights params = self.trainable_weights + self.non_trainable_weights File "/users/zaikun/anaconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 1840, in trainable_weights for layer in self.layers: AttributeError: 'Graph' object has no attribute 'layers'