Package: ppvideo
English |简体中文PaddleVide Quick Start1. Installation1.1 Install PaddlePaddle1.2 Install PaddleVideo Whl Package2. Easy-to-Use2.1 Use by Command Line2.2 Use by Python Code3. Arguments description4.QA1. Installation1.1 Install PaddlePaddleIf you have CUDA 9 or CUDA 10 installed on your machine, please run the following command to installpython3.7-mpipinstallpaddlepaddle-gpu-ihttps://mirror.baidu.com/pypi/simpleIf you have no available GPU on your machine, please run the following command to install the CPU versionpython3.7-mpipinstallpaddlepaddle-ihttps://mirror.baidu.com/pypi/simpleFor more software version requirements, please refer to the instructions inInstallation Documentfor operation.1.2 Install PaddleVideo Whl Packageoption1: use pypi（recommand）pip3.7installppvideo==2.3.0option2: build and install locallypython3.7setup.pybdist_wheel
python3.7-mpipinstalldist/ppvideo-2.3.0-py3-none-any.whl2. Easy-to-Use2.1 Use by Command LineRun shell command：ppvideo--model_name='ppTSM_v2'--use_gpu=False--video_file='data/example.avi'This command usePP-TSM_v2model to inferdata/example.avifile inCPU.The length of the example video is about 10s. When inference, the video is first divided into 16 segments according to the time axis, then extract one frame from each segment. Finally all frames are combined and feeded into the network.Results：Current video file: data/example.avi
        top-1 classes: [5]
        top-1 scores: [1.]
        top-1 label names: ['archery']As you can see, usePP-TSM_v2trained on Kinetics-400 to predictdata/example.avivideo，top1 prediction class_id is5, scores is1.0, class name isarchery.2.2 Use by Python CodeRun python code：fromppvideoimportPaddleVideoclas=PaddleVideo(model_name='ppTSM_v2',use_gpu=False)video_file='data/example.avi'clas.predict(video_file)This code usePP-TSM_v2model to inferdata/example.avifile inCPU.Results:Current video file: data/example.avi
        top-1 classes: [5]
        top-1 scores: [1.]
        top-1 label names: ['archery']As you can see, usePP-TSM_v2trained on Kinetics-400 to predictdata/example.avivideo，top1 prediction class_id is5, scores is1.0, class name isarchery.3. Arguments descriptionnametypedescriptionmodel_namestroptional, model name,'ppTSM'or'ppTSM_v2'. If None, please specify the path of your inference model by argsmodel_fileandparams_file.video_filestrrequired, Video file path, supported format: single video file path, or folder containing multiple videos.use_gpuboolwhether to use GPU，default True。num_segintThe number of segments used in the TSM model, which is also the number of frames extracted from the video. 8 forppTSM, 16 forppTSM_v2, default 16.short_sizeintshort size of frame, default 256.target_sizeinttarget size of frame, default 224.model_filestroptional，inference model(.pdmodel)path.params_filestroptional, inference modle(.pdiparams) path.batch_sizeintBatch size, default 1.use_fp16boolwhether to use float16，default False.use_tensorrtboolwhether to use Tensorrt, default False.gpu_memintuse GPU memory, default 8000.enable_mkldnnboolwhether to use MKLDNN, default False.top_kinttop_k, default 1.label_name_pathstrThis file consists the relation of class_id and class_name. Default usedata/k400/Kinetics-400_label_list.txtof Kinetics-400. You can replace it with your own label file.command example1：ppvideo--model_name='ppTSM_v2'--num_seg=16--video_file="data/mp4"--batch_size=2--top_k=5Results：Current video file: data/mp4/example3.avi
        top-5 classes: [  5 345 311 159 327]
        top-5 scores: [1.0000000e+00 1.0152016e-11 8.2871061e-14 6.7713670e-14 5.0752070e-14]
        top-5 label names: ['archery', 'sword_fighting', 'skipping_rope', 'hula_hooping', 'spray_painting']
Current video file: data/mp4/example2.avi
        top-5 classes: [  5 345 311 159 327]
        top-5 scores: [1.0000000e+00 1.0152016e-11 8.2871061e-14 6.7713670e-14 5.0752070e-14]
        top-5 label names: ['archery', 'sword_fighting', 'skipping_rope', 'hula_hooping', 'spray_painting']
Current video file: data/mp4/example.avi
        top-5 classes: [  5 345 311 159 327]
        top-5 scores: [1.0000000e+00 1.0152016e-11 8.2871061e-14 6.7713670e-14 5.0752070e-14]
        top-5 label names: ['archery', 'sword_fighting', 'skipping_rope', 'hula_hooping', 'spray_painting']
Current video file: data/mp4/example1.avi
        top-5 classes: [  5 345 311 159 327]
        top-5 scores: [1.0000000e+00 1.0152016e-11 8.2871061e-14 6.7713670e-14 5.0752070e-14]
        top-5 label names: ['archery', 'sword_fighting', 'skipping_rope', 'hula_hooping', 'spray_painting']command example1：ppvideo--model_name='ppTSM'--num_seg=8--video_file="data/mp4"--batch_size=2--top_k=54. QAopecv-python Installation maybe slow, you can try:python3.7 -m pip install opencv-python==4.2.0.32 -i https://pypi.doubanio.com/simple