Skip to content

coffee19850519/gait

Repository files navigation

Gait Recognition

Requistments

  1. tensorflow-gpu >= 1.10.0
  2. python >= 3.6
  3. opencv-python >= 2.4.8
  4. scipy
  5. numpy
  6. matplotlib

File Introduction

  • Folder(should create manually before running):

    • ./image/frames_data/ —— Cache frame data after the video has been converted
    • ./models/ —— Pose-estimation pre-trained models ,download them from here
    • ./models_pose/ —— Alternative Pose-estimation pre-trained model,download from here
  • Core Files

    • video_to_pic.py —— convert videos data into frames data
    • pose_estimation.py —— estimate the pose of people of frames data,and generate the pose-vector ,save pose-vector data as TFrecords files.
    • gait_model.py —— define the gait model:3D Resnet model , able to train and validate
    • test_model.py —— test the model use test data
    • other files are supportive

How to use

  1. run python pose_estimation.py -h to get the parameters information ,such as :

       usage: pose_estimation.py [-h] [-d DATA_DIR] [-t DATA_TYPE] [-n NUM_CLASSES]
       process video data and generate pose-vector,save as TFrecords al last
       optional arguments:
       -h, --help            show this help message and exit
       -d DATA_DIR, --data_dir DATA_DIR
                           your video data path
       -t DATA_TYPE, --data_type DATA_TYPE
                           your data type : train or test or val,Consistent with
                           data_dir,if data_dir='train-set
                           path',data_type='train'
       -n NUM_CLASSES, --num_classes NUM_CLASSES
    
       Therefore,when you want to run this file ,you should set these parameters. Here is the correct example
    

CUDA_VISIBLE_DEVICES=0 python pose_estimation.py -d '/home/a524wangye/USA_gait/video/train' -t 'train' -n 3

CUDA_VISIBLE_DEVICES=0 python pose_estimation.py -d '/home/a524wangye/USA_gait/video/val' -t 'val' -n 3

CUDA_VISIBLE_DEVICES=0 python pose_estimation.py -d '/home/a524wangye/USA_gait/video/test' -t 'test' -n 3

then it will generate pose-data of val-set and train-set and save as tfrecords. you must set the second parameter,when you want to process the train data in order to get the pose-vector, the second parameter should be set 'train'.in a similar way

valset - 'val' ; testset - 'test' After above, it will save the pose data as tfrecords file which are located in './TFdata/'

To prevent errors, delete data of 'image/frames_data/' and './TFdata/' before running pose_estimation.py

  1. run python run_gait.py -h to train and validate data. such as :

     usage: run_gait.py [-h] [-n NUM_CLASSES] [-t TRAIN_STEPS] [-e EPOCH]
                [-b BATCH] [-tr TRAIN_SET] [-va VAL_SET] [-c CHECKPOINT]
                [-l LEARN_RATE] [-nt NUM_TRAINSET] [-nv NUM_VALSET]
    
     provide data to train and val
    
     optional arguments:
     -h, --help            show this help message and exit
     -n NUM_CLASSES, --num_classes NUM_CLASSES
                             number of classes
     -t TRAIN_STEPS, --train_steps TRAIN_STEPS
                             number of iterations per epoch
     -e EPOCH, --epoch EPOCH 
                             number of epoches
     -b BATCH, --batch BATCH
                             number of batch
     -tr TRAIN_SET, --train_set TRAIN_SET
                             path of train tfrecords
     -va VAL_SET, --val_set VAL_SET
                             path of val tfrecords
     -c CHECKPOINT, --checkpoint CHECKPOINT
                             path of saving model
     -l LEARN_RATE, --learn_rate LEARN_RATE
                             learn_rate
     -nt NUM_TRAINSET, --num_trainset NUM_TRAINSET
                             number of train samples ,used to shuffle
     -nv NUM_VALSET, --num_valset NUM_VALSET
                             number of val samples ,used to shuffle
    

the correct example:

CUDA_VISIBLE_DEVICES=0 python run_gait.py -n 3 -t 50 -e 10 -b 3 -tr '/home/a524wangye/USA_gait/TFdata/train.tfrecords' -va '/home/a524wangye/USA_gait/TFdata/val.tfrecords' -c '/home/a524wangye/USA_gait/Our_model/' -l 0.001 -nv 3

After 2, our model will be saved in './Our_model'.

  1. After 1 and 2 , we can use the model to test our data.
    run python test_model.py -h

     usage: test_model.py [-h] [-m MODEL_FILE] [-t TEST_TFRECORDS] [-n NUM_TEST]
    
     test model to get acc and loss
    
     optional arguments:
     -h, --help            show this help message and exit
     -m MODEL_FILE, --model_file MODEL_FILE
                             model path
     -t TEST_TFRECORDS, --test_tfrecords TEST_TFRECORDS
                             test data path
     -n NUM_TEST, --num_test NUM_TEST
                             number of test samples
    

the correct example
CUDA_VISIBLE_DEVICES=0 python test_model.py -m '/home/a524wangye/USA_gait/Our_model/' -t '/home/a524wangye/USA_gait/TFdata/test.tfrecords' -n 3

Data Format

  1. raw video data:

    • the name of video is set to 'label_number.mp4'
      • 'label' is label of this video,'' is used to separate,'number' is the sequence number of the video,such as
        1_0.mp4,1_1.mp4,2_1.mp4 and so on. The program will split by '
        ' to get the label of the video.
    • folder format
      • Set up three folders(train,test,val) to store different data
  2. frames data

    • The program is automatically generated without human intervention
    • Store the frame data corresponding to the above video
  3. tfrecords data

    • pose_estimation.py will convert the frames data into pose-vector and store them as tfrecords file.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages