Ejemplo n.º 1
0
 def __init__(self, batch_size, train_video_length_info, unit_feature_size, unit_size, lambda_reg, lr, train_clip_path, test_clip_path, train_flow_feature_dir, train_appr_feature_dir, test_flow_feature_dir, test_appr_feature_dir):
     
     self.batch_size = batch_size
     self.test_batch_size = 1
     self.lr = lr
     self.lambda_reg = lambda_reg
     self.unit_feature_size = unit_feature_size  # 4096
     self.visual_feature_dim = unit_feature_size # 4096
     self.train_set = TrainingDataSet(train_flow_feature_dir,train_appr_feature_dir,train_clip_path, batch_size, train_video_length_info,unit_feature_size,unit_size)
     self.test_set = TestingDataSet(test_flow_feature_dir, test_appr_feature_dir, test_clip_path, self.test_batch_size)
Ejemplo n.º 2
0
 def __init__(self, batch_size, train_csv_path, test_csv_path, test_visual_feature_dir, train_visual_feature_dir):
     
     self.batch_size = batch_size
     self.test_batch_size = 1
     self.vs_lr = 0.005
     self.lambda_regression = 0.01
     self.alpha = 1.0/batch_size
     self.semantic_size = 1024 # the size of visual and semantic comparison size
     self.sentence_embedding_size = 4800
     self.visual_feature_dim = 4096*3
     self.train_set=TrainingDataSet(train_visual_feature_dir, train_csv_path, self.batch_size)
     self.test_set=TestingDataSet(test_visual_feature_dir, test_csv_path, self.test_batch_size)
Ejemplo n.º 3
0
    def __init__(self, config):
        """Initialization
        """
        self.config = config

        self.sess = None
        self.saver = None

        self.train_clip_path = self.config.train_clip_path
        self.background_path = self.config.background_path
        self.test_clip_path = self.config.test_clip_path
        self.train_flow_feature_dir = self.config.train_flow_feature_dir
        self.train_appr_feature_dir = self.config.train_appr_feature_dir
        self.test_flow_feature_dir = self.config.test_flow_feature_dir
        self.test_appr_feature_dir = self.config.test_appr_feature_dir
        self.test_len_dict = self.config.test_len_dict

        self.batch_size = self.config.batch_size

        self.test_batch_size = 1
        self.middle_layer_size = 1000

        self.lambda_reg = float(self.config.lambda_reg)
        self.action_class_num = self.config.action_class_num
        self.feat_type = self.config.feat_type
        self.visual_feature_dim = self.config.visual_feature_dim

        # Initialize the training data and testing data
        self.train_set = TrainingDataSet(self.config,
                                         self.train_flow_feature_dir,
                                         self.train_appr_feature_dir,
                                         self.train_clip_path,
                                         self.background_path)
        self.test_set = TestingDataSet(self.config, self.test_flow_feature_dir,
                                       self.test_appr_feature_dir,
                                       self.test_clip_path,
                                       self.test_batch_size,
                                       self.test_len_dict)

        # Path to save the summary of the models
        self.summary_dir = os.path.join('./summary', self.config.save_name)

        if not os.path.exists(self.summary_dir):
            os.mkdir(self.summary_dir)

        if self.config.issave == 'Yes':
            self.model_dir = os.path.join('./model', self.config.save_name)

            if not os.path.exists(self.model_dir):
                os.mkdir(self.model_dir)
Ejemplo n.º 4
0
    def __init__(self, batch_size, train_video_length_info, ctx_num,
                 unit_feature_size, unit_size, lambda_reg, lr, train_clip_path,
                 background_path, test_clip_path, train_visual_feature_dir,
                 test_visual_feature_dir):

        self.batch_size = batch_size
        self.test_batch_size = 1
        self.lr = lr
        self.lambda_reg = lambda_reg
        self.unit_feature_size = unit_feature_size
        self.visual_feature_dim = unit_feature_size * 3
        self.train_set = TrainingDataSet(train_visual_feature_dir,
                                         train_clip_path, background_path,
                                         batch_size, train_video_length_info,
                                         ctx_num, unit_feature_size, unit_size)
        self.test_set = TestingDataSet(test_visual_feature_dir, test_clip_path,
                                       self.test_batch_size, ctx_num)
    def __init__(self, batch_size, pool_size, train_csv_path, test_csv_path,
                 test_visual_feature_dir, train_visual_feature_dir):

        self.batch_size = batch_size
        self.test_batch_size = 1
        self.vs_lr = 0.0001
        self.lambda_regression = 0.01
        self.alpha = 1.0 / batch_size
        #self.alpha=0.06
        self.pool_size = pool_size
        self.semantic_size = 1024
        self.sentence_embedding_size = 4800
        self.visual_feature_dim = 4096
        self.train_set = TrainingDataSet(train_visual_feature_dir,
                                         train_csv_path, self.batch_size)
        self.test_set = TestingDataSet(test_visual_feature_dir, test_csv_path,
                                       self.test_batch_size)
        self.context_num = 1
