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

BaseServer breaking because data is persisted in self.input_ops #26

Open
andrazvonar opened this issue May 18, 2020 · 0 comments
Open

Comments

@andrazvonar
Copy link

I've copied example code into the function below in order to embed faces. I'm calling it from a for loop.

It works fine in the first iteration, but breaks in the second.

def embed_face(face):    
    # Read example image
    test_img = face
    test_img = cv2.resize(test_img, configs.face_describer_tensor_shape)

# Define input tensors feed to session graph
dropout_rate = 1.0
input_data = [np.expand_dims(test_img, axis=0), dropout_rate]

# Define a Base Server
srv = base_server.BaseServer(model_fp='/Users/andraz/Documents/šola/diploma/tf-insightface/pretrained/insightface.pb',
                             input_tensor_names=configs.face_describer_input_tensor_names,
                             output_tensor_names=configs.face_describer_output_tensor_names,
                             device=configs.face_describer_device)
# Run prediction
prediction = srv.inference(data=input_data)


# Print results
return prediction

The error I am getting

    ---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-14-61ed406b99dc> in <module>
     21 
     22             # Embed faceial features
---> 23             embedded_face = embed_face(cropped_face)
     24             print("Embedded face")

<ipython-input-12-9bc850f211fc> in embed_face(face)
     25                                  device=configs.face_describer_device)
     26     # Run prediction
---> 27     prediction = srv.inference(data=input_data)
     28 
     29     del srv

~/Documents/šola/diploma/tf-insightface/models/base_server.py in inference(self, data)
     73 
     74         with self.graph.as_default():
---> 75             self._set_feed_dict(data=data)
     76             print('[Base Server] Running inference...')
     77             self.prediction = self.session.run(self.output_ops, feed_dict=self.feed_dict)

~/Documents/šola/diploma/tf-insightface/models/base_server.py in _set_feed_dict(self, data)
     62 
     63     def _set_feed_dict(self, data):
---> 64         assert len(data) == len(self.input_ops)
     65         with self.graph.as_default():
     66             print(self.input_ops)

AssertionError: 
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

1 participant