Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

computed output size would be negative #11

Open
vijtad opened this issue Mar 10, 2017 · 5 comments
Open

computed output size would be negative #11

vijtad opened this issue Mar 10, 2017 · 5 comments

Comments

@vijtad
Copy link

vijtad commented Mar 10, 2017

I am getting following error when I am running sticker example in Windows 10/Python 3.5/TF 0.1.

computed output size would be negative

	 [[Node: fcn_8s/vgg_16/fc6/convolution = Conv2D[T=DT_FLOAT, data_format="NHWC", padding="VALID", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/cpu:0"](fcn_8s/vgg_16/pool5/MaxPool, fcn_8s/vgg_16/fc6/weights/read)]]



Caused by op 'fcn_8s/vgg_16/fc6/convolution', defined at:

  File "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.2\visualstudio_py_launcher.py", line 78, in <module>

    vspd.debug(filename, port_num, debug_id, debug_options, run_as)

  File "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.2\visualstudio_py_debugger.py", line 2483, in debug

    exec_file(file, globals_obj)

  File "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.2\visualstudio_py_util.py", line 111, in exec_file

    exec_code(code, file, global_variables)

  File "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.2\visualstudio_py_util.py", line 87, in exec_code

    exec(code_obj, global_variables)

  File "C:\Users\vijay\Documents\Visual Studio 2015\Projects\PythonApplication3\PythonApplication3\sticker.py", line 48, in <module>

    is_training=False)

  File "C:\TensorFlow\tf-image-segmentation-master\tf_image_segmentation\utils\inference.py", line 53, in new_network_definition

    all_outputs = network_definition(*args, **kwargs)

  File "C:\TensorFlow\tf-image-segmentation-master\tf_image_segmentation\models\fcn_8s.py", line 78, in FCN_8s

    spatial_squeeze=False)

  File "C:\TensorFlow\models-master\slim\nets\vgg.py", line 165, in vgg_16

    net = slim.conv2d(net, 4096, [7, 7], padding='VALID', scope='fc6')

  File "C:\Users\vijay\Miniconda3\lib\site-packages\tensorflow\contrib\framework\python\ops\arg_scope.py", line 177, in func_with_args

    return func(*args, **current_args)

  File "C:\Users\vijay\Miniconda3\lib\site-packages\tensorflow\contrib\layers\python\layers\layers.py", line 907, in convolution

    outputs = layer.apply(inputs)

  File "C:\Users\vijay\Miniconda3\lib\site-packages\tensorflow\python\layers\base.py", line 303, in apply

    return self.__call__(inputs, **kwargs)

  File "C:\Users\vijay\Miniconda3\lib\site-packages\tensorflow\python\layers\base.py", line 273, in __call__

    outputs = self.call(inputs, **kwargs)

  File "C:\Users\vijay\Miniconda3\lib\site-packages\tensorflow\python\layers\convolutional.py", line 156, in call

    data_format=utils.convert_data_format(self.data_format, self.rank + 2))

  File "C:\Users\vijay\Miniconda3\lib\site-packages\tensorflow\python\ops\nn_ops.py", line 639, in convolution

    op=op)

  File "C:\Users\vijay\Miniconda3\lib\site-packages\tensorflow\python\ops\nn_ops.py", line 308, in with_space_to_batch

    return op(input, num_spatial_dims, padding)

  File "C:\Users\vijay\Miniconda3\lib\site-packages\tensorflow\python\ops\nn_ops.py", line 631, in op

    name=name)

  File "C:\Users\vijay\Miniconda3\lib\site-packages\tensorflow\python\ops\nn_ops.py", line 129, in _non_atrous_convolution

    name=name)

  File "C:\Users\vijay\Miniconda3\lib\site-packages\tensorflow\python\ops\gen_nn_ops.py", line 396, in conv2d

    data_format=data_format, name=name)

  File "C:\Users\vijay\Miniconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 763, in apply_op

    op_def=op_def)

  File "C:\Users\vijay\Miniconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 2327, in create_op

    original_op=self._default_original_op, op_def=op_def)

  File "C:\Users\vijay\Miniconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1226, in __init__

    self._traceback = _extract_stack()



InvalidArgumentError (see above for traceback): computed output size would be negative

	 [[Node: fcn_8s/vgg_16/fc6/convolution = Conv2D[T=DT_FLOAT, data_format="NHWC", padding="VALID", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/cpu:0"](fcn_8s/vgg_16/pool5/MaxPool, fcn_8s/vgg_16/fc6/weights/read)]]

My 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.global_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:
    

    sess.run(initializer)
    #saver.restore(sess,fcn_16s_checkpoint_path)
    saver = tf.train.Saver()
    saver.restore(sess, "C:/temp/model_fcn8s_final.ckpt")
    #path = 'C:\\temp\\model_fcn8s_final.ckpt'
    #saver = tf.train.import_meta_graph(path + '.meta')
    #saver.restore(sess, tf.train.latest_checkpoint("C:\\temp\\"))
    all_vars = tf.get_collection('vars')
    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()

@liujiaohit
Copy link

hi, do you solve the problem? I have the similar error.

@bohelion
Copy link

bohelion commented Feb 1, 2018

I have the same error.Have you solved this problem?I need your help,thanks.

@alyato
Copy link

alyato commented May 15, 2018

I also meet the same problem. But i check my code carefully, finding the number of images are setted wrong. Can help your guys hopefully. thanks.

@R-Miner
Copy link

R-Miner commented May 17, 2018

I had the same problem. For me the image size was not correct.

@zBabar
Copy link

zBabar commented May 21, 2018

can you please share more info regarding where we can make amendments to get it through

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants