Last active
May 13, 2019 11:58
-
-
Save dsalaj/c9c59f23e5e9472e6729d1c7b1f1b920 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# # First create and activate conda python3 environment: | |
# conda create -n video python=3.6 | |
# conda activate video | |
# # Then install the requirements: | |
# conda install ffmpeg | |
# conda install tensorflow-gpu==1.13.1 | |
# pip install tensorflow_datasets | |
# # The bellow code would still produce an error because of the missing file ("ucf101_labels.txt") | |
# # So manually download the "ucf101_labels.txt" and put it in place: | |
# cd "/home/$USER/anaconda3/envs/video/lib/python3.6/site-packages/tensorflow_datasets/video/" | |
# wget https://raw.githubusercontent.com/tensorflow/datasets/master/tensorflow_datasets/video/ucf101_labels.txt | |
import tensorflow as tf | |
import tensorflow_datasets as tfds | |
tf.enable_eager_execution() | |
builder = tfds.builder(name="ucf101") | |
builder.download_and_prepare() # this needs to be called only once | |
dtrain = builder.as_dataset(split=tfds.Split.TRAIN) | |
dtrain = dtrain.repeat().padded_batch(1, padded_shapes={"video":[tf.Dimension(None), 256, 256, 3], "label":[]}) | |
example, = dtrain.take(1) | |
print(example.keys()) # dict_keys(['video', 'label']) | |
print(example['video'].shape) # TensorShape([Dimension(1), Dimension(74), Dimension(256), Dimension(256), Dimension(3)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment