feature_network.mode.set_value(np.uint8(1)) print "instantiating model..." model = RATM(name='RATM', imsize=imsize, patchsize=patchsize, nhid=nhid, numpy_rng=numpy_rng, eps=1e-4, hids_scale=1., feature_network=feature_network, input_feature_layer_name=input_feature_layer_name, metric_feature_layer_name=metric_feature_layer_name, nchannels=1, weight_decay=weight_decay) print "done (with instantiating model)" model.load( 'attention_model_kth_{0:02d}left_out_val_best.h5'.format( args.test_person)) def compute_avg_IoU(inputs, targets, masks): bbs = targets vids = inputs max_nframes = np.max(np.where(masks > .5)[1]) N = vids.shape[0] Xs = (bbs[:, :, 1::2] + bbs[:, :, ::2]) / 2. # left, right, top, bottom (w/h = r-l, b-t) width_height = bbs[:, :, 1::2] - bbs[:, :, ::2] vids = vids.astype(np.float32)
print "instantiating model..." model = RATM(name='RATM', imsize=imsize, patchsize=patchsize, nhid=nhid, numpy_rng=numpy_rng, eps=1e-4, hids_scale=1., feature_network=feature_network, input_feature_layer_name=input_feature_layer_name, metric_feature_layer_name=metric_feature_layer_name, nchannels=1, weight_decay=weight_decay) print "done (with instantiating model)" model.load('attention_model_kth_{0:02d}left_out_val_best.h5'.format( args.test_person)) def compute_avg_IoU(inputs, targets, masks): bbs = targets vids = inputs max_nframes = np.max(np.where(masks > .5)[1]) N = vids.shape[0] Xs = (bbs[:, :, 1::2] + bbs[:, :, ::2]) / 2. # left, right, top, bottom (w/h = r-l, b-t) width_height = bbs[:, :, 1::2] - bbs[:, :, ::2] vids = vids.astype(np.float32)