Reputation: 669
I'm trying to do image classification. I'm using Scala, the Akka actor system, and deeplearning4j. The thing is that I have to detect always on the same spots or crop on the image. I was thinking of creating a new actor for each crop of the image, on each frame. The thing is that, from what I understand, instantiating a new model for each actor creation is not viable, but having an instance of the model, and passing to each actor isn't either. Should I have a pool of instances? I'm a bit stuck with this problem, since it is the first time I'm trying deeplearning4j. Previously, I would use a python REST api, but I think that this solution should perform better.
Thank you in advance.
Upvotes: 1
Views: 228
Reputation: 3205
In the future, just of note: You can use parallelinference for multi threaded serving out of the box. https://github.com/deeplearning4j/dl4j-examples/blob/master/dl4j-examples/src/main/java/org/deeplearning4j/examples/inference/ParallelInferenceExample.java
One of the problems with the above answers, is it does not factor in that models have internal state when doing activations. ParallelInference also allows for both batched as well as sequential inference. This matters when you are using gpus for example. We allow multi threaded inference here as well.
Upvotes: 2
Reputation: 566
perhaps you could take a look at the monix library, it has async tasks, batching, fault-tolerance primitives, etc.
Upvotes: 0
Reputation: 44918
images.par.map(model.classify)
could already do the job; it would take care of a thread pool all by itself).Upvotes: 1