tf-image-segmentation
tf-image-segmentation copied to clipboard
tf 1.0 changes tf.pack -> tf.stack
tf.pack should become tf.stack. There are a number of other changes that need to be applied for tf 1.0.
https://github.com/tensorflow/tensorflow/releases
@ahundt, I guess I will create a separate branch since tf 1.0 is not backwards compatible.
the changes were quite minor
I am getting following error after changing tf.stack when I am running fcn_32s_train.ipynb
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-2-f9a75342d227> in <module>()
68 upsampled_logits_batch, vgg_16_variables_mapping = FCN_32s(image_batch_tensor=image_batch,
69 number_of_classes=number_of_classes,
---> 70 is_training=True)
71
72
/notebooks/tf-image-segmentation/tf_image_segmentation/models/fcn_32s.pyc in FCN_32s(image_batch_tensor, number_of_classes, is_training)
110 is_training=is_training,
111 spatial_squeeze=False,
--> 112 fc_conv_padding='SAME')
113
114 downsampled_logits_shape = tf.shape(logits)
/notebooks/models/slim/nets/vgg.pyc in vgg_16(inputs, num_classes, is_training, dropout_keep_prob, spatial_squeeze, scope, fc_conv_padding)
164 with slim.arg_scope([slim.conv2d, slim.fully_connected, slim.max_pool2d],
165 outputs_collections=end_points_collection):
--> 166 net = slim.repeat(inputs, 2, slim.conv2d, 64, [3, 3], scope='conv1')
167 net = slim.max_pool2d(net, [2, 2], scope='pool1')
168 net = slim.repeat(net, 2, slim.conv2d, 128, [3, 3], scope='conv2')
/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers/python/layers/layers.pyc in repeat(inputs, repetitions, layer, *args, **kwargs)
1718 for i in range(repetitions):
1719 kwargs['scope'] = scope + '_' + str(i+1)
-> 1720 outputs = layer(outputs, *args, **kwargs)
1721 return outputs
1722
/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/ops/arg_scope.pyc in func_with_args(*args, **kwargs)
175 current_args = current_scope[key_func].copy()
176 current_args.update(kwargs)
--> 177 return func(*args, **current_args)
178 _add_op(func)
179 setattr(func_with_args, '_key_op', _key_op(func))
/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers/python/layers/layers.pyc in convolution(inputs, num_outputs, kernel_size, stride, padding, data_format, rate, activation_fn, normalizer_fn, normalizer_params, weights_initializer, weights_regularizer, biases_initializer, biases_regularizer, reuse, variables_collections, outputs_collections, trainable, scope)
905 _scope=sc,
906 _reuse=reuse)
--> 907 outputs = layer.apply(inputs)
908
909 # Add variables to collections.
/usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/base.pyc in apply(self, inputs, **kwargs)
301 Output tensor(s).
302 """
--> 303 return self.__call__(inputs, **kwargs)
304
305
/usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/base.pyc in __call__(self, inputs, **kwargs)
267 input_shapes = [x.get_shape() for x in input_list]
268 if len(input_shapes) == 1:
--> 269 self.build(input_shapes[0])
270 else:
271 self.build(input_shapes)
/usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/convolutional.pyc in build(self, input_shape)
143 regularizer=self.bias_regularizer,
144 trainable=True,
--> 145 dtype=self.dtype)
146 else:
147 self.bias = None
/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.pyc in get_variable(name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, partitioner, validate_shape, custom_getter)
986 collections=collections, caching_device=caching_device,
987 partitioner=partitioner, validate_shape=validate_shape,
--> 988 custom_getter=custom_getter)
989 get_variable_or_local_docstring = (
990 """%s
/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.pyc in get_variable(self, var_store, name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, partitioner, validate_shape, custom_getter)
888 collections=collections, caching_device=caching_device,
889 partitioner=partitioner, validate_shape=validate_shape,
--> 890 custom_getter=custom_getter)
891
892 def _get_partitioned_variable(self,
/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.pyc in get_variable(self, name, shape, dtype, initializer, regularizer, reuse, trainable, collections, caching_device, partitioner, validate_shape, custom_getter)
339 reuse=reuse, trainable=trainable, collections=collections,
340 caching_device=caching_device, partitioner=partitioner,
--> 341 validate_shape=validate_shape)
342 else:
343 return _true_getter(
/usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/base.pyc in variable_getter(getter, name, shape, dtype, initializer, regularizer, trainable, **kwargs)
256 name, shape, initializer=initializer, regularizer=regularizer,
257 dtype=dtype, trainable=trainable,
--> 258 variable_getter=functools.partial(getter, **kwargs))
259
260 # Build (if necessary) and call the layer, inside a variable scope.
/usr/local/lib/python2.7/dist-packages/tensorflow/python/layers/base.pyc in _add_variable(self, name, shape, dtype, initializer, regularizer, trainable, variable_getter)
206 initializer=initializer,
207 dtype=dtype,
--> 208 trainable=trainable and self.trainable)
209 # TODO(sguada) fix name = variable.op.name
210 if variable in existing_variables:
/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers/python/layers/layers.pyc in layer_variable_getter(getter, *args, **kwargs)
1308 getter = functools.partial(current_custom_getter, getter)
1309 kwargs['rename'] = rename
-> 1310 return _model_variable_getter(getter, *args, **kwargs)
1311 return layer_variable_getter
1312
/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/layers/python/layers/layers.pyc in _model_variable_getter(getter, name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, partitioner, rename, **_)
1297 regularizer=regularizer, collections=collections, trainable=trainable,
1298 caching_device=caching_device, partitioner=partitioner,
-> 1299 custom_getter=getter)
1300
1301
/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/ops/arg_scope.pyc in func_with_args(*args, **kwargs)
175 current_args = current_scope[key_func].copy()
176 current_args.update(kwargs)
--> 177 return func(*args, **current_args)
178 _add_op(func)
179 setattr(func_with_args, '_key_op', _key_op(func))
/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/ops/variables.pyc in model_variable(name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, device, partitioner, custom_getter)
266 trainable=trainable, collections=collections,
267 caching_device=caching_device, device=device,
--> 268 partitioner=partitioner, custom_getter=custom_getter)
269 return var
270
/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/ops/arg_scope.pyc in func_with_args(*args, **kwargs)
175 current_args = current_scope[key_func].copy()
176 current_args.update(kwargs)
--> 177 return func(*args, **current_args)
178 _add_op(func)
179 setattr(func_with_args, '_key_op', _key_op(func))
/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/framework/python/ops/variables.pyc in variable(name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, device, partitioner, custom_getter)
223 collections=collections,
224 caching_device=caching_device,
--> 225 partitioner=partitioner)
226
227
/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.pyc in _true_getter(name, shape, dtype, initializer, regularizer, reuse, trainable, collections, caching_device, partitioner, validate_shape)
331 initializer=initializer, regularizer=regularizer, reuse=reuse,
332 trainable=trainable, collections=collections,
--> 333 caching_device=caching_device, validate_shape=validate_shape)
334
335 if custom_getter is not None:
/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.pyc in _get_single_variable(self, name, shape, dtype, initializer, regularizer, partition_info, reuse, trainable, collections, caching_device, validate_shape)
682 caching_device=caching_device,
683 dtype=variable_dtype,
--> 684 validate_shape=validate_shape)
685 self._vars[name] = v
686 logging.vlog(1, "Created variable %s with shape %s and init %s", v.name,
/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variables.pyc in __init__(self, initial_value, trainable, collections, validate_shape, caching_device, name, variable_def, dtype, expected_shape, import_scope)
224 name=name,
225 dtype=dtype,
--> 226 expected_shape=expected_shape)
227
228 def __str__(self):
/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variables.pyc in _init_from_args(self, initial_value, trainable, collections, validate_shape, caching_device, name, dtype, expected_shape)
301 with ops.name_scope("Initializer"), ops.device(None):
302 self._initial_value = ops.convert_to_tensor(
--> 303 initial_value(), name="initial_value", dtype=dtype)
304 shape = (self._initial_value.get_shape()
305 if validate_shape else tensor_shape.unknown_shape())
/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.pyc in <lambda>()
671 else:
672 init_val = lambda: initializer(
--> 673 shape.as_list(), dtype=dtype, partition_info=partition_info)
674 variable_dtype = dtype.base_dtype
675
TypeError: __init__() got multiple values for keyword argument 'dtype'
I think that is a general problem with tf 1.0 Might be related to https://github.com/tensorflow/models/issues/672
You are correct, it was due to tf.zeros_initializer. Due to api change, I should put parenthesis () to make it work in fc_8s.py Thanks
Is tensorflow 1.0 backend available?
I am using windows python3.5 tensorflow 1.0, and it always reports errors that I cannot fix myself.
I was able to run sticker example successfully on TF 1.0/Python 3.5 /Windows 10. I used VS 2015 to debug Python code.
Few changes has to be done to make it work.
Segmentation of sticker cat is not producing good result as described in the article.
I have attached the images.
Please give me suggestion on how to improve segmentation quality.
I have done following changes
-
In latest source code of tensorflow/models/slim/nets/vgg.py, parameter fc_conv_padding='VALID' is missing in vgg_16 method. I have to add to make it run.
-
Changed xRange to range in one of the source code upsampling.py as XRange has been replaced with range in Python 3.5.
-
tf.pack should become tf.stack.
-
tf.zeros_initializer should be replaced with tf.zeros_initializer() in vgg.py.
Source code is as follows
from __future__ import division
import os
import sys
import tensorflow as tf
import skimage.io as io
import numpy as np
sys.path.append("tf-image-segmentation/")
sys.path.append("/home/dpakhom1/workspace/my_models/slim/")
fcn_16s_checkpoint_path = \
'C:/TensorFlow/checkpoints/vgg_16.ckpt'
#os.environ["CUDA_VISIBLE_DEVICES"] = '1'
slim = tf.contrib.slim
from tf_image_segmentation.models.fcn_8s import FCN_8s
from tf_image_segmentation.utils.inference import adapt_network_for_any_size_input
from tf_image_segmentation.utils.pascal_voc import pascal_segmentation_lut
number_of_classes = 21
#image_filename = 'C:/Tensorflow/sticker/me.jpg'
image_filename = 'C:/Tensorflow/sticker/small_cat.jpg'
image_filename_placeholder = tf.placeholder(tf.string)
feed_dict_to_use = {image_filename_placeholder: image_filename}
image_tensor = tf.read_file(image_filename_placeholder)
image_tensor = tf.image.decode_jpeg(image_tensor, channels=3)
# Fake batch for image and annotation by adding
# leading empty axis.
image_batch_tensor = tf.expand_dims(image_tensor, axis=0)
# Be careful: after adaptation, network returns final labels
# and not logits
FCN_8s = adapt_network_for_any_size_input(FCN_8s, 32)
pred, fcn_16s_variables_mapping = FCN_8s(image_batch_tensor=image_batch_tensor,
number_of_classes=number_of_classes,
is_training=False)
# The op for initializing the variables.
initializer = tf.local_variables_initializer()
#saver = tf.train.Saver()
#saver = tf.train.import_meta_graph('C:/TensorFlow/checkpoints/fcn_8s_checkpoint/model_fcn8s_final.ckpt.meta', clear_devices=True)
with tf.Session() as sess:
#saver.restore(sess,fcn_16s_checkpoint_path)
saver = tf.train.Saver()
saver.restore(sess, "C:/temp/model_fcn8s_final.ckpt")
sess.run(initializer)
#path = 'C:\\temp\\model_fcn8s_final.ckpt'
#saver = tf.train.import_meta_graph(path + '.meta')
#saver.restore(sess, tf.train.latest_checkpoint("C:\\temp\\"))
print("Model restored.")
print('Initialized')
image_np, pred_np = sess.run([image_tensor, pred], feed_dict=feed_dict_to_use)
io.imshow(image_np)
io.show()
io.imshow(pred_np.squeeze())
io.show()
# Eroding countour
import skimage.morphology
prediction_mask = (pred_np.squeeze() == 8)
# Let's apply some morphological operations to
# create the contour for our sticker
cropped_object = image_np * np.dstack((prediction_mask,) * 3)
square = skimage.morphology.square(5)
temp = skimage.morphology.binary_erosion(prediction_mask, square)
negative_mask = (temp != True)
eroding_countour = negative_mask * prediction_mask
eroding_countour_img = np.dstack((eroding_countour, ) * 3)
cropped_object[eroding_countour_img] = 248
png_transparancy_mask = np.uint8(prediction_mask * 255)
image_shape = cropped_object.shape
png_array = np.zeros(shape=[image_shape[0], image_shape[1], 4], dtype=np.uint8)
png_array[:, :, :3] = cropped_object
png_array[:, :, 3] = png_transparancy_mask
io.imshow(cropped_object)
io.imsave('C:/Tensorflow/sticker/sticker_cat.png', png_array)
vgg.py code is as follows
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Contains model definitions for versions of the Oxford VGG network.
These model definitions were introduced in the following technical report:
Very Deep Convolutional Networks For Large-Scale Image Recognition
Karen Simonyan and Andrew Zisserman
arXiv technical report, 2015
PDF: http://arxiv.org/pdf/1409.1556.pdf
ILSVRC 2014 Slides: http://www.robots.ox.ac.uk/~karen/pdf/ILSVRC_2014.pdf
CC-BY-4.0
More information can be obtained from the VGG website:
www.robots.ox.ac.uk/~vgg/research/very_deep/
Usage:
with slim.arg_scope(vgg.vgg_arg_scope()):
outputs, end_points = vgg.vgg_a(inputs)
with slim.arg_scope(vgg.vgg_arg_scope()):
outputs, end_points = vgg.vgg_16(inputs)
@@vgg_a
@@vgg_16
@@vgg_19
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
slim = tf.contrib.slim
def vgg_arg_scope(weight_decay=0.0005):
"""Defines the VGG arg scope.
Args:
weight_decay: The l2 regularization coefficient.
Returns:
An arg_scope.
"""
with slim.arg_scope([slim.conv2d, slim.fully_connected],
activation_fn=tf.nn.relu,
weights_regularizer=slim.l2_regularizer(weight_decay),
biases_initializer=tf.zeros_initializer()):
with slim.arg_scope([slim.conv2d], padding='SAME') as arg_sc:
return arg_sc
def vgg_a(inputs,
num_classes=1000,
is_training=True,
dropout_keep_prob=0.5,
spatial_squeeze=True,
scope='vgg_a'):
"""Oxford Net VGG 11-Layers version A Example.
Note: All the fully_connected layers have been transformed to conv2d layers.
To use in classification mode, resize input to 224x224.
Args:
inputs: a tensor of size [batch_size, height, width, channels].
num_classes: number of predicted classes.
is_training: whether or not the model is being trained.
dropout_keep_prob: the probability that activations are kept in the dropout
layers during training.
spatial_squeeze: whether or not should squeeze the spatial dimensions of the
outputs. Useful to remove unnecessary dimensions for classification.
scope: Optional scope for the variables.
Returns:
the last op containing the log predictions and end_points dict.
"""
with tf.variable_scope(scope, 'vgg_a', [inputs]) as sc:
end_points_collection = sc.name + '_end_points'
# Collect outputs for conv2d, fully_connected and max_pool2d.
with slim.arg_scope([slim.conv2d, slim.max_pool2d],
outputs_collections=end_points_collection):
net = slim.repeat(inputs, 1, slim.conv2d, 64, [3, 3], scope='conv1')
net = slim.max_pool2d(net, [2, 2], scope='pool1')
net = slim.repeat(net, 1, slim.conv2d, 128, [3, 3], scope='conv2')
net = slim.max_pool2d(net, [2, 2], scope='pool2')
net = slim.repeat(net, 2, slim.conv2d, 256, [3, 3], scope='conv3')
net = slim.max_pool2d(net, [2, 2], scope='pool3')
net = slim.repeat(net, 2, slim.conv2d, 512, [3, 3], scope='conv4')
net = slim.max_pool2d(net, [2, 2], scope='pool4')
net = slim.repeat(net, 2, slim.conv2d, 512, [3, 3], scope='conv5')
net = slim.max_pool2d(net, [2, 2], scope='pool5')
# Use conv2d instead of fully_connected layers.
net = slim.conv2d(net, 4096, [7, 7], padding='VALID', scope='fc6')
net = slim.dropout(net, dropout_keep_prob, is_training=is_training,
scope='dropout6')
net = slim.conv2d(net, 4096, [1, 1], scope='fc7')
net = slim.dropout(net, dropout_keep_prob, is_training=is_training,
scope='dropout7')
net = slim.conv2d(net, num_classes, [1, 1],
activation_fn=None,
normalizer_fn=None,
scope='fc8')
# Convert end_points_collection into a end_point dict.
end_points = slim.utils.convert_collection_to_dict(end_points_collection)
if spatial_squeeze:
net = tf.squeeze(net, [1, 2], name='fc8/squeezed')
end_points[sc.name + '/fc8'] = net
return net, end_points
vgg_a.default_image_size = 224
def vgg_16(inputs,
num_classes=1000,
is_training=True,
dropout_keep_prob=0.5,
spatial_squeeze=True,
scope='vgg_16',
fc_conv_padding='VALID'):
"""Oxford Net VGG 16-Layers version D Example.
Note: All the fully_connected layers have been transformed to conv2d layers.
To use in classification mode, resize input to 224x224.
Args:
inputs: a tensor of size [batch_size, height, width, channels].
num_classes: number of predicted classes.
is_training: whether or not the model is being trained.
dropout_keep_prob: the probability that activations are kept in the dropout
layers during training.
spatial_squeeze: whether or not should squeeze the spatial dimensions of the
outputs. Useful to remove unnecessary dimensions for classification.
scope: Optional scope for the variables.
Returns:
the last op containing the log predictions and end_points dict.
"""
with tf.variable_scope(scope, 'vgg_16', [inputs]) as sc:
end_points_collection = sc.name + '_end_points'
# Collect outputs for conv2d, fully_connected and max_pool2d.6
with slim.arg_scope([slim.conv2d, slim.fully_connected, slim.max_pool2d],
outputs_collections=end_points_collection):
net = slim.repeat(inputs, 2, slim.conv2d, 64, [3, 3], scope='conv1')
net = slim.max_pool2d(net, [2, 2], scope='pool1')
net = slim.repeat(net, 2, slim.conv2d, 128, [3, 3], scope='conv2')
net = slim.max_pool2d(net, [2, 2], scope='pool2')
net = slim.repeat(net, 3, slim.conv2d, 256, [3, 3], scope='conv3')
net = slim.max_pool2d(net, [2, 2], scope='pool3')
net = slim.repeat(net, 3, slim.conv2d, 512, [3, 3], scope='conv4')
net = slim.max_pool2d(net, [2, 2], scope='pool4')
net = slim.repeat(net, 3, slim.conv2d, 512, [3, 3], scope='conv5')
net = slim.max_pool2d(net, [2, 2], scope='pool5')
# Use conv2d instead of fully_connected layers.
net = slim.conv2d(net, 4096, [7, 7], padding=fc_conv_padding, scope='fc6')
net = slim.dropout(net, dropout_keep_prob, is_training=is_training,
scope='dropout6')
net = slim.conv2d(net, 4096, [1, 1], scope='fc7')
net = slim.dropout(net, dropout_keep_prob, is_training=is_training,
scope='dropout7')
net = slim.conv2d(net, num_classes, [1, 1],
activation_fn=None,
normalizer_fn=None,
scope='fc8')
# Convert end_points_collection into a end_point dict.
end_points = slim.utils.convert_collection_to_dict(end_points_collection)
if spatial_squeeze:
net = tf.squeeze(net, [1, 2], name='fc8/squeezed')
end_points[sc.name + '/fc8'] = net
return net, end_points
vgg_16.default_image_size = 224
def vgg_19(inputs,
num_classes=1000,
is_training=True,
dropout_keep_prob=0.5,
spatial_squeeze=True,
scope='vgg_19'):
"""Oxford Net VGG 19-Layers version E Example.
Note: All the fully_connected layers have been transformed to conv2d layers.
To use in classification mode, resize input to 224x224.
Args:
inputs: a tensor of size [batch_size, height, width, channels].
num_classes: number of predicted classes.
is_training: whether or not the model is being trained.
dropout_keep_prob: the probability that activations are kept in the dropout
layers during training.
spatial_squeeze: whether or not should squeeze the spatial dimensions of the
outputs. Useful to remove unnecessary dimensions for classification.
scope: Optional scope for the variables.
Returns:
the last op containing the log predictions and end_points dict.
"""
with tf.variable_scope(scope, 'vgg_19', [inputs]) as sc:
end_points_collection = sc.name + '_end_points'
# Collect outputs for conv2d, fully_connected and max_pool2d.
with slim.arg_scope([slim.conv2d, slim.fully_connected, slim.max_pool2d],
outputs_collections=end_points_collection):
net = slim.repeat(inputs, 2, slim.conv2d, 64, [3, 3], scope='conv1')
net = slim.max_pool2d(net, [2, 2], scope='pool1')
net = slim.repeat(net, 2, slim.conv2d, 128, [3, 3], scope='conv2')
net = slim.max_pool2d(net, [2, 2], scope='pool2')
net = slim.repeat(net, 4, slim.conv2d, 256, [3, 3], scope='conv3')
net = slim.max_pool2d(net, [2, 2], scope='pool3')
net = slim.repeat(net, 4, slim.conv2d, 512, [3, 3], scope='conv4')
net = slim.max_pool2d(net, [2, 2], scope='pool4')
net = slim.repeat(net, 4, slim.conv2d, 512, [3, 3], scope='conv5')
net = slim.max_pool2d(net, [2, 2], scope='pool5')
# Use conv2d instead of fully_connected layers.
net = slim.conv2d(net, 4096, [7, 7], padding='VALID', scope='fc6')
net = slim.dropout(net, dropout_keep_prob, is_training=is_training,
scope='dropout6')
net = slim.conv2d(net, 4096, [1, 1], scope='fc7')
net = slim.dropout(net, dropout_keep_prob, is_training=is_training,
scope='dropout7')
net = slim.conv2d(net, num_classes, [1, 1],
activation_fn=None,
normalizer_fn=None,
scope='fc8')
# Convert end_points_collection into a end_point dict.
end_points = slim.utils.convert_collection_to_dict(end_points_collection)
if spatial_squeeze:
net = tf.squeeze(net, [1, 2], name='fc8/squeezed')
end_points[sc.name + '/fc8'] = net
return net, end_points
vgg_19.default_image_size = 224
# Alias
vgg_d = vgg_16
vgg_e = vgg_19
Thanks for the reply. I just find a way to use tensorflow upgrade tool to upgrade the folder models
and tf-image-segmentation
automatically. And it works fine now.
Also I think if you use fcn_8s_checkpoint_path = "C:/TensorFlow/checkpoints/vgg_8.ckpt"
instead of fcn_16s_checkpoint_path = "C:/TensorFlow/checkpoints/vgg_16.ckpt"
, it may produce better segmentation result. But I am not sure.
fcn_16s_checkpoint_path variable is not being used in the code.
I am using model_fcn8s_final.ckpt provided in dropbox.
saver.restore(sess, "C:/temp/model_fcn8s_final.ckpt")
What is the image size of this cat ?
I have this cat size as width = 144 and height = 85.
I am getting good segmentation of me.jpg and image size is 400x400.
I would like to whether segmentation depends on image size.
On Sat, Mar 11, 2017 at 9:36 PM, zhaozj89 [email protected] wrote:
Also I think if you use fcn_8s_checkpoint_path = 'C:/TensorFlow/checkpoints/vgg_8.ckpt' instead of ``fcn_16s_checkpoint_path = 'C:/TensorFlow/checkpoints/vgg_16.ckpt', it may produce better segmentation result. But I am not sure.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/warmspringwinds/tf-image-segmentation/issues/8#issuecomment-285917018, or mute the thread https://github.com/notifications/unsubscribe-auth/AFye3To4b2Aulvg9VRT8Z4cnxW0gHoyYks5rk1oqgaJpZM4MACdU .
@vijtad can you please submit a pull request with your changes rather than including them in comments? That allows us to review and merge the code.
Here are two documents that explain how: https://gist.github.com/Chaser324/ce0505fbed06b947d962 https://help.github.com/categories/collaborating-with-issues-and-pull-requests/
Hi @warmspringwinds, @vijtad, @ahundt,
I took the liberty of submitting a PR that adds forward/backward compatibility for tf-1.0.x with version checks at all the fail points in the code based on the output of tf_upgrade_tool.py as suggested by @zhaozj89.
Please have a look and consider merging. As I say in the PR though, I'm unsure if this type of forward/backward compatibility version checking is the best approach for future maintainability. E.g. it would probably break future applications of tf_upgrade_tool.py. In order to retain that option, maintaining separate branches might be better. In any case, I'll leave it up to you.
Hi @barryridge Just tested for the tf_upgrade_tool.py and it worked like a charm. :) :+1:
@vijtad I refer your code and got an error below, any idea? I also found that you use prediction_mask = (pred_np.squeeze() == 8)
instead of prediction_mask = (pred_np.squeeze() == 15)
, why?
Any suggestion is appreciated, thanks.
/usr/local/lib/python2.7/dist-packages/ipykernel_launcher.py:77: VisibleDeprecationWarning: boolean index did not match indexed array along dimension 0; dimension is 1 but corresponding boolean dimension is 360
ValueError Traceback (most recent call last)
<ipython-input-1-16f3a3a662ba> in <module>()
83 png_array = np.zeros(shape=[image_shape[0], image_shape[1], 4], dtype=np.uint8)
84
---> 85 png_array[:, :, :3] = cropped_object
86
87 png_array[:, :, 3] = png_transparancy_mask
ValueError: could not broadcast input array from shape (360,480,3) into shape (1,360,3)