Giter Site home page Giter Site logo

neuralnets's People

Contributors

creatcodebuild avatar mzaradzki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

neuralnets's Issues

TypeError: index must be integers fcn8model1 = fcn_32s_to_8s(fcn32model)

TypeError Traceback (most recent call last)
in ()
1 image_size3 = 64*8
----> 2 fcn8model3 = fcn_32s_to_8s(fcn32_blank(image_size3))
3
4 imarr3 = np.ones((3,image_size3,image_size3))
5 imarr3 = np.expand_dims(imarr3, axis=0)

/home/ankurk/ML/semanticSeg/neuralnets-master/vgg_segmentation_keras/utils.py in fcn_32s_to_8s(fcn32model)
177 (extra_margin4/2, extra_margin4/2))) # INFO : cropping as deconv gained pixels
178
--> 179 score4 = crop_margin4(s4deconv(score_fused))
180
181 # WARNING : check dimensions

/home/ankurk/anaconda3/lib/python3.5/site-packages/keras/engine/topology.py in call(self, x, mask)
515 if inbound_layers:
516 # This will call layer.build() if necessary.
--> 517 self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
518 # Outputs were already computed when calling self.add_inbound_node.
519 outputs = self.inbound_nodes[-1].output_tensors

/home/ankurk/anaconda3/lib/python3.5/site-packages/keras/engine/topology.py in add_inbound_node(self, inbound_layers, node_indices, tensor_indices)
569 # creating the node automatically updates self.inbound_nodes
570 # as well as outbound_nodes on inbound layers.
--> 571 Node.create_node(self, inbound_layers, node_indices, tensor_indices)
572
573 def get_output_shape_for(self, input_shape):

/home/ankurk/anaconda3/lib/python3.5/site-packages/keras/engine/topology.py in create_node(cls, outbound_layer, inbound_layers, node_indices, tensor_indices)
153
154 if len(input_tensors) == 1:
--> 155 output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
156 output_masks = to_list(outbound_layer.compute_mask(input_tensors[0], input_masks[0]))
157 # TODO: try to auto-infer shape if exception is raised by get_output_shape_for.

/home/ankurk/anaconda3/lib/python3.5/site-packages/keras/layers/convolutional.py in call(self, x, mask)
1761 :,
1762 self.cropping[0][0]:input_shape[2]-self.cropping[0][1],
-> 1763 self.cropping[1][0]:input_shape[3]-self.cropping[1][1]]
1764 elif self.dim_ordering == 'tf':
1765 return x[:,

/home/ankurk/anaconda3/lib/python3.5/site-packages/theano/tensor/var.py in getitem(self, args)
503 return self.take(args[axis], axis)
504 else:
--> 505 return theano.tensor.subtensor.advanced_subtensor(self, *args)
506 else:
507 if numpy.newaxis in args:

/home/ankurk/anaconda3/lib/python3.5/site-packages/theano/gof/op.py in call(self, *inputs, **kwargs)
609 """
610 return_list = kwargs.pop('return_list', False)
--> 611 node = self.make_node(*inputs, **kwargs)
612
613 if config.compute_test_value != 'off':

/home/ankurk/anaconda3/lib/python3.5/site-packages/theano/tensor/subtensor.py in make_node(self, x, *index)
2131 x = theano.tensor.as_tensor_variable(x)
2132
-> 2133 index = tuple(map(as_index_variable, index))
2134 bcast = adv_index_broadcastable_pattern(x, index)
2135 return gof.Apply(self,

/home/ankurk/anaconda3/lib/python3.5/site-packages/theano/tensor/subtensor.py in as_index_variable(idx)
2074 return NoneConst.clone()
2075 if isinstance(idx, slice):
-> 2076 return make_slice(idx)
2077 if isinstance(idx, gof.Variable) and isinstance(idx.type, SliceType):
2078 return idx

/home/ankurk/anaconda3/lib/python3.5/site-packages/theano/gof/op.py in call(self, *inputs, **kwargs)
609 """
610 return_list = kwargs.pop('return_list', False)
--> 611 node = self.make_node(*inputs, **kwargs)
612
613 if config.compute_test_value != 'off':

/home/ankurk/anaconda3/lib/python3.5/site-packages/theano/tensor/type_other.py in make_node(self, slc, stop, step)
36 inp = [slc, stop, step]
37 return Apply(self,
---> 38 list(map(as_int_none_variable, inp)),
39 [slicetype()])
40

/home/ankurk/anaconda3/lib/python3.5/site-packages/theano/tensor/type_other.py in as_int_none_variable(x)
17 x = theano.tensor.as_tensor_variable(x, ndim=0)
18 if x.type.dtype[:3] not in ('int', 'uin'):
---> 19 raise TypeError('index must be integers')
20 return x
21

TypeError: index must be integers

Negative dimension size caused by subtracting 2 from 1 for 'max_pooling2d_10/MaxPool'

The issue was born in this code (int 2 line) -
image_size1 = 64*4
fcn8model1 = fcn_32s_to_8s(fcn32_blank(image_size1))

End Error code:
ValueError Traceback (most recent call last)
in ()
----> 1 fcn32model = fcn32_blank(image_size)

/home/lumius/Dropbox/neuralnets/vgg_segmentation_keras/utils.pyc in fcn32_blank(image_size)
39
40 for l in convblock(128, 2, bits=2):
---> 41 mdl.add(l)
42
43 for l in convblock(256, 3, bits=3):

/usr/local/lib/python2.7/dist-packages/Keras-2.0.6-py2.7.egg/keras/models.pyc in add(self, layer)
467 output_shapes=[self.outputs[0]._keras_shape])
468 else:
--> 469 output_tensor = layer(self.outputs[0])
470 if isinstance(output_tensor, list):
471 raise TypeError('All layers in a Sequential model '

/usr/local/lib/python2.7/dist-packages/Keras-2.0.6-py2.7.egg/keras/engine/topology.pyc in call(self, inputs, **kwargs)
594
595 # Actually call the layer, collecting output(s), mask(s), and shape(s).
--> 596 output = self.call(inputs, **kwargs)
597 output_mask = self.compute_mask(inputs, previous_mask)
598

/usr/local/lib/python2.7/dist-packages/Keras-2.0.6-py2.7.egg/keras/layers/pooling.pyc in call(self, inputs)
152 strides=self.strides,
153 padding=self.padding,
--> 154 data_format=self.data_format)
155 return output
156

