davidsandberg / facenet

Face recognition using Tensorflow
MIT License
13.85k stars 4.81k forks source link

have a problem when using classifier.py with pretrained_model #890

Open DeveloperZWK opened 6 years ago

DeveloperZWK commented 6 years ago

Hi all, When I want to train a classifier on own images with classifier.py with the following parameters: python ~/facenet/src/classifier.py \ TRAIN \ ~/datasets/my_dataset/test_mtcnnpy_100 \ ~/models/20180402-114759.pb \ ~/models/my_classifier.pkl \ --image_size 100

And then, I get the following error when attempting to train with a batch size of 64. Any help is much appreciated. Number of classes: 15 Number of images: 57 Loading feature extraction model Model filename: .../models/20180402-114759.pb Calculating features for images 2018-10-04 15:05:23.306062: W tensorflow/core/framework/op_kernel.cc:1273] OP_REQUIRES failed at pooling_ops_common.cc:69 : Invalid argument: Computed output size would be negative: -1 [input_size: 1, effective_filter_size: 3, stride: 1] Traceback (most recent call last): File ".../lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1327, in _do_call return fn(*args) File "..../lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1312, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File ".../lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1420, in _call_tf_sessionrun status, run_metadata) File ".../lib/python3.5/site-packages/tensorflow/python/framework/errors_impl.py", line 516, in exit c_api.TF_GetCode(self.status.status)) tensorflow.python.framework.errors_impl.InvalidArgumentError: Computed output size would be negative: -1 [input_size: 1, effective_filter_size: 3, stride: 1] [[Node: InceptionResnetV1/Logits/AvgPool_1a_8x8/AvgPool = AvgPoolT=DT_FLOAT, data_format="NHWC", ksize=[1, 3, 3, 1], padding="VALID", strides=[1, 1, 1, 1], _device="/job:localhost/replica:0/task:0/device:CPU:0"]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File ".../facenet/src/classifier.py", line 170, in main(parse_arguments(sys.argv[1:])) File .../facenet/src/classifier.py", line 88, in main emb_array[start_index:end_index,:] = sess.run(embeddings, feed_dict=feed_dict) File ".../lib/python3.5/site-packages/tensorflow/python/client/session.py", line 905, in run run_metadata_ptr) File ".../lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1140, in _run feed_dict_tensor, options, run_metadata) File ".../lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1321, in _do_run run_metadata) File ".../lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1340, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: Computed output size would be negative: -1 [input_size: 1, effective_filter_size: 3, stride: 1] [[Node: InceptionResnetV1/Logits/AvgPool_1a_8x8/AvgPool = AvgPoolT=DT_FLOAT, data_format="NHWC", ksize=[1, 3, 3, 1], padding="VALID", strides=[1, 1, 1, 1], _device="/job:localhost/replica:0/task:0/device:CPU:0"]]

Caused by op 'InceptionResnetV1/Logits/AvgPool_1a_8x8/AvgPool', defined at: File ".../facenet/src/classifier.py", line 170, in main(parse_arguments(sys.argv[1:])) File ".../facenet/src/classifier.py", line 69, in main facenet.load_model(args.model) File ".../facenet/src/facenet.py", line 373, in load_model tf.import_graph_def(graph_def, input_map=input_map, name='') File ".../lib/python3.5/site-packages/tensorflow/python/util/deprecation.py", line 432, in new_func return func(*args, **kwargs) File ".../lib/python3.5/site-packages/tensorflow/python/framework/importer.py", line 577, in import_graph_def op_def=op_def) File "..../lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3290, in create_op op_def=op_def) File ".../lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1654, in init self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Computed output size would be negative: -1 [input_size: 1, effective_filter_size: 3, stride: 1] [[Node: InceptionResnetV1/Logits/AvgPool_1a_8x8/AvgPool = AvgPoolT=DT_FLOAT, data_format="NHWC", ksize=[1, 3, 3, 1], padding="VALID", strides=[1, 1, 1, 1], _device="/job:localhost/replica:0/task:0/device:CPU:0"]]

anhanhtdh01 commented 3 years ago

me too