score_out = 0
class_num = 101 if args.dataset=='UCF101' else 51
split_dir = 'ucfTrainTestlist' if args.dataset=='UCF101' else 'hmdbTrainTestlist'
base_dir = '/home/ss/feats' if args.base_dir is None else args.base_dir
feat_list = ['mixed_8_join']#,'mixed_7_join']#, 'top_cls_global_pool']#['mixed_7_join','mixed_8_join','mixed_10_join']
print(feat_list)
# Data
print('==> Preparing data..')

#base_dir = '/home/ss/feats'
trainset = datasets.UCF101_mixed_v3_dict(
    rootDict={'mixed_10_join':os.path.join(base_dir,args.dataset+'_rgb_mix10_v3_npz')
              ,'mixed_8_join' :os.path.join(base_dir,args.dataset+'_rgb_mix8_v3_npz') 
              ,'mixed_7_join' :os.path.join(base_dir,args.dataset+'_rgb_mix7_v3_npz') 
             # ,'top_cls_global_pool':os.path.join(base_dir,args.dataset+'_rgb_top_v3_npz')
             },
    label=os.path.join(split_dir,'alllist.txt'), 
    ext = '_rgb.npz',
    is_training=True,
    feat_list = feat_list,
    n = args.n
    )
#['top_cls_global_pool', 'mixed_7_join', 'fc_action', 'mixed_10_join']
trainloader = torch.utils.data.DataLoader(trainset, batch_size=32, shuffle=True, num_workers=read_workers)

testset = datasets.UCF101_mixed_v3_dict(
    rootDict={'mixed_10_join':os.path.join(base_dir,args.dataset+'_rgb_mix10_v3_npz')
              ,'mixed_8_join' :os.path.join(base_dir,args.dataset+'_rgb_mix8_v3_npz')
              ,'mixed_7_join' :os.path.join(base_dir,args.dataset+'_rgb_mix7_v3_npz')
              #'top_cls_global_pool':os.path.join(base_dir,args.dataset+'_rgb_top_v3')
             },
#    rootDict={'mixed_10_join':'/media/ss/38cfe914-26f2-4a22-9cf1-bea9684775ac/lmy/temporal-segment-networks/data/UCF101_rgb_mix10_v3_npz',
Beispiel #2
0
parser.add_argument('--spa', default='UCF101')
parser.add_argument('--tim', default='UCF101')
parser.add_argument('--split', default='1')
args = parser.parse_args()

class_num = 101 if args.dataset=='UCF101' else 51
split_dir = 'ucfTrainTestlist' if args.dataset=='UCF101' else 'hmdbTrainTestlist'

base_dir = '../temporal-segment-networks/data/'
feat_list = ['mixed_8_join','mixed_7_join']#['mixed_7_join','mixed_8_join','mixed_10_join']

testset = datasets.UCF101_mixed_v3_dict(
    rootDict={'mixed_10_join':os.path.join(base_dir,args.dataset+'_rgb_mix10_v3_npz'),
              'mixed_8_join' :os.path.join(base_dir,args.dataset+'_rgb_mix8_v3_npz') ,
              'mixed_7_join' :os.path.join(base_dir,args.dataset+'_rgb_mix7_v3_npz')},
    label=os.path.join(split_dir,'testlist0'+args.split+'.txt'),
    ext = '_rgb.npz',
    is_training=False,
    feat_list = feat_list
    )
def test_with_score(score):
    true_num = 0.0
    ids = np.argmax(score, axis=1)
    for i in range(testset.__len__()):
        if testset.datas[i][1]==ids[i]:
            true_num += 1.0
    return true_num/testset.__len__()
if __name__ == '__main__':
    a = 0.0
    acc_max, a_max = 0, 0
    spa_score = np.load(args.spa)
Beispiel #3
0
split_dir = 'ucfTrainTestlist' if args.dataset=='UCF101' else 'hmdbTrainTestlist'
base_dir = '/home/ss/feats' if args.base_dir is None else args.base_dir
feat_list = ['mixed_8_join']#, 'top_cls_global_pool']#['mixed_7_join','mixed_8_join','mixed_10_join']
BATCH_SIZE=32
frame_id = args.img_id
print(feat_list)
# Data
print('==> Preparing data..')

#base_dir = '/home/ss/feats'
showset = datasets.UCF101_mixed_v3_dict(
    rootDict={'mixed_10_join':os.path.join(base_dir,args.dataset+'_rgb_mix10_v3_npz')
              ,'mixed_8_join' :os.path.join(base_dir,args.dataset+'_rgb_mix8_v3_npz') 
              ,'mixed_7_join' :os.path.join(base_dir,args.dataset+'_rgb_mix7_v3_npz') 
             # ,'top_cls_global_pool':os.path.join(base_dir,args.dataset+'_rgb_top_v3_npz')
             },
    label=os.path.join(split_dir,'part.txt'), 
    ext = '_rgb.npz',
    is_training=False,
    feat_list = feat_list,
    n = args.n
    )
showloader = torch.utils.data.DataLoader(showset, batch_size=BATCH_SIZE, shuffle=False, num_workers=read_workers)
dim = 2048
str_net = SpaNet(model_type='str', glo_channels=1280, loc_channels=768, out_channels=1, num_classes=class_num, drop_rate=drop_rate, out_type=args.type, n=args.n)
old_net = SpaNet(model_type='old', glo_channels=1280, loc_channels=8, out_channels=1, num_classes=class_num, drop_rate=drop_rate, out_type=args.type, n=args.n)

if use_cuda:
    str_net.cuda()
    str_net = torch.nn.DataParallel(str_net, device_ids=range(torch.cuda.device_count()))
    old_net.cuda()
    old_net = torch.nn.DataParallel(old_net, device_ids=range(torch.cuda.device_count()))
Beispiel #4
0
CenLoss_a = 0.001
drop_rate = 0.5
epoch_num = 50
read_workers = 16
feat_list = ['mixed_8_join',
             'mixed_7_join']  #['mixed_7_join','mixed_8_join','mixed_10_join']
print(feat_list)
# Data
print('==> Preparing data..')

BaseDir = '/home/ss/feats'
trainset = datasets.UCF101_mixed_v3_dict(
    rootDict={
        'mixed_10_join': os.path.join(BaseDir, 'UCF101_rgb_mix10_v3_npz'),
        'mixed_8_join': os.path.join(BaseDir, 'UCF101_rgb_mix8_v3_npz'),
        'mixed_7_join': os.path.join(BaseDir, 'UCF101_rgb_mix7_v3_npz')
    },
    label='./ucfTrainTestlist/trainlist01.txt.top3',
    ext='_rgb.npz',
    is_training=True,
    feat_list=feat_list)
#['top_cls_global_pool', 'mixed_7_join', 'fc_action', 'mixed_10_join']
trainloader = torch.utils.data.DataLoader(trainset,
                                          batch_size=32,
                                          shuffle=True,
                                          num_workers=read_workers)

testset = datasets.UCF101_mixed_v3_dict(
    rootDict={
        'mixed_10_join': os.path.join(BaseDir, 'UCF101_rgb_mix10_v3_npz'),
        'mixed_8_join': os.path.join(BaseDir, 'UCF101_rgb_mix8_v3_npz'),
        'mixed_7_join': os.path.join(BaseDir, 'UCF101_rgb_mix7_v3_npz')