def main(coef, n_classes, frames, fps, width, height, channels): seg1_target = target_generator(lambda x: segmentation1(x, 0.03 * coef)) seg2_target = target_generator(lambda x: segmentation2(x, 0.04 * coef)) @target_generator def class_target(x): return classification(x, 0.05 * coef, n_classes) target_list = [seg1_target, seg2_target, class_target] queue_list = [(queue.Queue(), queue.Queue()) for target in target_list] thread_list = [ Thread(target=target, args=qio) for target, qio in zip(target_list, queue_list) ] for thread in thread_list: thread.start() time_recorder = TimeRecord() size = (height, width, channels) for frame in fake_video(frames=frames, fps=fps, size=size): with time_recorder: for qi, _ in queue_list: qi.put(frame) for _, qo in queue_list: qo.get() time_recorder.report()
def do_segmentation2(sleep_time): output = segmentation2(G["frame"], sleep_time) np.copyto(G["output_segmentation2"], output)
def process(frame, base_sleep_time, n_classes): rs1 = segmentation1(frame, base_sleep_time * 0.03) rs2 = segmentation2(frame, base_sleep_time * 0.04) rs3 = classification(frame, base_sleep_time * 0.05, n_classes) return rs1, rs2, rs3
def seg2_target(x): return segmentation2(x, 0.04 * g_dict["coef"])
def process(self, x): return segmentation2(x, self.sleep_time)