For a single image at a time, the detection algorithm works like a charm. But, when I pass multiple images at once, it just crashes.
I had it working on a CPU server earlier by wrapping it around multiprocessing and closing it every time a detection completed.
Here is the code for that:
def process_detection_pipeline(self, front, inputdata):
try:
manager = multiprocessing.Manager()
return_dict = manager.dict()
def worker_process(return_dic, front, inputdata):
userid = inputdata['userid']
if front is not None:
frontcrpimg, statusmin, statusmax = self.obj_detectperson.getUserCropImg(front)
cv2.imwrite('output/' + str(userid) + '/cropimgs/front.jpg', frontcrpimg)
return_dic['1'] = statusmin
return_dic['2'] = statusmax
return_dic['3'] = frontcrpimg
p = Process(target=worker_process, args=(return_dict, front, inputdata))
p.start()
p.join()
return return_dict.values()
except:
return False, False, None
The same code block is not working in the case of a GPU-based server.
I would like to know if there is a better solution to solve this problem?