def main(opt): if opt["module"] == "TEM": if opt["mode"] == "train": print "TEM training start" BSN_Train_TEM(opt) print "TEM training finished" elif opt["mode"] == "inference": print "TEM inference start" if not os.path.exists("output/" + opt["arch"] + opt["fix_scale"] + "_TEM_results"): os.makedirs("output/" + opt["arch"] + opt["fix_scale"] + "_TEM_results") BSN_inference_TEM(opt) print "TEM inference finished" else: print "Wrong mode. TEM has two modes: train and inference" elif opt["module"] == "PGM": if not os.path.exists("output/" + opt["arch"] + opt["fix_scale"] + "_PGM_proposals"): os.makedirs("output/" + opt["arch"] + opt["fix_scale"] + "_PGM_proposals") print "PGM: start generate proposals" PGM_proposal_generation(opt) print "PGM: finish generate proposals" if not os.path.exists("output/" + opt["arch"] + opt["fix_scale"] + "_PGM_feature"): os.makedirs("output/" + opt["arch"] + opt["fix_scale"] + "_PGM_feature") print "PGM: start generate BSP feature" PGM_feature_generation(opt) print "PGM: finish generate BSP feature" elif opt["module"] == "PEM": if opt["mode"] == "train": print "PEM training start" BSN_Train_PEM(opt) print "PEM training finished" elif opt["mode"] == "inference": if not os.path.exists("output/" + opt["arch"] + opt["fix_scale"] + "_PEM_results"): os.makedirs("output/" + opt["arch"] + opt["fix_scale"] + "_PEM_results") print "PEM inference start" BSN_inference_PEM(opt) print "PEM inference finished" else: print "Wrong mode. PEM has two modes: train and inference" elif opt["module"] == "Post_processing": print "Post processing start" BSN_post_processing(opt) print "Post processing finished" elif opt["module"] == "Evaluation": evaluation_proposal(opt) print ""
def engine_runner(opt): if opt["module"] == "TEM": if opt["mode"] == "train": print ("TEM training start") BSN_Train_TEM(opt) print ("TEM training finished") elif opt["mode"] == "inference": print ("TEM inference start") if not os.path.exists("output/TEM_results"): os.makedirs("output/TEM_results") BSN_inference_TEM(opt) print ("TEM inference finished") else: print ("Wrong mode. TEM has two modes: train and inference") elif opt["module"] == "PGM": if not os.path.exists("output/PGM_proposals"): os.makedirs("output/PGM_proposals") print ("PGM: start generate proposals") PGM_proposal_generation(opt) print ("PGM: finish generate proposals") ''' if not os.path.exists("output/PGM_feature"): os.makedirs("output/PGM_feature") print ("PGM: start generate BSP feature") PGM_feature_generation(opt) print ("PGM: finish generate BSP feature") ''' elif opt["module"] == "PEM": if opt["mode"] == "train": print ("PEM training start") BSN_Train_PEM(opt) print ("PEM training finished") elif opt["mode"] == "inference": if not os.path.exists("output/PEM_results"): os.makedirs("output/PEM_results") print ("PEM inference start") BSN_inference_PEM(opt) print ("PEM inference finished") else: print ("Wrong mode. PEM has two modes: train and inference") elif opt["module"] == "Post_processing": print ("Post processing start") BSN_post_processing(opt) print ("Post processing finished") elif opt["module"] == "Evaluation": evaluation_proposal(opt) else: print ('unknow module, please check ...')
def main(opt): if opt["mode"] == "train": BMN_Train(opt) elif opt["mode"] == "inference": if not os.path.exists("output/BMN_results"): os.makedirs("output/BMN_results") BMN_inference(opt) print("Post processing start") BMN_post_processing(opt) print("Post processing finished") evaluation_proposal(opt)
def main(opt): if opt["mode"] == "train": with open(opt["checkpoint_path"] + "/opts.json", "w") as opt_file: json.dump(opt, opt_file) BMN_Train(opt) elif opt["mode"] == "inference": if not os.path.exists(opt["output"] + "/BMN_results"): os.makedirs(opt["output"] + "/BMN_results") BMN_inference(opt) print("Post processing start") BMN_post_processing(opt) print("Post processing finished") evaluation_proposal(opt)
def main(opt): if opt["module"] == "BMN": mask = np.load(opt["bm_mask_path"]) opt["bm_mask"] = mask if opt["mode"] == "train": BMN_Train(opt) elif opt["mode"] == "inference": if not os.path.exists("output/BMN_results"): os.makedirs("output/BMN_results") BMN_inference(opt) else: print("Wrong mode. BMN has two modes: train and inference") elif opt["module"] == "Post_processing": print("Post processing start") BMN_post_processing(opt) print("Post processing finished") elif opt["module"] == "Evaluation": evaluation_proposal(opt) print("")
# step1 train models run_training(args) # step2 generate final proposal for i in range(1, args.epochs + 1): generate_proposals_with_pem(args, i, 'test') # step3 evaluation AR_AN = {} aran = [] for epoch in range(1, args.epochs + 1): eval_file = os.path.join( args.save_path, 'proposals', 'results_softnms_n5_score_se_pem_epoch{}.json'.format(epoch)) results = evaluation_proposal(args, eval_file) AR_AN[epoch] = results aran.append(results[1]) aran = np.array(aran) mean_10 = np.mean(aran[10:, :], 0) with open( os.path.join(args.save_path, 'result_softnms_n5_score_se_pem.txt'), 'w') as f: for key, item in AR_AN.items(): s = '{}\t{}\t{}\t{}\t{}\t{}\n'.format(key, item[1][0], item[1][1], item[1][2], item[1][3], item[1][4]) f.write(s) s = '{}\t{}\t{}\t{}\t{}\t{}\n'.format('averaged_last10', mean_10[0], mean_10[1], mean_10[2], mean_10[3], mean_10[4])
def main(opt): if opt["module"] == "TEM": if opt["mode"] == "train": print("TEM training start") BSN_Train_TEM(opt) print("TEM training finished") elif opt["mode"] == "inference": print("TEM inference start") if not os.path.exists("output/TEM_results"): os.makedirs("output/TEM_results") BSN_inference_TEM(opt) # 前推产生每一个video的三个概率序列 并存储到TEM-results print("TEM inference finished") else: print("Wrong mode. TEM has two modes: train and inference") elif opt["module"] == "PGM": if not os.path.exists("output/PGM_proposals"): os.makedirs("output/PGM_proposals") print("PGM: start generate proposals") PGM_proposal_generation(opt) # using staring and ending possibility produced by TEM to generate proposal print("PGM: finish generate proposals") if not os.path.exists("output/PGM_feature"): os.makedirs("output/PGM_feature") # print("PGM: start generate BSP feature") PGM_feature_generation(opt) # generate BSP features for all candidate proposals and store them print("PGM: finish generate BSP feature") elif opt["module"] == "PEM": if opt["mode"] == "train": print("PEM training start") BSN_Train_PEM(opt) # train PEM module print("PEM training finished") elif opt["mode"] == "inference": if not os.path.exists("output/PEM_results"): os.makedirs("output/PEM_results") print("PEM inference start") BSN_inference_PEM(opt) # evaluate the proposal from one subset and store them print("PEM inference finished") else: print("Wrong mode. PEM has two modes: train and inference") elif opt["module"] == "BMN": if opt["mode"] == "train": print("BMN training start") BMN_Train(opt) print("BMN training start") elif opt["mode"] == "inference": if not os.path.exists("output/BMN_results"): os.makedirs("output/BMN_results") print("BMN inference start") BMN_inference(opt) print("BMN inference start") else: print("Wrong mode. PEM has two modes: train and inference") print("Post processing start") elif opt["module"] == "BMN_Post_processing": print("BMN Post processing start") BMN_post_processing(opt) print("BMN Post processing finished") elif opt["module"] == "BSN_Post_processing": print("BSN Post processing start") BSN_post_processing(opt) print("BSN Post processing finished") elif opt["module"] == "BMN_Evaluation": evaluation_proposal(opt, result_file=opt["bmn_result_file"], save_fig_path=opt["bmn_save_fig_path"]) elif opt["module"] == "BSN_Evaluation": evaluation_proposal(opt, result_file=opt["result_file"], save_fig_path=opt["save_fig_path"]) print("")