Ask Your Question
1

Is DNN supports threading

asked 2018-12-12 06:34:37 -0500

vineetjai gravatar image

updated 2018-12-13 23:45:27 -0500

Hi, I am trying to use DNN with threading for executing operation on video frame-wise. What I had done so far is:

I had read net from disk using net = cv2.dnn.readNetFromTensorflow(weightsPath, configPath) . I am doing threading with 3 threads. First thread is running correctly but for 2nd and 3rd thread it is throwing error:- cv2.error: OpenCV(3.4.4) /io/opencv/modules/dnn/src/dnn.cpp:834: error: (-215:Assertion failed) ld.inputBlobs[0]->total() == total(shapes[index]) in function 'allocateBlobsForLayer'. Is it because only one thread can access net at particular time or Is DNN not supports threading or some other reasons?

I can share my code if needed.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
4

answered 2018-12-12 06:42:56 -0500

berak gravatar image

updated 2018-12-12 06:46:08 -0500

NO, this is not possible.

only one single thread can be used for a single network, you can't "share" the net instance between multiple threads.

what you can do is:

  • don't send a single image through it, but a whole batch
  • try to enable a faster backend / target
  • maybe you don't need to run the inference for every frame, but only now & then, and use tracking to follow your objects in the meantime
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-12-12 06:33:16 -0500

Seen: 68 times

Last updated: Dec 12 '18