Package: autovideo
AutoVideo: An Automated Video Action Recognition SystemAutoVideo is a system for automated video analysis. It is developed based onD3Minfrastructure, which describes machine learning with generic pipeline languages. Currently, it focuses on video action recognition, supporting a complete training pipeline consisting of data processing, video processing, video transformation, and action recognition. It also supports automated tuners for pipeline search. AutoVideo is developed byDATA Labat Rice University.Paper:https://arxiv.org/abs/2108.04212Demo Video:https://youtu.be/vXpRfsdt1a0Tutorial:[Towards Data Science] AutoVideo: An Automated Video Action Recognition SystemRelated Project:TODS: Automated Time-series Outlier Detection SystemThere are some other video analysis libraries out there, but this one is designed to be highly modular. AutoVideo is highly extendible thanks to the pipeline language, where each module is wrapped as a primitive with some hyperparameters. This allows us to easily develop new modules. It is also convenient to perform pipeline search. We welcome contributions to enrich AutoVideo with more primitives. You can find instructions inContributing Guide.Cite this workIf you find this repo useful, you may cite:Zha, Daochen, et al. "AutoVideo: An Automated Video Action Recognition System." arXiv preprint arXiv:2108.0421 (2021).@article{zha2021autovideo,title={AutoVideo: An Automated Video Action Recognition System},author={Zha, Daochen and Bhat, Zaid and Chen, Yi-Wei and Wang, Yicheng and Ding, Sirui and Jain, Anmoll and Bhat, Mohammad and Lai, Kwei-Herng and Chen, Jiaben and Zou, Na and Hu, Xia},journal={arXiv preprint arXiv:2108.04212},year={2021}}InstallationMake sure that you havePython 3.6+andpipinstalled. Currently the code is only tested in Linux system. First, installtorchandtorchvisionwithpip3 install torch
pip3 install torchvisionTo use the automated searching, you need to install ray-tune and hyperopt withpip3 install 'ray[tune]' hyperoptWe recommend installing the stable version ofautovideowithpip:pip3 install autovideoAlternatively, you can clone the latest version withgit clone https://github.com/datamllab/autovideo.gitThen install withcd autovideo
pip3 install -e .Quick StartTo try the examples, you may downloadhmdb6dataset, which is a subset ofhmdb51with only 6 classes. All the datasets can be downloaded fromGoogle Drive. Then, you may unzip a dataset and put it indatasets. You may also try STGCN for skeleton-based action recogonition onkinetics36, which is a subset of Kinetics dataset with 36 classes.Fitting and saving a pipelinepython3 examples/fit.pySome important hyperparameters are as follows.--alg: the supported algorithm. Currently we supporttsn,tsm,i3d,eco,eco_full,c3d,r2p1d,r3d,stgcn.--pretrained: whether loading pre-trained weights and fine-tuning.--gpu: which gpu device to use. Empty string for CPU.--data_dir: the directory of the dataset--log_dir: the path for sainge the log--save_path: the path for saving the fitted pipelineIn AutoVideo, all the pipelines can be described as Python Dictionaries. Inexamplers/fit.py, the default pipline is defined below.config={"transformation":[("RandomCrop",{"size":(128,128)}),("Scale",{"size":(128,128)}),],"augmentation":[("meta_ChannelShuffle",{"p":0.5}),("blur_GaussianBlur",),("flip_Fliplr",),("imgcorruptlike_GaussianNoise",),],"multi_aug":"meta_Sometimes","algorithm":"tsn","load_pretrained":False,"epochs":50,}This pipeline describes what transformation and augmentation primitives will be used, and also how the multiple augmentation primitives are combined. It also specifies using TSN to train 50 epochs from scratch. The hyperparameters can be flexibly configured based on the hyperparameters defined in each primitive.Loading a fitted pipeline and producing predictionsAfter fitting a pipeline, you can load a pipeline and make predictions.python3 examples/produce.pySome important hyperparameters are as follows.--gpu: which gpu device to use. Empty string for CPU.--data_dir: the directory of the dataset--log_dir: the path for saving the log--load_path: the path for loading the fitted pipelineLoading a fitted pipeline and recogonizing actionsAfter fitting a pipeline, you can also make predicitons on a single video. As a demo, you may download the fitted pipeline and the demo video fromGoogle Drive. Then, you can use the following command to recogonize the action in the video:python3 examples/recogonize.pySome important hyperparameters are as follows.--gpu: which gpu device to use. Empty string for CPU.--video_path: the path of video file--log_dir: the path for saving the log--load_path: the path for loading the fitted pipelineFitting and producing a pipelineAlternatively, you can dofitandproducewithout saving the model withpython3 examples/fit_produce.pySome important hyperparameters are as follows.--alg: the supported algorithm.--pretrained: whether loading pre-trained weights and fine-tuning.--gpu: which gpu device to use. Empty string for CPU.--data_dir: the directory of the dataset--log_dir: the path for saving the logAutomated searchingIn addition to running them by yourself, we also support automated model selection and hyperparameter tuning:python3 examples/search.pySome important hyperparameters are as follows.--alg: the searching  algorithm. Currently, we supportrandomandhyperopt.--num_samples: the number of samples to be tried--gpu: which gpu device to use. Empty string for CPU.--data_dir: the directory of the datasetSearch sapce can also be specified as Python Dictionaries. An example:search_space={"augmentation":{"aug_0":tune.choice([("arithmetic_AdditiveGaussianNoise",),("arithmetic_AdditiveLaplaceNoise",),]),"aug_1":tune.choice([("geometric_Rotate",),("geometric_Jigsaw",),]),},"multi_aug":tune.choice(["meta_Sometimes","meta_Sequential",]),"algorithm":tune.choice(["tsn"]),"learning_rate":tune.uniform(0.0001,0.001),"momentum":tune.uniform(0.9,0.99),"weight_decay":tune.uniform(5e-4,1e-3),"num_segments":tune.choice([8,16,32]),}Supported Action Recogoniton AlgorithmsAlgorithmsPrimitive PathPaperTSNautovideo/recognition/tsn_primitive.pyTemporal Segment Networks: Towards Good Practices for Deep Action RecognitionTSMautovideo/recognition/tsm_primitive.pyTSM: Temporal Shift Module for Efficient Video UnderstandingR2P1Dautovideo/recognition/r2p1d_primitive.pyA Closer Look at Spatiotemporal Convolutions for Action RecognitionR3Dautovideo/recognition/r3d_primitive.pyLearning spatio-temporal features with 3d residual networks for action recognitionC3Dautovideo/recognition/c3d_primitive.pyLearning Spatiotemporal Features with 3D Convolutional NetworksECO-Liteautovideo/recognition/eco_primitive.pyECO: Efficient Convolutional Network for Online Video UnderstandingECO-Fullautovideo/recognition/eco_full_primitive.pyECO: Efficient Convolutional Network for Online Video UnderstandingI3Dautovideo/recognition/i3d_primitive.pyQuo Vadis, Action Recognition? A New Model and the Kinetics DatasetSTGCNautovideo/recognition/stgcn_primitive.pySpatial Temporal Graph Convolutional Networks for Skeleton-Based Action RecognitionSupported Augmentation PrimitivesWe have adapted all the augmentation methods inimgaugto videos and wrap them as primitives. Some examples are as below.Augmentation MethodPrimitive PathAddElementwiseautovideo/augmentation/arithmetic/AddElementwise_primitive.pyCartoonautovideo/augmentation/artistic/Cartoon_primitive.pyBlendAlphaBoundingBoxesautovideo/augmentation/blend/BlendAlphaBoundingBoxes_primitive.pyAverageBlurautovideo/augmentation/blend/AverageBlur_primitive.pyAddToBrightnessautovideo/augmentation/color/AddToBrightness_primitive.pyAllChannelsCLAHEautovideo/augmentation/contrast/AllChannelsCLAHE_primitive.pyDirectedEdgeDetectautovideo/augmentation/convolutional/DirectedEdgeDetect_primitive.pyDirectedEdgeDetectautovideo/augmentation/convolutional/DirectedEdgeDetect_primitive.pySaveDebugImageEveryNBatchesautovideo/augmentation/edges/SaveDebugImageEveryNBatches_primitive.pyCannyautovideo/augmentation/debug/Canny_primitive.pyFliplrautovideo/augmentation/debug/Fliplr_primitive.pyAffineautovideo/augmentation/geometric/Affine_primitive.pyBrightnessautovideo/augmentation/imgcorruptlike/Brightness_primitive.pyChannelShuffleautovideo/augmentation/meta/ChannelShuffle_primitive.pyAutocontrastautovideo/augmentation/pillike/Autocontrast_primitive.pyAveragePoolingautovideo/augmentation/pooling/AveragePooling_primitive.pyRegularGridVoronoiautovideo/augmentation/segmentation/RegularGridVoronoi_primitive.pyCenterCropToAspectRatioautovideo/augmentation/size/CenterCropToAspectRatio_primitive.pyCloudsautovideo/augmentation/weather/Clouds_primitive.pySee theFull List of Augmentation PrimitivesAdvanced UsageBeyond the above examples, you can also customize the configurations.Configuring the hypereparamtersEach model in AutoVideo is wrapped as a primitive, which contains some hyperparameters. An example of TSN ishere. All the hyperparameters can be specified when building the pipeline by passing aconfigdictionary. Seeexamples/fit.py.Configuring the search spaceThe tuner will search the best hyperparamter combinations within a search sapce to improve the performance. The search space can be defined with ray-tune. Seeexamples/search.py.Preparing datasets and benchmarkingThe datasets must follow d3m format, which consists of a csv file and a media folder. The csv file should have three columns to specify the instance indices, video file names and labels. An example is as belowd3mIndex,video,label
0,Aussie_Brunette_Brushing_Hair_II_brush_hair_u_nm_np1_ri_med_3.avi,0
1,brush_my_hair_without_wearing_the_glasses_brush_hair_u_nm_np1_fr_goo_2.avi,0
2,Brushing_my_waist_lenth_hair_brush_hair_u_nm_np1_ba_goo_0.avi,0
3,brushing_raychel_s_hair_brush_hair_u_cm_np2_ri_goo_2.avi,0
4,Brushing_Her_Hair__[_NEW_AUDIO_]_UPDATED!!!!_brush_hair_h_cm_np1_le_goo_1.avi,0
5,Haarek_mmen_brush_hair_h_cm_np1_fr_goo_0.avi,0
6,Haarek_mmen_brush_hair_h_cm_np1_fr_goo_1.avi,0
7,Prelinger_HabitPat1954_brush_hair_h_nm_np1_fr_med_26.avi,0
8,brushing_hair_2_brush_hair_h_nm_np1_ba_med_2.avi,0The media folder should contain video files. You may refer to our example hmdb6 dataset inGoogle Drive. We have also prepared hmdb51 and ucf101 in the Google Drive for benchmarking. Please readbenchmarkfor more details. For some of the algorithms (TSN, TSM, C3D, R2P1D and R3D), if you want to load the pre-trained weights and fine-tune, you need to download the weights fromGoogle Driveand put it toweights.