Facenet: questions about the input images size

Created on 31 Aug 2017  路  11Comments  路  Source: davidsandberg/facenet

image

here are the first several lines in inception-resnet-v1. it seems the input image size is 299 or so. but in compare.py line104:
image

the image was resized to 160. and, images for training are also of the same size. so how does 160 sized images was fed into the net

Most helpful comment

@pavankumarkatakam Hi. I have met the same problem with you. Has your problem been solved? How?

All 11 comments

The inception-resnet-v1 input size can be of any size, because the network have a avg_pool2d.

@zt383154 thank you very much!! i was perplexed by the comment for such a long time :-(

But when im creating the embeddings using the .pb file listed in this project and image size with 50 im getting the following error

Calculating features for images
2017-09-02 09:46:31.250573: W tensorflow/core/framework/op_kernel.cc:1158] Invalid argument: computed output size would be negative
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1139, in _do_call
    return fn(*args)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1121, in _run_fn
    status, run_metadata)
  File "/usr/lib/python3.5/contextlib.py", line 66, in __exit__
    next(self.gen)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status
    pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: computed output size would be negative
     [[Node: InceptionResnetV1/Logits/AvgPool_1a_8x8/AvgPool = AvgPool[T=DT_FLOAT, data_format="NHWC", ksize=[1, 3, 3, 1], padding="VALID", strides=[1, 1, 1, 1], _device="/job:localhost/replica:0/task:0/gpu:0"](InceptionResnetV1/Block8/add)]]
     [[Node: embeddings/_679 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_12539_embeddings", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "createEmbeddings.py", line 140, in <module>
    main(parse_arguments(sys.argv[1:]))
  File "createEmbeddings.py", line 97, in main
    emb_array[start_index:end_index,:] = sess.run(embeddings, feed_dict=feed_dict)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 789, in run
    run_metadata_ptr)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 997, in _run
    feed_dict_string, options, run_metadata)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1132, in _do_run
    target_list, options, run_metadata)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1152, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: computed output size would be negative
     [[Node: InceptionResnetV1/Logits/AvgPool_1a_8x8/AvgPool = AvgPool[T=DT_FLOAT, data_format="NHWC", ksize=[1, 3, 3, 1], padding="VALID", strides=[1, 1, 1, 1], _device="/job:localhost/replica:0/task:0/gpu:0"](InceptionResnetV1/Block8/add)]]
     [[Node: embeddings/_679 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_12539_embeddings", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

Caused by op 'InceptionResnetV1/Logits/AvgPool_1a_8x8/AvgPool', defined at:
  File "createEmbeddings.py", line 140, in <module>
    main(parse_arguments(sys.argv[1:]))
  File "createEmbeddings.py", line 59, in main
    facenet.load_model(args.model)
  File "/media/pavankumar/PAVANDL/facenet/src/facenet.py", line 380, in load_model
    tf.import_graph_def(graph_def, name='')
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/importer.py", line 311, in import_graph_def
    op_def=op_def)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py", line 2506, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py", line 1269, in __init__
    self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): computed output size would be negative
     [[Node: InceptionResnetV1/Logits/AvgPool_1a_8x8/AvgPool = AvgPool[T=DT_FLOAT, data_format="NHWC", ksize=[1, 3, 3, 1], padding="VALID", strides=[1, 1, 1, 1], _device="/job:localhost/replica:0/task:0/gpu:0"](InceptionResnetV1/Block8/add)]]
     [[Node: embeddings/_679 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_12539_embeddings", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

@pavankumarkatakam I think the input image size is too small to cause the output size of the layer to be negative. When the convolution kernel size of a layer is 3x3, the output may be negative when the input size is less than 3x3.

So what is the minimum image size ? 160?

I think the minimum input for the avgpool layer is size 1x1. When the input size is 160x160, the avgpool layer is input to 3X3, so the input size can be less than 160x160. But I don't know the smallest size because I didn't test it

I have successfully used an image size of 100x100 for a custom dataset. Did you specify the image_size?

Closed due to inactivity. Reopen if needed.

@pavankumarkatakam Hi. I have met the same problem with you. Has your problem been solved? How?

@pavankumarkatakam @Zhangwanwanwan Did you solve the problem?

padding="VALID"---->padding="SAME"

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Zumbalamambo picture Zumbalamambo  路  3Comments

kuaikuaikim picture kuaikuaikim  路  3Comments

Leedonggeon picture Leedonggeon  路  3Comments

Feynman27 picture Feynman27  路  3Comments

tamaghnadutta picture tamaghnadutta  路  3Comments