Youtube-8m Image recognition dataset downloader and tfrecord creator. The program works in two parts
- extract.py: scraps the youtube 8m videos and downloads two frames per video (can be changed in program)
- yt8m_tfrecord.py: creates tfrecord and pbtxt of top n classes which has max images. (can be modified to choose specific classes)
All the vieos are downloaded in temp dir, frames are extracted and then video is deleted. It will also create pbtxt file for further use. multiprocessing is used in python to scrap multiple videos at sametime.
- Clone this Repo .
- Download yt8m frame level item csv from: https://drive.google.com/drive/folders/1_8jXla9b_9SEU6zLCDQADvn2qmL_HNic?usp=sharing
- Place both the files in the cloned dir
- Make relevent changes in extract.py and run (preferably in tmux or screen if on server, as it takes very long)
- Run yt8m_tfrecord.py script:
USAGE: yt8m_tfrecord.py [flags]
flags:
yt8m_tfrecord.py:
--output_dir: Directory path for tfrecords yt8m dataset. will have train and validation subdirectories inside it.
(default: 'output_tf')
--pbtxt: path to write pbtxt filepath to write pbtxt file
(default: 'label.pbtxt')
--raw_data_dir: Directory path for raw yt8m dataset. Should classes subdirectories inside it.
(default: 'output')
--top_n: top n number of classesdefault is 15
(default: '15')
(an integer)
--val_ratio: validation ratio to split datasetdefault is 0.2
(default: '0.2')
(a number)
- Python 3
- youtube-dl
- OpenCV
- pandas
- tensorflow
- imutils (if you would like to resize frames)
This you would already know
You will need youtube-dl. Installation instruction can be found on this link youtube-dl Still for your quick reference will list installation instruction:
sudo -H pip3 install --upgrade youtube-dl
There are various way to install OpenCV but example using (Conda, PIP or build from source). But for purpose of this project below is instruction using PIP
pip3 install opencv-contrib-python
pip3 install pandas
pip3 install tensorflow
or
pip3 install tensorflow-gpu
pip3 install imutils
This project is licensed under the Apache License - see the LICENSE file for details