1
$\begingroup$

Let's say i have three model: Facial recognition, Face landmark detection, Emotion recognition.
Now if i want to predict those three feature from a single image. What should be my approach?

  1. Should i combined those three model? or
  2. Run three model in three different thread?
$\endgroup$
4
  • 1
    $\begingroup$ By combining those three models, you mean feature sharing or just running them in the one same thread? $\endgroup$ Jan 30 '19 at 9:40
  • $\begingroup$ Actually i don't know exact way, how to combine three model. I ask question here to know in which way i will go. or any other best practice. $\endgroup$
    – Masum
    Jan 30 '19 at 10:08
  • $\begingroup$ Have you already trained those three models ( Facial recognition, Face landmark detection, Emotion recognition)? $\endgroup$ Jan 30 '19 at 10:15
  • $\begingroup$ Yes, I have developed Facial recognition model and facial expression recognition model separately. Now when i give a image, how could i get combined prediction? (Though i can already run the models one after another against the image) $\endgroup$
    – Masum
    Jan 30 '19 at 10:19
0
$\begingroup$

All three models fit to single GPU

Since you have already trained the models and models are separate (do not share the features), you could construct the computational graph in a way that you have only one input (your image), but that input is pushed to three different branches of the computational graph (each branch is one of your three models). At the output of such constructed graph, you will get three outputs (one from each of three branches).

This way you will run all three models at once.

If you are using TF, it will look like this:

output_1, output_2, output_3 = sess.run(output_op, feed_dict:{input_layer: input_image})

where the output_op holds a list of outputs from three models (hence, we unpack them to three variables output_1, output_2 and output_3); input_layer is the tensor operation which takes the image and pushes it to three branches as already described.

This is only possible if your GPU memory is large enough to fit all three models into the memory.

All three models do not fit to single GPU

In this case, assuming you have access to multiple GPUs, you could modify the computational graph which combines three models to use different GPUs for each branch.

Run one after another

Also, this can be always done.


If you are using TF, this link could be useful.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.