AISangam / Facenet-Real-time-face-recognition-using-deep-learning-Tensorflow

Facenet-Real-time-face-recognition-using-deep-learning-Tensorflow
159 stars 104 forks source link

Change for number of iteration #3

Open brijeshg opened 6 years ago

brijeshg commented 6 years ago

Hi,

I made change for 5000 number of iteration to train my images in file /packages/classifier.py. Following are the changes I made. Here is code snippet. batch_size = 200 image_size = 300 nrof_images = len(path) print(nrof_images)

nrof_batches_per_epoch = int(math.ceil(1.0 * nrof_images / batch_size))

            nrof_batches_per_epoch=5000
            emb_array = np.zeros((nrof_images, embedding_size))
            for i in range(nrof_batches_per_epoch):

After running classifier_train.py , I got following error:

Traceback (most recent call last): File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1322, in _do_call return fn(*args) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1307, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1409, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.InvalidArgumentError: Reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero [[Node: InceptionResnetV1/Logits/Flatten/flatten/Reshape = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/device:CPU:0"](InceptionResnetV1/Logits/AvgPool_1a_8x8/AvgPool, InceptionResnetV1/Logits/Flatten/flatten/Reshape/shape)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "classifier_train.py", line 14, in get_file=obj.main_train() File "/home/ubuntu/brgupta_workspace/face_recognition/facenet/packages/classifier.py", line 51, in main_train emb_array[start_index:end_index, :] = sess.run(embeddings, feed_dict=feed_dict) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 900, in run run_metadata_ptr) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1135, in _run feed_dict_tensor, options, run_metadata) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1316, in _do_run run_metadata) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1335, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: Reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero [[Node: InceptionResnetV1/Logits/Flatten/flatten/Reshape = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/device:CPU:0"](InceptionResnetV1/Logits/AvgPool_1a_8x8/AvgPool, InceptionResnetV1/Logits/Flatten/flatten/Reshape/shape)]]

Caused by op 'InceptionResnetV1/Logits/Flatten/flatten/Reshape', defined at: File "classifier_train.py", line 14, in get_file=obj.main_train() File "/home/ubuntu/brgupta_workspace/face_recognition/facenet/packages/classifier.py", line 30, in main_train facenet.load_model(self.modeldir) File "/home/ubuntu/brgupta_workspace/face_recognition/facenet/packages/facenet.py", line 388, in load_model saver = tf.train.import_meta_graph(os.path.join(model_exp, meta_file)) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/training/saver.py", line 1955, in import_meta_graph *kwargs) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/framework/meta_graph.py", line 743, in import_scoped_meta_graph producer_op_list=producer_op_list) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/util/deprecation.py", line 432, in new_func return func(args, **kwargs) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/framework/importer.py", line 513, in import_graph_def _ProcessNewOps(graph) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/framework/importer.py", line 303, in _ProcessNewOps for new_op in graph._add_new_tf_operations(compute_devices=False): # pylint: disable=protected-access File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3540, in _add_new_tf_operations for c_op in c_api_util.new_tf_operations(self) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3540, in for c_op in c_api_util.new_tf_operations(self) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3428, in _create_op_from_tf_operation ret = Operation(c_op, self) File "/home/ubuntu/.local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1718, in init self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero [[Node: InceptionResnetV1/Logits/Flatten/flatten/Reshape = Reshape[T=DT_FLOAT, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/device:CPU:0"](InceptionResnetV1/Logits/AvgPool_1a_8x8/AvgPool, InceptionResnetV1/Logits/Flatten/flatten/Reshape/shape)]]


Please help me to train my images for 10000 number of iterations. Thanks in advance.