def main(): args = args_parser() update_config(args.cfg) if cfg.BASIC.SHOW_CFG: pprint.pprint(cfg) # prepare running environment for the whole project # prepare_env(cfg) # dataloader val_dset = WtalDataset(cfg, cfg.DATASET.VAL_SPLIT) val_loader = DataLoader(val_dset, batch_size=cfg.TEST.BATCH_SIZE, shuffle=False, num_workers=cfg.BASIC.WORKERS, pin_memory=cfg.BASIC.PIN_MEMORY) # network model = LocNet(cfg) # model.apply(weight_init) model.cuda() # weight_file = "" # weight_file = "/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/0_NeurIPS2020_code_ok/results_and_model/thumos14_checkpoint_best_cas_epoch125_iou0.5__0.2928.pth" # weight_file = "/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/0_NeurIPS2020_code_ok/results_and_model/anet12_checkpoint_best_cas_epoch30_map_0.2394.pth" # weight_file = "/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/0_NeurIPS2020_code_ok/results_and_model/anet13_checkpoint_best_cas_epoch35_map_0.2348.pth" weight_file = "/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/thumos14/000_thumos_29.13_save_model_Frame_wise_accuracy/checkpoint_best_cas.pth" epoch = 801 from utils.utils import load_weights model = load_weights(model, weight_file) evaluate_save_for_post_process(cfg, val_loader, model, epoch)
def main(): args = args_parser() update_config(args.cfg) if cfg.BASIC.SHOW_CFG: pprint.pprint(cfg) cfg.BASIC.ROOT_DIR = os.path.join(os.path.dirname(__file__), '..') # dataloader val_dset = WtalDataset(cfg, cfg.DATASET.VAL_SPLIT) val_loader = DataLoader(val_dset, batch_size=cfg.TEST.BATCH_SIZE, shuffle=False, num_workers=cfg.BASIC.WORKERS, pin_memory=cfg.BASIC.PIN_MEMORY) # network model = LocNet(cfg) model.cuda() if not os.path.exists(args.res_dir): os.makedirs(args.res_dir) model = load_weights(model, args.weight_file) evaluate_vis_cas(cfg, val_loader, model, args.res_dir, args.is_minmax_norm)
def main(): args = args_parser() update_config(args.cfg) if cfg.BASIC.SHOW_CFG: pprint.pprint(cfg) # prepare running environment for the whole project prepare_env(cfg) # dataloader val_dset = WtalDataset(cfg, cfg.DATASET.VAL_SPLIT) val_loader = DataLoader(val_dset, batch_size=cfg.TEST.BATCH_SIZE, shuffle=False, num_workers=cfg.BASIC.WORKERS, pin_memory=cfg.BASIC.PIN_MEMORY) # network model = LocNet(cfg) # model.apply(weight_init) model.cuda() # weight_file = '/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/0_NeurIPS2020_code_ok/results_and_model/thumos14_checkpoint_best_cas_epoch125_iou0.5__0.2928.pth' # weight_file = '/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/0_NeurIPS2020_code_ok/results_and_model/anet12_checkpoint_best_cas_epoch30_map_0.2545.pth' # weight_file = '/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/0_NeurIPS2020_code_ok/results_and_model/anet13_checkpoint_best_cas_epoch35_map_0.2348.pth' # weight_file = '' weight_file = '/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/thumos14/thumos_ablation_inv_0_save_model/checkpoint_best_cas_inv0_epoch69_0.2636.pth' # weight_file = '/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/thumos14/thumos_ablation_only_cas_save_model/checkpoint_best_cas_only_cas_epoch134_0.1957.pth' # weight_file = '/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/thumos14/thumos_ablation_individual_attention_2048k1_2048k1_2048k1_only_cam_svae_model/checkpoint_best_cas_only_cam_epoch96_0.1714.pth' res_dir = os.path.join(cfg.BASIC.CKPT_DIR, cfg.TEST.RESULT_DIR, 'vis/cas_gt_idx_minmax_norm_std') if not os.path.exists(res_dir): os.makedirs(res_dir) from utils.utils import load_weights model = load_weights(model, weight_file) epoch = 600 output_json_file_cas, output_json_file_cam, test_acc_cas, test_acc_cam = evaluate( cfg, val_loader, model, epoch) evaluate_mAP(cfg, output_json_file_cas, os.path.join(cfg.BASIC.CKPT_DIR, cfg.DATASET.GT_FILE), cfg.BASIC.VERBOSE) evaluate_mAP(cfg, output_json_file_cam, os.path.join(cfg.BASIC.CKPT_DIR, cfg.DATASET.GT_FILE), cfg.BASIC.VERBOSE) is_minmax_norm = True evaluate_vis_cas_minmax_norm_std(cfg, val_loader, model, res_dir, is_minmax_norm)
def main(): args = args_parser() update_config(args.cfg) if cfg.BASIC.SHOW_CFG: pprint.pprint(cfg) # prepare running environment for the whole project # prepare_env(cfg) # dataloader val_dset = WtalDataset(cfg, cfg.DATASET.VAL_SPLIT) val_loader = DataLoader(val_dset, batch_size=cfg.TEST.BATCH_SIZE, shuffle=False, num_workers=cfg.BASIC.WORKERS, pin_memory=cfg.BASIC.PIN_MEMORY) # network model_cas = LocNet(cfg) # model.apply(weight_init) model_cam = LocNet(cfg) model_cas.cuda() model_cam.cuda() # weight_file = "" # weight_file = "/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/0_NeurIPS2020_code_ok/results_and_model/thumos14_checkpoint_best_cas_epoch125_iou0.5__0.2928.pth" # weight_file = "/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/0_NeurIPS2020_code_ok/results_and_model/anet12_checkpoint_best_cas_epoch30_map_0.2394.pth" # weight_file = "/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/anet13/anet13_same_as_anet12_seed1_epoch45_TOPK_K_R_0.6_LR_DECAY26_save_every_model/checkpoint_best_cas_epoch35.pth" weight_file_cas = "/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/thumos14/thumos_ablation_only_cas_only_cam_separate_weight_save_model/checkpoint_best_cas_epoch75_0.2055.pth" weight_file_cam = "/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/thumos14/thumos_ablation_only_cas_only_cam_separate_weight_save_model/checkpoint_best_cam_epoch89_0.176.pth" from utils.utils import load_weights model_cas = load_weights(model_cas, weight_file_cas) model_cam = load_weights(model_cam, weight_file_cam) epoch = 911 output_json_file_cas, test_acc_cas = evaluate_fuse_sequence( cfg, val_loader, model_cas, model_cam, epoch) # output_json_file_cas, test_acc_cas = evaluate(cfg, val_loader, model, epoch) if cfg.BASIC.VERBOSE: print('test_acc, cas %f' % (test_acc_cas)) mAP, average_mAP = evaluate_mAP( cfg, output_json_file_cas, os.path.join(cfg.BASIC.CKPT_DIR, cfg.DATASET.GT_FILE), cfg.BASIC.VERBOSE)
def main(): args = args_parser() update_config(args.cfg) if cfg.BASIC.SHOW_CFG: pprint.pprint(cfg) # prepare running environment for the whole project prepare_env(cfg) # dataloader val_dset = WtalDataset(cfg, cfg.DATASET.VAL_SPLIT) val_loader = DataLoader(val_dset, batch_size=cfg.TEST.BATCH_SIZE, shuffle=False, num_workers=cfg.BASIC.WORKERS, pin_memory=cfg.BASIC.PIN_MEMORY) # network model = LocNet(cfg) # model.apply(weight_init) model.cuda() # weight_file = "" weight_file = "/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/0_NeurIPS2020_code_ok/results_and_model/thumos14_checkpoint_best_cas_epoch125_iou0.5__0.2928.pth" # weight_file = "/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/0_NeurIPS2020_code_ok/results_and_model/anet12_checkpoint_best_cas_epoch30_map_0.2394.pth" # weight_file = "/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/0_NeurIPS2020_code_ok/results_and_model/anet13_checkpoint_best_cas_epoch35_map_0.2348.pth" epoch = 801 from utils.utils import load_weights model = load_weights(model, weight_file) # actions_json_file = evaluate(cfg, val_loader, model, epoch) # # evaluate_mAP(cfg, actions_json_file, os.path.join(cfg.BASIC.CKPT_DIR, cfg.DATASET.GT_FILE)) # output_json_file_cas, output_json_file_cam, test_acc_cas, test_acc_cam = evaluate(cfg, val_loader, model, epoch) output_json_file_cas, test_acc_cas = evaluate(cfg, val_loader, model, epoch) if cfg.BASIC.VERBOSE: print('test_acc, cas %f' % (test_acc_cas)) mAP, average_mAP = evaluate_mAP( cfg, output_json_file_cas, os.path.join(cfg.BASIC.CKPT_DIR, cfg.DATASET.GT_FILE), cfg.BASIC.VERBOSE)
def main(): args = args_parser() update_config(args.cfg) if cfg.BASIC.SHOW_CFG: pprint.pprint(cfg) # prepare running environment for the whole project # prepare_env(cfg) # dataloader val_dset = WtalDataset(cfg, cfg.DATASET.VAL_SPLIT) val_loader = DataLoader(val_dset, batch_size=cfg.TEST.BATCH_SIZE, shuffle=False, num_workers=cfg.BASIC.WORKERS, pin_memory=cfg.BASIC.PIN_MEMORY) # network model = LocNet(cfg) # model.apply(weight_init) model.cuda() # weight_file = '/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/anet12/anet12_0.2350_cam_inv_1_seed7_epoch36_TOPK_K_R_0.25__save_model_LR_decay/anet12_checkpoint_best_cas_0.2394.pth' weight_file = "/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/anet13/anet13_same_as_anet12_seed1_epoch45_TOPK_K_R_0.6_LR_DECAY26_save_every_model/anet13_checkpoint_best_cas_epoch28_0.2178.pth" epoch = 603 from utils.utils import load_weights model = load_weights(model, weight_file) # actions_json_file = evaluate(cfg, val_loader, model, epoch) # # evaluate_mAP(cfg, actions_json_file, os.path.join(cfg.BASIC.CKPT_DIR, cfg.DATASET.GT_FILE)) # output_json_file_cas, output_json_file_cam, test_acc_cas, test_acc_cam = evaluate(cfg, val_loader, model, epoch) output_json_file_cas, test_acc_cas = evaluate(cfg, val_loader, model, epoch) if cfg.BASIC.VERBOSE: print('test_acc, cas %f' % (test_acc_cas)) mAP, average_mAP = evaluate_mAP( cfg, output_json_file_cas, os.path.join(cfg.BASIC.CKPT_DIR, cfg.DATASET.GT_FILE), cfg.BASIC.VERBOSE)
def main(): args = args_parser() update_config(args.cfg) if cfg.BASIC.SHOW_CFG: pprint.pprint(cfg) # prepare running environment for the whole project prepare_env(cfg) # dataloader val_dset = WtalDataset(cfg, cfg.DATASET.VAL_SPLIT) val_loader = DataLoader(val_dset, batch_size=cfg.TEST.BATCH_SIZE, shuffle=False, num_workers=cfg.BASIC.WORKERS, pin_memory=cfg.BASIC.PIN_MEMORY) # network model = LocNet(cfg) # model.apply(weight_init) model.cuda() # weight_file = '/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/0_NeurIPS2020_code_ok/results_and_model/thumos14_checkpoint_best_cas_epoch125_iou0.5__0.2928.pth' # weight_file = '/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/0_NeurIPS2020_code_ok/results_and_model/anet12_checkpoint_best_cas_epoch30_map_0.2545.pth' weight_file = '/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/0_NeurIPS2020_code_ok/results_and_model/anet13_checkpoint_best_cas_epoch35_map_0.2348.pth' res_dir = os.path.join(cfg.BASIC.CKPT_DIR, cfg.TEST.RESULT_DIR,'vis/cas_weight_gt_idx_iou_0.85_mul_instance') if not os.path.exists(res_dir): os.makedirs(res_dir) from utils.utils import load_weights model = load_weights(model, weight_file) # epoch = 600 # actions_json_file, _ = evaluate(cfg, val_loader, model, epoch) # evaluate_mAP(cfg, actions_json_file, os.path.join(cfg.BASIC.CKPT_DIR, cfg.DATASET.GT_FILE), cfg.BASIC.VERBOSE) is_minmax_norm = True evaluate_vis_cas_select_specific(cfg, val_loader, model, res_dir, is_minmax_norm)
def main(): args = args_parser() update_config(args.cfg) if cfg.BASIC.SHOW_CFG: pprint.pprint(cfg) # prepare running environment for the whole project prepare_env(cfg) # dataloader val_dset = WtalDataset(cfg, cfg.DATASET.VAL_SPLIT) val_loader = DataLoader(val_dset, batch_size=cfg.TEST.BATCH_SIZE, shuffle=False, num_workers=cfg.BASIC.WORKERS, pin_memory=cfg.BASIC.PIN_MEMORY) # network model = LocNet(cfg) # model.apply(weight_init) model.cuda() weight_file = '/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/anet12/anet12_no_inv_base_LR_0.0002_BATCH_128_save_model/checkpoint_best_cas_0.2243.pth' epoch = 600 res_dir = '/disk3/zt/code/4_a/1_ECM_no_inv_drop/output/anet12/anet12_no_inv_base_LR_0.0002_BATCH_128_save_model/vis/cas_minmax_norm' if not os.path.exists(res_dir): os.makedirs(res_dir) from utils.utils import load_weights model = load_weights(model, weight_file) is_minmax_norm = True # actions_json_file = evaluate(cfg, val_loader, model, epoch) # # evaluate_mAP(cfg, actions_json_file, os.path.join(cfg.BASIC.CKPT_DIR, cfg.DATASET.GT_FILE)) # output_json_file_cas, output_json_file_cam, test_acc_cas, test_acc_cam = evaluate(cfg, val_loader, model, epoch) evaluate_vis_cas(cfg, val_loader, model, epoch, res_dir, is_minmax_norm)
def main(): args = args_parser() update_config(args.cfg) if cfg.BASIC.SHOW_CFG: pprint.pprint(cfg) # prepare running environment for the whole project prepare_env(cfg) # dataloader val_dset = WtalDataset(cfg, cfg.DATASET.VAL_SPLIT) val_loader = DataLoader(val_dset, batch_size=cfg.TEST.BATCH_SIZE, shuffle=False, num_workers=cfg.BASIC.WORKERS, pin_memory=cfg.BASIC.PIN_MEMORY) # network model = LocNet(cfg) # model.apply(weight_init) model.cuda() # weight_file = '' weight_file = '/disk/yangle/Short-Actions/ECM/output/thumos14/ECM_baseline/checkpoint_best_150.pth' res_dir = os.path.join(cfg.BASIC.CKPT_DIR, cfg.TEST.RESULT_DIR, 'vis/ECM_thumos_score') if not os.path.exists(res_dir): os.makedirs(res_dir) from utils.utils import load_weights model = load_weights(model, weight_file) epoch = 600 # output_json_file_cas, test_acc_cas = evaluate(cfg, val_loader, model, epoch) output_json_file_cas = '/disk/yangle/Short-Actions/ECM/output/thumos14/ECM_baseline/vis/ecm.json' evaluate_mAP(cfg, output_json_file_cas, os.path.join(cfg.BASIC.CKPT_DIR, cfg.DATASET.GT_FILE), cfg.BASIC.VERBOSE)
def main(): args = args_parser() update_config(args.cfg) if cfg.BASIC.SHOW_CFG: pprint.pprint(cfg) # prepare running environment for the whole project # prepare_env(cfg) # dataloader val_dset = WtalDataset(cfg, cfg.DATASET.VAL_SPLIT) val_loader = DataLoader(val_dset, batch_size=cfg.TEST.BATCH_SIZE, shuffle=False, num_workers=cfg.BASIC.WORKERS, pin_memory=cfg.BASIC.PIN_MEMORY) # network model = LocNet(cfg) # model.apply(weight_init) model.cuda() # weight_file = "" weight_file = "/disk/yangle/Short-Actions/ECM/output/thumos14/ECM_baseline/checkpoint_best_150.pth" epoch = 601 from utils.utils import load_weights model = load_weights(model, weight_file) # actions_json_file = evaluate(cfg, val_loader, model, epoch) # # evaluate_mAP(cfg, actions_json_file, os.path.join(cfg.BASIC.CKPT_DIR, cfg.DATASET.GT_FILE)) # output_json_file_cas, output_json_file_cam, test_acc_cas, test_acc_cam = evaluate(cfg, val_loader, model, epoch) output_json_file_cas, test_acc_cas = evaluate(cfg, val_loader, model, epoch) if cfg.BASIC.VERBOSE: print('test_acc, cas %f' % (test_acc_cas)) mAP, average_mAP = evaluate_mAP(cfg, output_json_file_cas, os.path.join(cfg.BASIC.CKPT_DIR, cfg.DATASET.GT_FILE), cfg.BASIC.VERBOSE)
def main(): args = args_parser() update_config(args.cfg) if cfg.BASIC.SHOW_CFG: pprint.pprint(cfg) # prepare running environment for the whole project prepare_env(cfg) # log writer = SummaryWriter( log_dir=os.path.join(cfg.BASIC.CKPT_DIR, cfg.BASIC.LOG_DIR)) # dataloader train_dset = WtalDataset(cfg, cfg.DATASET.TRAIN_SPLIT) train_loader = DataLoader(train_dset, batch_size=cfg.TRAIN.BATCH_SIZE, shuffle=True, num_workers=cfg.BASIC.WORKERS, pin_memory=cfg.BASIC.PIN_MEMORY) val_dset = WtalDataset(cfg, cfg.DATASET.VAL_SPLIT) val_loader = DataLoader(val_dset, batch_size=cfg.TEST.BATCH_SIZE, shuffle=False, num_workers=cfg.BASIC.WORKERS, pin_memory=cfg.BASIC.PIN_MEMORY) # network model = LocNet(cfg) # model.apply(weight_init) model.cuda() # weight_file = "/disk3/zt/code/actloc/thumos/17_CAS_CAM_fast_tuning/output/20class_seed_0_save_model/checkpoint_best_cas_0.2701.pth" weight_file = '/disk3/zt/code/actloc/thumos/20_0.2701_try/output/debug_save_epoch30/checkpoint_best_cas.pth' from utils.utils import load_weights model = load_weights(model, weight_file) # optimizer optimizer = optim.Adam(model.parameters(), lr=cfg.TRAIN.LR, betas=cfg.TRAIN.BETAS, weight_decay=cfg.TRAIN.WEIGHT_DECAY) optimizer.load_state_dict(torch.load(weight_file)['optimizer']) # criterion criterion = BasNetLoss() for epoch in range(1, cfg.TRAIN.EPOCH_NUM + 1): print('Epoch: %d:' % epoch) loss_average_cas, loss_average_cam, loss_average_consistency, loss_average_norm, loss_average_cas_inv, loss_average_cam_inv = train( cfg, train_loader, model, optimizer, criterion) writer.add_scalar('train_loss/cas', loss_average_cas, epoch) writer.add_scalar('train_loss/cam', loss_average_cam, epoch) writer.add_scalar('train_loss/consistency', loss_average_consistency, epoch) writer.add_scalar('train_loss/norm', loss_average_norm, epoch) writer.add_scalar('train_loss/cas_inv', loss_average_cas_inv, epoch) writer.add_scalar('train_loss/cam_inv', loss_average_cam_inv, epoch) if cfg.BASIC.VERBOSE: print( 'loss: cas %f, cam %f, consistency %f, norm %f, cas_inv %f, cam_inv %f' % (loss_average_cas, loss_average_cam, loss_average_consistency, loss_average_norm, loss_average_cas_inv, loss_average_cam_inv)) # decay learning rate if epoch in cfg.TRAIN.LR_DECAY_EPOCHS: decay_lr(optimizer, factor=cfg.TRAIN.LR_DECAY_FACTOR) if epoch % cfg.TEST.EVAL_INTERVAL == 0: _, _, test_acc_cas, test_acc_cam = evaluate( cfg, val_loader, model, epoch) if cfg.BASIC.VERBOSE: print('test_acc, cas %f, cam %f' % (test_acc_cas, test_acc_cam)) writer.add_scalar('test_acc/cas', test_acc_cas, epoch) writer.add_scalar('test_acc/cam', test_acc_cam, epoch) writer.close()
def main(): args = args_parser() update_config(args.cfg) if cfg.BASIC.SHOW_CFG: pprint.pprint(cfg) # prepare running environment for the whole project prepare_env(cfg) # log writer = SummaryWriter( log_dir=os.path.join(cfg.BASIC.CKPT_DIR, cfg.BASIC.LOG_DIR)) # dataloader train_dset = WtalDataset(cfg, cfg.DATASET.TRAIN_SPLIT) train_loader = DataLoader(train_dset, batch_size=cfg.TRAIN.BATCH_SIZE, shuffle=True, num_workers=cfg.BASIC.WORKERS, pin_memory=cfg.BASIC.PIN_MEMORY) val_dset = WtalDataset(cfg, cfg.DATASET.VAL_SPLIT) val_loader = DataLoader(val_dset, batch_size=cfg.TEST.BATCH_SIZE, shuffle=False, num_workers=cfg.BASIC.WORKERS, pin_memory=cfg.BASIC.PIN_MEMORY) # network model = LocNet(cfg) model.cuda() # optimizer optimizer = optim.Adam(model.parameters(), lr=cfg.TRAIN.LR, betas=cfg.TRAIN.BETAS, weight_decay=cfg.TRAIN.WEIGHT_DECAY) # criterion criterion = BasNetLoss() for epoch in range(1, cfg.TRAIN.EPOCH_NUM + 1): print('Epoch: %d:' % epoch) loss_average_cas, loss_average_cam, loss_average_consistency, loss_average_norm, loss_average_cam_inv = train( cfg, train_loader, model, optimizer, criterion) writer.add_scalar('train_loss/cas', loss_average_cas, epoch) writer.add_scalar('train_loss/cam', loss_average_cam, epoch) writer.add_scalar('train_loss/consistency', loss_average_consistency, epoch) writer.add_scalar('train_loss/norm', loss_average_norm, epoch) writer.add_scalar('train_loss/cam_inv', loss_average_cam_inv, epoch) if cfg.BASIC.VERBOSE: print( 'loss: cas %f, cam %f, consistency %f, norm %f, cam_inv %f' % (loss_average_cas, loss_average_cam, loss_average_consistency, loss_average_norm, loss_average_cam_inv)) # decay learning rate if epoch in cfg.TRAIN.LR_DECAY_EPOCHS: decay_lr(optimizer, factor=cfg.TRAIN.LR_DECAY_FACTOR) if epoch % cfg.TEST.EVAL_INTERVAL == 0: _, test_acc_cas = evaluate(cfg, val_loader, model, epoch) if cfg.BASIC.VERBOSE: print('test_acc, cas %f' % (test_acc_cas)) writer.add_scalar('test_acc/cas', test_acc_cas, epoch) save_best_model(cfg, epoch=epoch, model=model, optimizer=optimizer, name='cas') writer.close()