/usr/local/lib/python2.7/dist-packages/Keras-2.0.6-py2.7.egg/keras/layers/pooling.pyc in _pooling_function(self, inputs, pool_size, strides, padding, data_format)
215 output = K.pool2d(inputs, pool_size, strides,
216 padding, data_format,
--> 217 pool_mode='max')
218 return output
219

/usr/local/lib/python2.7/dist-packages/Keras-2.0.6-py2.7.egg/keras/backend/tensorflow_backend.pyc in pool2d(x, pool_size, strides, padding, data_format, pool_mode)
3376
3377 if pool_mode == 'max':
-> 3378 x = tf.nn.max_pool(x, pool_size, strides, padding=padding)
3379 elif pool_mode == 'avg':
3380 x = tf.nn.avg_pool(x, pool_size, strides, padding=padding)

/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/nn_ops.pyc in max_pool(value, ksize, strides, padding, data_format, name)
1768 padding=padding,
1769 data_format=data_format,
-> 1770 name=name)
1771
1772

/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_nn_ops.pyc in _max_pool(input, ksize, strides, padding, data_format, name)
1605 result = _op_def_lib.apply_op("MaxPool", input=input, ksize=ksize,
1606 strides=strides, padding=padding,
-> 1607 data_format=data_format, name=name)
1608 return result
1609

/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.pyc in apply_op(self, op_type_name, name, **keywords)
765 op = g.create_op(op_type_name, inputs, output_types, name=scope,
766 input_types=input_types, attrs=attr_protos,
--> 767 op_def=op_def)
768 if output_structure:
769 outputs = op.outputs

/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.pyc in create_op(self, op_type, inputs, dtypes, input_types, name, attrs, op_def, compute_shapes, compute_device)
2576 original_op=self._default_original_op, op_def=op_def)
2577 if compute_shapes:
-> 2578 set_shapes_for_outputs(ret)
2579 self._add_op(ret)
2580 self._record_op_seen_by_control_dependencies(ret)

