Exemplo n.º 1
0
            batch += 1
        _, _, _, _, c = correct_preds(probs, labels.squeeze())
        if disp:
            print(i, c)
        correct.append(c)
    PCE = np.mean(correct)
    return PCE


if __name__ == "__main__":

    split = 1
    seq_length = 64
    n_cpu = 6

    model = EventDetector(
        pretrain=True,
        width_mult=1.0,
        lstm_layers=1,
        lstm_hidden=256,
        bidirectional=True,
        dropout=False,
    )

    save_dict = torch.load("models/swingnet_1800.pth.tar")
    model.load_state_dict(save_dict["model_state_dict"])
    model.cuda()
    model.eval()
    PCE = eval(model, split, seq_length, n_cpu, True)
    print("Average PCE: {}".format(PCE))
Exemplo n.º 2
0

if __name__ == '__main__':
    split = 1
    seq_length = 64
    n_cpu = 6

    model = EventDetector(pretrain=True,
                          width_mult=1,
                          lstm_layers=1,
                          lstm_hidden=256,
                          bidirectional=True,
                          dropout=False)

    rgb_save_dict = torch.load('swingnet_1600.pth.tar')
    model.load_state_dict(rgb_save_dict['model_state_dict'])
    model.cuda()
    model.eval()

    _, _, rgb_probs, rgb_tols, rgb_events = myeval(model, split, seq_length,
                                                   n_cpu, False, 1)

    optical_save_dict = torch.load('swingnet_1200.pth.tar')
    model.load_state_dict(optical_save_dict['model_state_dict'])
    model.cuda()
    model.eval()
    _, _, optical_probs, optical_tols, optical_events = myeval(
        model, split, seq_length, n_cpu, False, 0)

    if len(optical_probs) != len(rgb_probs):
        print("there is error in fusion part")
if __name__ == '__main__':

    seq_length = 64
    n_cpu = 6

    model = EventDetector(pretrain=True,
                          width_mult=1.,
                          lstm_layers=1,
                          lstm_hidden=256,
                          bidirectional=True,
                          dropout=False)

    save_dict = torch.load('models/' + version_name + '_10000.pth.tar',
                           map_location=lambda storage, loc: storage)
    model.load_state_dict(save_dict['model_state_dict'])
    model.to(device)
    model.eval()
    PCE = eval(model, split, seq_length, n_cpu, True)
    print('Average PCE: {}'.format(PCE))

    if not os.path.exists('results'):
        os.mkdir('results')

    if bool_classical_loss:
        output_file = 'results/classical.txt'
    else:
        output_file = 'results/softloc.txt'

    with open(output_file, 'a') as f:
        f.write(version_name)
Exemplo n.º 4
0
                       dropout=False)
 # model = torch.nn.parallel.DataParallel(model)
 PCES = {}
 PFCRS = {}
 vNum = 0
 for i in range(99, 100):
     index = i * 100
     print('swingnet_{}.pth.tar'.format(index))
     save_dict = torch.load('./models/swingnet_{}.pth.tar'.format(index))
     new_state_dict = save_dict['model_state_dict']
     # from collections import OrderedDict
     # new_state_dict = OrderedDict()
     # for k, v in save_dict['model_state_dict'].items():
     #     name = k[7:] # remove `module.`
     #     new_state_dict[name] = v
     model.load_state_dict(new_state_dict)
     model.cuda()
     model.eval()
     PCE, vNum, _, _, _, PFCR = myeval(model, split, seq_length, n_cpu,
                                       False, 0)
     PCES[index] = PCE
     PFCRS[index] = PFCR
 if cfg.FRAME_13_OPEN:
     print("13 frames")
     print('Average PCE: {}'.format(PCES))
     print("video file num:{}".format(vNum))
     print("per frame correct ratio:{}".format(PFCRS))
 else:
     print("8 frames")
     print('split:{}  Average PCE: {}'.format(split, PCES))
     print("video file num:{}".format(vNum))