How to implement multi-processing ?

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

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

berak gravatar image

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


i am detect
i am detect
i am detect
i am detect
i am detect
i am detect
Traceback (most recent call last):
  File "", line 17, in <module>, imgs)
  File "C:\Anaconda3\lib\multiprocessing\", line 260, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "C:\Anaconda3\lib\multiprocessing\", line 608, in get
    raise self._value
  File "C:\Anaconda3\lib\multiprocessing\", line 119, in worker
    result = (True, func(*args, **kwds))
  File "C:\Anaconda3\lib\multiprocessing\", line 44, in mapstar
    return list(map(*args))
  File "E:\git\opencv-dnn-demo\face_detectors\", line 34, in detect
    detections =
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


you maybe want to use the python bindings for yolo directly - -> How to use Yolo as DLL

It also works on linux(.so).

holger gravatar imageholger ( 2018-10-17 00:04:37 -0500 )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 -0500 )edit

Thanks, how to feed as batch can you please explain

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

there is a (c++) answer here

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