How to implement multi-processing ?

asked Oct 16 '18

updated Oct 17 '18

berak gravatar image

Hi, I tried to run face detection using multi processing I am getting below error

E:\git\opencv-dnn-demo\face_detectors>python sample.py

i am detect
i am detect
i am detect
i am detect
i am detect
i am detect
Traceback (most recent call last):
  File "sample.py", line 17, in <module>
    pool.map(fd.detect, imgs)
  File "C:\Anaconda3\lib\multiprocessing\pool.py", line 260, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "C:\Anaconda3\lib\multiprocessing\pool.py", line 608, in get
    raise self._value
  File "C:\Anaconda3\lib\multiprocessing\pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "C:\Anaconda3\lib\multiprocessing\pool.py", line 44, in mapstar
    return list(map(*args))
  File "E:\git\opencv-dnn-demo\face_detectors\yolov2.py", line 34, in detect
    detections = self.net.forward()
cv2.error: OpenCV(3.4.3) C:\projects\opencv-python\opencv\modules\dnn\src\dnn.cpp:841: error: (-215:Assertion failed) memHosts.find(lp) == memHosts.end() in function 'cv::dnn::experimental_dnn_34_v7::BlobManager::addHost'

What was the issue sorry I new to CV and Yolo

Preview: (hide)

Comments

you maybe want to use the python bindings for yolo directly - https://github.com/AlexeyAB/darknet -> How to use Yolo as DLL

It also works on linux(.so).

holger gravatar imageholger (Oct 17 '18)edit

please DO NOT TRY to use multiprocessing with this.

(neural networks are "stateful", and can't be shared between processes / threads)

if you have several images to process, feed those into the nn as a batch for speedup.

berak gravatar imageberak (Oct 17 '18)edit

Thanks, how to feed as batch can you please explain

itsthanga gravatar imageitsthanga (Oct 17 '18)edit

there is a (c++) answer here

berak gravatar imageberak (Oct 17 '18)edit