Example #1
0
import tensorflow as tf
import numpy as np
from model_builder import build_model
from dataset import Dataset, Dataloader
import pickle
batch_size = 1
_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")
Example #2
0
    tf.logging.set_verbosity(tf.logging.INFO)
    _SAMPLE_VIDEO_FRAMES = 16
    _IMAGE_SIZE = 112
    NUM_CLASS = 101
    _CHECKPOINT_PATHS = {
        'pretrained_model': 'pretrained-models/r2plus1-18/Caffe2TfR2.5d.ckpt',
        'snapshots': 'saved_models/model.ckpt'
    }
    is_checkpoint = FLAGS.checkpoint
    batch_size = FLAGS.batch_size
    use_pretrained = FLAGS.pretrained

    train_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='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)