1st place solution to Kaggle's 2018 YouTube-8M Video Understanding Challenge
1st place solution to Kaggle's 2018 YouTube-8M Video Understanding Challenge
This repository contains all code used by first placed team "Next top GB model" (David and Miha skalic) in the Kaggle's competition The 2nd YouTube-8M Video Understanding Challenge.
The repository is a fork of google's repository and borrows from Wang et al, Miech et al and Skalic et al. Code is released under Apache License Version 2.0.
This readme walks through a specific example to reproduce training, eval, distillation, quantization, graph combination for a single model type.
@inproceedings{skalic2018building,
title={Building A Size Constrained Predictive Models for Video Classification},
author={Skalic, Miha and Austin, David},
booktitle={European Conference on Computer Vision},
pages={297--305},
year={2018},
organization={Springer}
}All models herein were trained in single GPU mode and the instructions that follow will reproduce this step. The overall flow for training each model is as follows:
This readme will walk through all commands to train both stand-alone and a distillation model. For model details for other models see all_models.txt.
All code was run using Python 2.7 and Tensorflow 1.8.0. All models were trained on GPU's. The requirements.txt file contains a list of all libraries installed in the environment used for training and testing. While all libraries are not required, the having the full list should ensure complete compatibility with all code.
Make sure to set your local paths correctly for the train and save paths:
…Once training is complete, eval is performed as follows:
……Change savefile to specific save path
python quantize.py \
--transform_type quant_uniform \
--model "$SAVEPATH//NetVLAD_ema/inference_model" \
--savefile ../trained_models/quants/your_model/inference_model
cp $SAVEPATH//NetVLAD_ema/model_flags.json ../trained_models/quants/your_model
graph_ensemble.py takes in 2 or more trained models and combines them into a single graph. Sample usage:
python graph_ensemble.py \
--models ../trained_models/quants/74/inference_model \
../trained_models/model_1/inference_model \
../trained_models/model_2/inference_model \
../trained_models/model_3/inference_model \
--weights 0.3333 0.3333 0.3334 \
--save_folder ../train_models/your_combined_output_graph
RECORDPATTEST="../data/frame/test"
python inference_gpu.py \
--train_dir "../trained_models/quants/your_model" \
--output_file="./output.csv" \
--input_data_pattern="$RECORDPATtest/*.tfrecord" \
--batch_size 200 \
--sample_allWARNING: Large dataset creation! Creating a new Distillation set will consume ~1.4TB of data so you'll need to have the storage space available.
python prepare_distill_dataset.py --batch_size 128 --file_size 512 --input_data_pattern "$RECORDPATVAL/*.tfrecord" --output_dir "output_folder/train_distill/" --model_file "../train_models/your_ensemble_model/inference_model"
Training on a distillation dataset can be done using train_distill.py script. Use same flags as in train.py.
File model_configs.xlsx contains the arhitectures of models used in the work.
Trained model as .tar.gz can be downloaded from here.
See inference.py for sample usage of the model. Folder feature_extractor contains information on
preprocessing custom videos.
No open issues yet, or sync has not completed.