/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.pyc in set_shapes_for_outputs(op)
1858 shape_func = _call_cpp_shape_fn_and_require_op
1859
-> 1860 shapes = shape_func(op)
1861 if shapes is None:
1862 raise RuntimeError(

/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.pyc in call_with_requiring(op)
1808
1809 def call_with_requiring(op):
-> 1810 return call_cpp_shape_fn(op, require_shape_fn=True)
1811
1812 _call_cpp_shape_fn_and_require_op = call_with_requiring

/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/common_shapes.pyc in call_cpp_shape_fn(op, require_shape_fn)
593 res = _call_cpp_shape_fn_impl(op, input_tensors_needed,
594 input_tensors_as_shapes_needed,
--> 595 require_shape_fn)
596 if not isinstance(res, dict):
597 # Handles the case where _call_cpp_shape_fn_impl calls unknown_shape(op).

/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/common_shapes.pyc in _call_cpp_shape_fn_impl(op, input_tensors_needed, input_tensors_as_shapes_needed, require_shape_fn)
657 missing_shape_fn = True
658 else:
--> 659 raise ValueError(err.message)
660
661 if missing_shape_fn:

ValueError: Negative dimension size caused by subtracting 2 from 1 for 'max_pooling2d_4/MaxPool' (op: 'MaxPool') with input shapes: [?,1,128,128].

Some questions about the FCN code

Thank you for writing this.

I have several questions about https://github.com/mzaradzki/neuralnets/tree/master/vgg_segmentation_keras/utils.py

First, Is there a specific reason for you to only define fcn32s and 2 functions to convert 32s to 16s and 8s? Is there any specific difficulties on defining 16s or 8s directly?

Second, why do you name the function fcn32_blank? Does it mean that this model is "blank" in terms of that it can not be used directly?

Thank you very much

KeyError

KeyError Traceback (most recent call last)
in ()
5 else: # INFO : use this if you downloaded weights from robots.ox.ac.uk
6 data = loadmat('./vgg-face.mat', matlab_compatible=False, struct_as_record=False)
----> 7 net = data['net'][0,0]
8 l = net.layers
9 description = net.classes[0,0].description

KeyError: 'net'

How I resolve it?

issues with notebook code

Hi, I'm trying to follow along the post below utilizing keras, with tensorflow backend.

https://aboveintelligent.com/face-recognition-with-keras-and-opencv-2baf2a83b799

Combined with the notebook you list:

https://github.com/mzaradzki/neuralnets/blob/master/vgg_faces_keras/vgg_faces_demo.ipynb

The first problem is in this part of the code:

if False:
data = loadmat('vgg-face.mat', matlab_compatible=False, struct_as_record=False)
l = data['layers']
description = data['meta'][0,0].classes[0,0].description
else:
data = loadmat('vgg_face_matconvnet/data/vgg_face.mat', matlab_compatible=False, struct_as_record=False)
net = data['net'][0,0]
l = net.layers
description = net.classes[0,0].description

The code hits the else block and fails to get past:

net = data['net'][0,0]

Traceback (most recent call last):
File "keras-vg-demo.py", line 95, in
net = data['net'][0,0]
KeyError: 'net'

Due to the net key not existing. Maybe it doesn't exist in the matlab file vgg-face.mat? I've tried to use the method in the false section instead focusing on "layers" instead of net, I get passed that error, but then I get to:

Traceback (most recent call last):
File "keras-vg-demo.py", line 144, in
copy_mat_to_keras(facemodel)
File "keras-vg-demo.py", line 137, in copy_mat_to_keras
assert (f_l_weights.shape == kmodel.layers[kindex].get_weights()[0].shape)
AssertionError

Help!
I'm trying to get some code in keras working to do basic facial recognition, and secondly face detection.

Thank you for your help! :)

Non squared images

First of all thanks for the code of the implementation. I have one question regarding the model. It only works for squared images at the moment right? When applying the last cropping it does the same cropping to both axis.

Is the project still being mantained? Do you guys accept PRs?

fcn32model = fcn32_blank(image_size) generates the "TypeError: index must be integers"

Hi, thanks for sharing the code.

I have been trying to experiment with the code of fcn16s_segmentation.ipynb. However, the line of code fcn32model = fcn32_blank(image_size) causes the following error message, what can be the reason for this? Thanks.

