{"action":"created","issue":{"url":"https://api.github.com/repos/davidsandberg/facenet/issues/888","repository_url":"https://api.github.com/repos/davidsandberg/facenet","labels_url":"https://api.github.com/repos/davidsandberg/facenet/issues/888/labels{/name}","comments_url":"https://api.github.com/repos/davidsandberg/facenet/issues/888/comments","events_url":"https://api.github.com/repos/davidsandberg/facenet/issues/888/events","html_url":"https://github.com/davidsandberg/facenet/issues/888","id":366000930,"node_id":"MDU6SXNzdWUzNjYwMDA5MzA=","number":888,"title":"not abel to predict embedding. VAlue Error","user":{"login":"ayushsaklani","id":19391609,"node_id":"MDQ6VXNlcjE5MzkxNjA5","avatar_url":"https://avatars3.githubusercontent.com/u/19391609?v=4","gravatar_id":"","url":"https://api.github.com/users/ayushsaklani","html_url":"https://github.com/ayushsaklani","followers_url":"https://api.github.com/users/ayushsaklani/followers","following_url":"https://api.github.com/users/ayushsaklani/following{/other_user}","gists_url":"https://api.github.com/users/ayushsaklani/gists{/gist_id}","starred_url":"https://api.github.com/users/ayushsaklani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ayushsaklani/subscriptions","organizations_url":"https://api.github.com/users/ayushsaklani/orgs","repos_url":"https://api.github.com/users/ayushsaklani/repos","events_url":"https://api.github.com/users/ayushsaklani/events{/privacy}","received_events_url":"https://api.github.com/users/ayushsaklani/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-02T17:27:00Z","updated_at":"2018-11-05T06:29:47Z","closed_at":null,"author_association":"NONE","body":"I am using this code to load model an predict embeddings but getting value error.\r\n```\r\nwith tf.Session() as sess:\r\n  new_saver = tf.train.import_meta_graph('checkpoint/model-20180402-114759.meta')\r\n  new_saver.restore(sess, 'checkpoint/model-20180402-114759.ckpt-275')\r\n  graph = tf.get_default_graph()\r\n  print(graph.get_tensor_by_name(\"input:0\"))\r\n  print(graph.get_tensor_by_name(\"phase_train:0\"))\r\n  print(graph.get_tensor_by_name(\"embeddings:0\"))\r\n  input_x = graph.get_tensor_by_name(\"input:0\")\r\n  \r\n  embeddings = graph.get_tensor_by_name(\"embeddings:0\")\r\n  phase_train_placeholder = tf.get_default_graph().get_tensor_by_name(\"phase_train:0\")\r\n\r\n  \r\n  feed_dict = { input_x:input_img, phase_train_placeholder:False }\r\n  emb_array= sess.run(embeddings, feed_dict=feed_dict)\r\n\r\n```\r\nError is : \r\n```\r\nValueError                                Traceback (most recent call last)\r\n<ipython-input-6-c2dfb37bf963> in <module>()\r\n     13 \r\n     14   feed_dict = { input_x:input_img, phase_train_placeholder:False }\r\n---> 15   emb_array= sess.run(embeddings, feed_dict=feed_dict)\r\n     16 \r\n     17 \r\n\r\n/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata)\r\n    885     try:\r\n    886       result = self._run(None, fetches, feed_dict, options_ptr,\r\n--> 887                          run_metadata_ptr)\r\n    888       if run_metadata:\r\n    889         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)\r\n\r\n/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)\r\n   1077             feed_handles[subfeed_t] = subfeed_val\r\n   1078           else:\r\n-> 1079             np_val = np.asarray(subfeed_val, dtype=subfeed_dtype)\r\n   1080 \r\n   1081           if (not is_tensor_handle_feed and\r\n\r\n/usr/local/lib/python3.6/dist-packages/numpy/core/numeric.py in asarray(a, dtype, order)\r\n    490 \r\n    491     \"\"\"\r\n--> 492     return array(a, dtype, copy=False, order=order)\r\n    493 \r\n    494 \r\n\r\nValueError: setting an array element with a sequence.\r\n```  \r\nI am not getting how to input image and predict embeddings."},"comment":{"url":"https://api.github.com/repos/davidsandberg/facenet/issues/comments/435768101","html_url":"https://github.com/davidsandberg/facenet/issues/888#issuecomment-435768101","issue_url":"https://api.github.com/repos/davidsandberg/facenet/issues/888","id":435768101,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNTc2ODEwMQ==","user":{"login":"VictorZhang2014","id":6853884,"node_id":"MDQ6VXNlcjY4NTM4ODQ=","avatar_url":"https://avatars2.githubusercontent.com/u/6853884?v=4","gravatar_id":"","url":"https://api.github.com/users/VictorZhang2014","html_url":"https://github.com/VictorZhang2014","followers_url":"https://api.github.com/users/VictorZhang2014/followers","following_url":"https://api.github.com/users/VictorZhang2014/following{/other_user}","gists_url":"https://api.github.com/users/VictorZhang2014/gists{/gist_id}","starred_url":"https://api.github.com/users/VictorZhang2014/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VictorZhang2014/subscriptions","organizations_url":"https://api.github.com/users/VictorZhang2014/orgs","repos_url":"https://api.github.com/users/VictorZhang2014/repos","events_url":"https://api.github.com/users/VictorZhang2014/events{/privacy}","received_events_url":"https://api.github.com/users/VictorZhang2014/received_events","type":"User","site_admin":false},"created_at":"2018-11-05T06:29:47Z","updated_at":"2018-11-05T06:29:47Z","author_association":"NONE","body":"Thank you @ayushsaklani for telling how to restore from this kind of ckpt file into TensorFlow session.\r\n\r\nHere I share you with my code on reading image from local, and send the numpy array to TensorFlow session . The code as shown below:\r\n```\r\nimport numpy as np\r\nimport cv2\r\n\r\n# read an image from local\r\nimg = cv2.imread('victor_test.jpeg')\r\n# resize the image to your desired shape\r\ninput_img = cv2.resize(img, (250, 250), 3)\r\n# change its shape to tensorflow mode needs shape\r\ninput_img = np.array(input_img).reshape((1, 250, 250, 3))\r\n\r\nprint(type(input_img), input_img.shape)\r\n```\r\nOutput is :\r\n```\r\n<class 'numpy.ndarray'> (1, 250, 250, 3)\r\n```\r\n\r\nFor you case ,the error message `ValueError: setting an array element with a sequence.` means that the variable `input_img` has to be numpy array."}}
{"actor":{"display_login":"VictorZhang2014"}}