コード例 #1
0
        acc_ish = float(correct_ish) / float(total)
    return [acc, acc_ish, correct, correct_ish]


if __name__ == '__main__':

    trained_model_names = [
        'TDID_VID_archDPlus_ntr_0_8000_81.54629_50.00000',
        #'TDID_archMM_6_9_8.38768_0.00000',
    ]

    # load data
    data_path = '/net/bvisionserver3/playpen10/ammirato/Data/ILSVRC/'

    #CREATE TRAIN/TEST splits
    data_set = VID_Loader(data_path, 'val_single', target_size=[200, 16])

    num_images = 100
    batch = True

    #test multiple trained nets
    for model_name in trained_model_names:
        print model_name
        # load net
        net = TDID()
        network.load_net(trained_model_path + model_name + '.h5', net)
        print('load model successfully!')

        net.cuda()
        net.eval()
                                          collate_fn=AVD.collate)





if save_freq > len(train_set)/batch_size:
    save_freq = len(train_set)/batch_size - 5*batch_size
    print save_freq


use_VID = False 
VID_data_path = '/net/bvisionserver3/playpen10/ammirato/Data/ILSVRC/'
target_size = [200,16]
##CREATE TRAIN/TEST splits
vid_train_set = VID_Loader(VID_data_path,'train_single', target_size=target_size, multiple_targets=True, batch_size=batch_size)



#write meta data out
meta_fid = open(os.path.join(text_out_dir,save_name_base+'.txt'),'w')
meta_fid.write('save name: {}\n'.format(save_name_base))
meta_fid.write('batch norm: {}\n'.format(use_batch_norm))
meta_fid.write('torch vgg: {}\n'.format(use_torch_vgg))
meta_fid.write('pretrained vgg: {}\n'.format(use_pretrained_vgg))
meta_fid.write('batch_size: {}\n'.format(batch_size))
meta_fid.write('vary images: {}\n'.format(vary_images))
meta_fid.write('chosen_ids: {}\n'.format(chosen_ids))
meta_fid.write('val chosen_ids: {}\n'.format(val_chosen_ids))
meta_fid.write('train_list: {}\n'.format(train_list))
meta_fid.write('val_lists: {}\n'.format(val_lists))
コード例 #3
0
# load config
cfg_from_file(cfg_file)
lr = cfg.TRAIN.LEARNING_RATE
momentum = cfg.TRAIN.MOMENTUM
weight_decay = cfg.TRAIN.WEIGHT_DECAY
disp_interval = 10  # cfg.TRAIN.DISPLAY
log_interval = cfg.TRAIN.LOG_IMAGE_ITERS

# load data
#data_path = '/playpen/ammirato/Downloads/ILSVRC/'
data_path = '/net/bvisionserver3/playpen10/ammirato/Data/ILSVRC/'

target_size = [200, 32]

#CREATE TRAIN/TEST splits
train_set = VID_Loader(data_path, 'train_single', target_size=target_size)
val_set = VID_Loader(data_path, 'val_single', target_size=target_size)

#load net definition and init parameters
net = TDID()
if load_trained_model:
    #load a previously trained model
    network.load_net(trained_model_path + trained_model_name, net)
else:
    #load pretrained vgg weights, and init everything else randomly
    network.weights_normal_init(net, dev=0.01)
    #network.load_pretrained_tdid(net, pretrained_model)
    vgg16_bn = models.vgg16_bn(pretrained=True)
    net.features = torch.nn.Sequential(
        *list(vgg16_bn.features.children())[:-1])
コード例 #4
0
    chosen_ids=chosen_ids,
    by_box=False,
    fraction_of_no_box=0.02,
    bn_normalize=use_batch_norm)

#create train/test loaders, with CUSTOM COLLATE function
trainloader = torch.utils.data.DataLoader(train_set,
                                          batch_size=2,
                                          shuffle=True,
                                          collate_fn=AVD.collate)

VID_data_path = '/net/bvisionserver3/playpen10/ammirato/Data/ILSVRC/'
target_size = [200, 16]
#CREATE TRAIN/TEST splits
train_set_VID = VID_Loader(VID_data_path,
                           'train_single',
                           target_size=target_size)

#write meta data out
meta_fid = open(os.path.join(text_out_dir, save_name_base + '.txt'), 'w')
meta_fid.write('save name: {}\n'.format(save_name_base))
meta_fid.write('batch norm: {}\n'.format(use_batch_norm))
meta_fid.write('chosen_ids: {}\n'.format(chosen_ids))
meta_fid.write('train_list: {}\n'.format(train_list))
meta_fid.write('target_path: {}\n'.format(target_path))
meta_fid.write('VID_target_size: {}\n'.format(target_size))
meta_fid.write('vid_set: {}\n'.format('train_single'))
meta_fid.write('learing rate: {}\n'.format(lr))
meta_fid.write('epoch or iters: {}\n'.format('epoch'))
meta_fid.write('AVD_freq: {}\n'.format('every other step'))
meta_fid.close()
コード例 #5
0
if rand_seed is not None:
    np.random.seed(rand_seed)

# load config
cfg_from_file(cfg_file)
lr = cfg.TRAIN.LEARNING_RATE * 10
momentum = cfg.TRAIN.MOMENTUM
weight_decay = cfg.TRAIN.WEIGHT_DECAY
disp_interval = 10  # cfg.TRAIN.DISPLAY
log_interval = cfg.TRAIN.LOG_IMAGE_ITERS

# load data
data_path = '/playpen/ammirato/Downloads/ILSVRC/'

#CREATE TRAIN/TEST splits
train_set = VID_Loader(data_path, 'val_single')
val_set = VID_Loader(data_path, 'val2_single')

#load net definition and init parameters
net = TDID()
if load_trained_model:
    #load a previously trained model
    network.load_net(trained_model_path + trained_model_name, net)
else:
    #load pretrained vgg weights, and init everything else randomly
    network.weights_normal_init(net, dev=0.01)
    network.load_pretrained_tdid(net, pretrained_model)

#put net on gpu
net.cuda()
net.train()
コード例 #6
0
    acc = 0
    acc_ish = 0
    if total != 0:
        acc = float(correct) / float(total)
        acc_ish = float(correct_ish) / float(total)
    return [acc, acc_ish]


if __name__ == '__main__':
    # load data

    # load data
    data_path = '/playpen/ammirato/Downloads/ILSVRC/'

    #CREATE TRAIN/TEST splits
    data_set = VID_Loader(data_path, 'val_single')

    num_images = 100
    batch = True

    #test multiple trained nets
    for model_name in trained_model_names:
        print model_name
        # load net
        net = TDID()
        network.load_net(trained_model_path + model_name + '.h5', net)
        print('load model successfully!')

        net.cuda()
        net.eval()