Ejemplo n.º 6
0
    def __init__(self, batch_size, ctx_num, unit_size, unit_feature_size,
                 action_class_num, lr, lambda_reg, train_clip_path,
                 background_path, test_clip_path, train_flow_feature_dir,
                 train_appr_feature_dir, test_flow_feature_dir,
                 test_appr_feature_dir):

        self.batch_size = batch_size
        self.test_batch_size = 1  # 测试的时候batch = 1个clip,训练的时候batcch = 128
        self.middle_layer_size = 1000
        self.vs_lr = lr
        self.lambda_reg = lambda_reg  # 1.0
        self.action_class_num = action_class_num  # 20
        self.visual_feature_dim = unit_feature_size * 3  # 4096*3
        self.train_set = TrainingDataSet(train_flow_feature_dir,
                                         train_appr_feature_dir,
                                         train_clip_path, background_path,
                                         batch_size, ctx_num, unit_size,
                                         unit_feature_size, action_class_num)
        self.test_set = TestingDataSet(test_flow_feature_dir,
                                       test_appr_feature_dir, test_clip_path,
                                       self.test_batch_size, unit_size)
Ejemplo n.º 7
0
    def __init__(self, batch_size, train_csv_path, test_csv_path,
                 test_visual_feature_dir, sliding_dir,
                 sliding_training_sample_file, test_clip_sentence_pairs_path,
                 test_swin_txt_path, train_softmax_dir, test_softmax_dir):

        self.batch_size = batch_size
        self.test_batch_size = 1
        self.vs_lr = 0.005
        self.lambda_regression = 0.01
        self.alpha = 1.0 / batch_size
        self.semantic_size = 1024  # the size of visual and semantic comparison size
        self.action_semantic_size = 300
        self.sentence_embedding_size = 4800
        self.visual_feature_dim = 4096 * 3

        self.train_set = TrainingDataSet(sliding_dir,
                                         sliding_training_sample_file,
                                         train_csv_path, batch_size,
                                         train_softmax_dir)
        self.test_set = TestingDataSet(test_visual_feature_dir, test_csv_path,
                                       self.test_batch_size,
                                       test_swin_txt_path, test_softmax_dir,
                                       test_clip_sentence_pairs_path)
Ejemplo n.º 8
0
 def __init__(self, ):
     self.train_set = TrainingDataSet(self.batch_size)
     self.test_set = TestingDataSet()
Ejemplo n.º 9
0
initial_steps = 0
max_steps = 20000
batch_size = 64
train_csv_path = "/home/wam/Action_Recognition/TACoS/train_clip-sentvec.pkl"
test_csv_path = "/home/wam/Action_Recognition/TACoS/test_clip-sentvec.pkl"
test_feature_dir="/home/wam/Action_Recognition/Interval128_256_overlap0.8_c3d_fc6/"
train_feature_dir = "/home/wam/Action_Recognition/Interval64_128_256_512_overlap0.8_c3d_fc6/"

test_batch_size = 1
vs_lr = 0.001
lambda_regression = 0.01
alpha = 1.0/batch_size
semantic_size = 1024 # the size of visual and semantic comparison size
sentence_embedding_size = 4800
visual_feature_dim = 4096*3
train_set=TrainingDataSet(train_feature_dir, train_csv_path, batch_size)
test_set=TestingDataSet(test_feature_dir, test_csv_path, test_batch_size)

def compute_loss_reg(sim_reg_mat, offset_label):
    sim_score_mat, p_reg_mat, l_reg_mat = tf.split(sim_reg_mat, 3, 2)
    sim_score_mat = tf.reshape(sim_score_mat, [batch_size, batch_size])
    l_reg_mat = tf.reshape(l_reg_mat, [batch_size, batch_size])
    p_reg_mat = tf.reshape(p_reg_mat, [batch_size, batch_size])
    # unit matrix with -2
    I_2 = tf.diag(tf.constant(-2.0, shape=[batch_size]))
    all1 = tf.constant(1.0, shape=[batch_size, batch_size])
    mask_mat = tf.add(I_2, all1)
    # loss cls, not considering iou
    I = tf.diag(tf.constant(1.0, shape=[batch_size]))
    I_half = tf.diag(tf.constant(0.5, shape=[batch_size]))
    batch_para_mat = tf.constant(alpha, shape=[batch_size, batch_size])
Ejemplo n.º 10
0
 def __init__(self, ):
     self.train_set = TrainingDataSet(self.batch_size)
     self.val_set = ValidationDataSet()