In [2]:
from work.dataset.activitynet import ActivityNetDataset
from work.config import (STORED_FEATURES_PATH, STORED_VIDEOS_EXTENSION,
                         STORED_VIDEOS_PATH)
from keras.preprocessing.image import list_pictures
from os import listdir

dataset = ActivityNetDataset(
    videos_path='../dataset/videos.json',
    labels_path='../dataset/labels.txt',
    stored_videos_path=STORED_VIDEOS_PATH,
    files_extension=STORED_VIDEOS_EXTENSION
)
# Removing the videos which already were extracted its features
features_ids = [f[:-4] for f in listdir(STORED_FEATURES_PATH) if f[-4:] == '.npy']
print('Videos already downloaded: {} videos'.format(len(features_ids)))
to_remove = []
for video in dataset.videos:
    if video.video_id in features_ids:
        to_remove.append(video)
for video in to_remove:
    dataset.videos.remove(video)
nb_videos = len(dataset.videos)
print('Total number of videos: {} videos'.format(nb_videos))


Videos already downloaded: 3936 videos
Total number of videos: 15821 videos

In [3]:
print(len(extracted_features_files))
print(extracted_features_files[:10])


3357
['/imatge/amontes/work/datasets/ActivityNet/v1.3/features/vm64rRECzZM.npy', '/imatge/amontes/work/datasets/ActivityNet/v1.3/features/TxYZLJQOHvY.npy', '/imatge/amontes/work/datasets/ActivityNet/v1.3/features/f0hh9bwVfV0.npy', '/imatge/amontes/work/datasets/ActivityNet/v1.3/features/8cbHNUbu3Tk.npy', '/imatge/amontes/work/datasets/ActivityNet/v1.3/features/eMkBTRYwBAU.npy', '/imatge/amontes/work/datasets/ActivityNet/v1.3/features/kC8DS6b76yI.npy', '/imatge/amontes/work/datasets/ActivityNet/v1.3/features/HNIs8lFvKkA.npy', '/imatge/amontes/work/datasets/ActivityNet/v1.3/features/QRcwvzq7QUM.npy', '/imatge/amontes/work/datasets/ActivityNet/v1.3/features/c1T9LbXOVUs.npy', '/imatge/amontes/work/datasets/ActivityNet/v1.3/features/CcKeoeSZVnE.npy']

In [8]:
from os import listdir

all_files = [f[:-4] for f in listdir(STORED_FEATURES_PATH) if f[-4:] == '.npy']
print(len(all_files))
print(all_files[:10])


3936
['vm64rRECzZM', 'TxYZLJQOHvY', 'f0hh9bwVfV0', '8cbHNUbu3Tk', 'eMkBTRYwBAU', 'kC8DS6b76yI', 'HNIs8lFvKkA', 'QRcwvzq7QUM', 'c1T9LbXOVUs', 'CcKeoeSZVnE']

In [ ]: