How to implement multi-processing ?

asked 2018-10-16 14:19:43 -0600

updated 2018-10-16 18:05:34 -0600

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

edit retag flag offensive close merge delete

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 ( 2018-10-17 00:04:37 -0600 )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 ( 2018-10-17 00:23:44 -0600 )edit

Thanks, how to feed as batch can you please explain

itsthanga gravatar imageitsthanga ( 2018-10-17 02:27:14 -0600 )edit

there is a (c++) answer here

berak gravatar imageberak ( 2018-10-17 02:34:58 -0600 )edit