This document provides a brief intro of launching jobs in PySlowFast for training and testing. Before launching any job, make sure you have properly installed the PySlowFast following the instruction in README.md and you have prepared the dataset following DATASET.md with the correct format.
Here we can start with training a simple C2D models by running:
python tools/run_net.py \
--cfg configs/Kinetics/C2D_8x8_R50.yaml \
DATA.PATH_TO_DATA_DIR path_to_your_dataset \
NUM_GPUS 2 \
TRAIN.BATCH_SIZE 16 \
You may need to pass location of your dataset in the command line by adding DATA.PATH_TO_DATA_DIR path_to_your_dataset, or you can simply add
DATA:
PATH_TO_DATA_DIR: path_to_your_dataset
To the yaml configs file, then you do not need to pass it to the command line every time.
You may also want to add:
DATA_LOADER.NUM_WORKERS 0 \
NUM_GPUS 2 \
TRAIN.BATCH_SIZE 16 \
If you want to launch a quick job for debugging on your local machine.
If your checkpoint is trained by PyTorch, then you can add the following line in the command line, or you can also add it in the YAML config:
TRAIN.CHECKPOINT_FILE_PATH path_to_your_PyTorch_checkpoint
If the checkpoint in trained by Caffe2, then you can do the following:
TRAIN.CHECKPOINT_FILE_PATH path_to_your_Caffe2_checkpoint \
TRAIN.CHECKPOINT_TYPE caffe2
If you need to performance inflation on the checkpoint, remember to set TRAIN.CHECKPOINT_INFLATE to True.
We have TRAIN.ENABLE and TEST.ENABLE to control whether training or testing is required for the current job. If only testing is preferred, you can set the TRAIN.ENABLE to False, and do not forget to pass the path to the model you want to test to TEST.CHECKPOINT_FILE_PATH.
python tools/run_net.py \
--cfg configs/Kinetics/C2D_8x8_R50.yaml \
DATA.PATH_TO_DATA_DIR path_to_your_dataset \
TEST.CHECKPOINT_FILE_PATH path_to_your_checkpoint \
TRAIN.ENABLE False \
modify a <pretrained_model_config_file>.yaml in configs/Kinetics/c2/ corresponding to the pretrained model you want to use and set the following settings (you can look at demo/Kinetics/SLOWFAST_8x8_R50.yaml for reference):
TRAIN.ENABLE: FalseTEST.ENABLE: FalseCHECKPOINT_TYPE: caffe2CHECKPOINT_FILE_PATH: "path/to/the/pre-trained/model.pkl"(skip this if you decide to place the model inOUTPUT_DIRwhich is default to./checkpoints/)DEMO.ENABLE: TrueDEMO.LABEL_FILE_PATH: path to a CSV label file (already indemo/Kinetics/kinetics_400_labels.csv)..DEMO.DATA_SOURCE: Index to the camera source (if you want to run on a video, put the video path here and set values ofDEMO.DATA_SOURCEinslowfast/config/default.pyto"")NUM_GPUS: 1(only if running on a single CPU)NUM_SHARDS: 1(only if running on a single machine)
Optional:
DISPLAY_WIDTH: custom display window widthDISPLAY_HEIGHT: custom display window height
modify a <pretrained_model_config_file>.yaml in configs/AVA/c2/ corresponding to the pretrained model you want to use and set the following settings (you can look at demo/AVA/SLOWFAST_32x2_R101_50_50.yaml for reference):
TRAIN.ENABLE: FalseTEST.ENABLE: FalseDETECTION.ENABLE: TrueCHECKPOINT_TYPE: caffe2CHECKPOINT_FILE_PATH: "path/to/the/pre-trained/model.pkl"(skip this if you decide to place the model inOUTPUT_DIRwhich is default to./checkpoints/)DEMO.ENABLE: TrueDEMO.LABEL_FILE_PATH: path to a text label file (already indemo/AVA/ava.names).DEMO.DATA_SOURCE: Index to the camera source (if you want to run on a video, put the video path here and set values ofDEMO.DATA_SOURCEinslowfast/config/default.pyto"")NUM_GPUS: 1(only if running on a single CPU)NUM_SHARDS: 1(only if running on a single machine)
Optional:
DEMO.DISPLAY_WIDTH: custom display window widthDEMO.DISPLAY_HEIGHT: custom display window height
python \tools\run_net.py --cfg path/to/<pretrained_model_config_file>.yaml