def perform_ssd_detection_by_id(task_id): start = TEvent.objects.get(pk=task_id) start.task_id = perform_ssd_detection_by_id.request.id start.started = True start.operation = perform_ssd_detection_by_id.name start.save() start_time = time.time() video_id = start.video_id detector = subprocess.Popen( ['fab', 'ssd_detect:{}'.format(video_id)], cwd=os.path.join( os.path.abspath(__file__).split('tasks.py')[0], '../')) detector.wait() if detector.returncode != 0: start.errored = True start.error_message = "fab ssd_detect failed with return code {}".format( detector.returncode) start.seconds = time.time() - start_time start.save() raise ValueError, start.error_message process_next(task_id) start.completed = True start.seconds = time.time() - start_time start.save() return 0
def perform_yolo_ssd_detection_by_id(video_id): start = TEvent() start.video_id = video_id start.started = True start.operation = perform_yolo_ssd_detection_by_id.name start.save() start_time = time.time() detector = subprocess.Popen(['fab','detect:{}'.format(video_id)],cwd=os.path.join(os.path.abspath(__file__).split('tasks.py')[0],'../')) detector.wait() if detector.returncode != 0: raise ValueError,"Task failed with returncode {}".format(detector.returncode) process_video_next(video_id,start.operation) start.completed = True start.seconds = time.time() - start_time start.save() return 0
def perform_detection(video_id): start = TEvent() start.video_id = video_id start.started = True start.operation = "detection" start.save() start_time = time.time() detector = subprocess.Popen( ['fab', 'detect:{}'.format(video_id)], cwd=os.path.join( os.path.abspath(__file__).split('tasks.py')[0], '../')) detector.wait() start.completed = True start.seconds = time.time() - start_time start.save() return 0