Using Theano backend.
Traceback (most recent call last):
File "train.py", line 20, in
fcn32model = fcn32_blank(image_size)
File "/home/FCN/fcn16s/utils.py", line 78, in fcn32_blank
(extra_margin/2, extra_margin/2))) ) # INFO : cropping as deconv gained pixels
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/Keras-1.2.1-py3.4.egg/keras/models.py", line 332, in add
output_tensor = layer(self.outputs[0])
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/Keras-1.2.1-py3.4.egg/keras/engine/topology.py", line 572, in call
self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/Keras-1.2.1-py3.4.egg/keras/engine/topology.py", line 635, in add_inbound_node
Node.create_node(self, inbound_layers, node_indices, tensor_indices)
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/Keras-1.2.1-py3.4.egg/keras/engine/topology.py", line 166, in create_node
output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/Keras-1.2.1-py3.4.egg/keras/layers/convolutional.py", line 1817, in call
self.cropping[1][0]:-self.cropping[1][1]]
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/theano/tensor/var.py", line 540, in getitem
return theano.tensor.subtensor.advanced_subtensor(self, *args)
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/theano/gof/op.py", line 604, in call
node = self.make_node(*inputs, **kwargs)
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/theano/tensor/subtensor.py", line 2140, in make_node
index = tuple(map(as_index_variable, index))
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/theano/tensor/subtensor.py", line 2081, in as_index_variable
return make_slice(idx)
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/theano/gof/op.py", line 604, in call
node = self.make_node(*inputs, **kwargs)
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/theano/tensor/type_other.py", line 39, in make_node
list(map(as_int_none_variable, inp)),
File "/devl/tensorflow/tf_0.12/lib/python3.4/site-packages/theano/tensor/type_other.py", line 20, in as_int_none_variable
raise TypeError('index must be integers')
TypeError: index must be integers

the reason of using pascal-fcn16s-dag.mat instead of weight provided by Keras pretrained model

Hi mzaradzki,

I have a question regarding your implementation of fcn16s_segmentation.ipynb, which introduces the weight of pascal-fcn16s-dag.mat for pre-trained model. Currently, Keras already provides pre-trained weight.
In order to leverage the mat-based weight, we have to use the function of copy_mat_to_keras,which can add one more layer of complexity. Are there any specific reason for this? Thanks a lot.

Huaiyang

kernel_size for fc6

For vgg_segmentation_keras I noticed that in line 50 of fcn_keras2.py kernel_size is set to 7 x 7. should that be 1 x 1?

EDIT: it seems that the original fully connected layers should be converted to equivalent fully convolutional layers. vgg16 has 7x7x512 outputs at pool5, so equivalent fc6 should have 7x7 kernel size such that the result will be exactly the same as the version that has fully connected layers should have

TypeError: index must be integers for fcn32model = fcn32_blank(image_size)

Hi,

Thanks for sharing the code, I tried fcn8s_tvg_for_rnncrf.ipynb, and it gets the following error message, which is caused by fcn32model = fcn32_blank(image_size)
would you like to take a look at it and see what might cause the problem?

Traceback (most recent call last):
File "fcn8s_tvg.py", line 18, in
fcn32model = fcn32_blank(image_size)
File "/home/GPU-Study/keras/FCN/fcn8s/utils.py", line 78, in fcn32_blank
(extra_margin/2, extra_margin/2))) ) # INFO : cropping as deconv gained pixels
File "/devl/lib/python3.4/site-packages/Keras-1.2.1-py3.4.egg/keras/models.py", line 332, in add
output_tensor = layer(self.outputs[0])
File "/devl/lib/python3.4/site-packages/Keras-1.2.1-py3.4.egg/keras/engine/topology.py", line 572, in call
self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
File "/devl/lib/python3.4/site-packages/Keras-1.2.1-py3.4.egg/keras/engine/topology.py", line 635, in add_inbound_node
Node.create_node(self, inbound_layers, node_indices, tensor_indices)
File "/devl/lib/python3.4/site-packages/Keras-1.2.1-py3.4.egg/keras/engine/topology.py", line 166, in create_node
output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
File "/devl/lib/python3.4/site-packages/Keras-1.2.1-py3.4.egg/keras/layers/convolutional.py", line 1817, in call
self.cropping[1][0]:-self.cropping[1][1]]
File "/devl/lib/python3.4/site-packages/theano/tensor/var.py", line 540, in getitem
return theano.tensor.subtensor.advanced_subtensor(self, *args)
File "/devl/lib/python3.4/site-packages/theano/gof/op.py", line 604, in call
node = self.make_node(*inputs, **kwargs)
File "/devl/lib/python3.4/site-packages/theano/tensor/subtensor.py", line 2140, in make_node
index = tuple(map(as_index_variable, index))
File "/devl/lib/python3.4/site-packages/theano/tensor/subtensor.py", line 2081, in as_index_variable
return make_slice(idx)
File "/devl/lib/python3.4/site-packages/theano/gof/op.py", line 604, in call
node = self.make_node(*inputs, **kwargs)
File "/devl/lib/python3.4/site-packages/theano/tensor/type_other.py", line 39, in make_node
list(map(as_int_none_variable, inp)),
File "/devl/lib/python3.4/site-packages/theano/tensor/type_other.py", line 20, in as_int_none_variable
raise TypeError('index must be integers')
TypeError: index must be integers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.