Example #1
0
_SAMPLE_VIDEO_FRAMES = 24
_LABEL_MAP_PATH = '/home/pr606/python_vir/yuan/i3d-kinects/data/label_map.txt'
with open(_LABEL_MAP_PATH) as f2:
    kinetics_classes = [x.strip() for x in f2.readlines()]

validate_set = Dataset.DataSet(clip_length=_SAMPLE_VIDEO_FRAMES,
                                        sample_step=2,
                                        data_root='/home/pr606/Pictures/part_validate_kinetics',
                                        annotation_path='/home/pr606/python_vir/yuan/EXTRA_DATA/kinetics_part.json',
                                        spatial_transform=None,
                                        mode='validation',
                                        with_start=True,
                                        multi_sample=True
                                        )

validate_generator = Dataloader.DataGenerator(validate_set, batch_size=batch_size, ordered_file_path='/home/pr606/python_vir/yuan/EXTRA_DATA/names_in_order.csv')


num_validate = validate_generator.__len__() # 1005
print("total validate data is :{}".format(num_validate))


inputs = tf.placeholder(shape=(batch_size,_SAMPLE_VIDEO_FRAMES,112,112,3),dtype=tf.float32)

mean, variance = tf.nn.moments(inputs, axes=(0, 1, 2, 3), keep_dims=True, name="normalize_moments")

Gamma = tf.constant(1.0, name="scale_factor", shape=mean.shape, dtype=tf.float32)
Beta = tf.constant(0.0,name="offset_factor", shape=mean.shape, dtype=tf.float32)
data = tf.nn.batch_normalization(inputs, mean, variance, offset=Beta, scale=Gamma, variance_epsilon=1e-3)

'''
Example #2
0
        clip_length=_SAMPLE_VIDEO_FRAMES,
        sample_step=2,
        data_root='/home/pr606/Pictures/UCF101DATASET/ucf101',
        annotation_path=
        '/home/pr606/Pictures/dataset_annotations/ucf101_json_file/ucf101_01.json',
        spatial_transform=None,
        mode='train')
    validate_set = Dataset.DataSet(
        clip_length=_SAMPLE_VIDEO_FRAMES,
        sample_step=2,
        data_root='/home/pr606/Pictures/UCF101DATASET/ucf101',
        annotation_path=
        '/home/pr606/Pictures/dataset_annotations/ucf101_json_file/ucf101_01.json',
        spatial_transform=None,
        mode='validation')
    train_generator = Dataloader.DataGenerator(train_set,
                                               batch_size=batch_size)
    validate_generator = Dataloader.DataGenerator(validate_set,
                                                  batch_size=batch_size)
    num_train = train_generator.__len__()
    num_validate = validate_generator.__len__()

    print("training data num is %d" % num_train)  # 733
    print("validation data num is %d" % num_validate)  # 291

    graph = tf.get_default_graph()
    with graph.as_default():
        data = tf.placeholder(shape=(batch_size, _SAMPLE_VIDEO_FRAMES,
                                     _IMAGE_SIZE, _IMAGE_SIZE, 1),
                              dtype=tf.float32)
        label = tf.placeholder(shape=(batch_size, NUM_CLASS), dtype=tf.int32)
        result = models(data, class_num=101, scope='at_model')