yahoo / spivak

Apache License 2.0
30 stars 3 forks source link

how to run pca and normalize for my own video? #11

Closed ldfandian closed 1 year ago

ldfandian commented 1 year ago

thanks for the great job~ @jvbsoares

I am trying to train the model with some additional own videos. After extracting resnet152 features from the low-quality videos, I need PCA and normalize those features, before kicking off the train.

which one should I use between make_pca_transform and make_pca_features? and, where is the pca_transform_ResNet_512_whiten_False.pkl? also, how to choose between resnet_max_abs and resnet_min_max ? I am assuming that I don't need run all of the 4 commands~ Please let me know if I mis-understand it.

and, do I still need to do "./bin/transform_features.py" if I just do resnet+pca (without using baidu features) for my own videos?

./bin/make_pca_transform.py \
  --features_dir $DATA_DIR \
  --features ResNet
./bin/make_pca_features.py \
  --features_dir $DATA_DIR \
  --pca "${DATA_DIR}/pca_transform_ResNet_512_whiten_False.pkl" \
  --features ResNet
./bin/create_normalizer.py \
  --features_dir ./data/features/resnet/ \
  --splits_dir ./data/splits/ \
  --normalizer max_abs \
  --features ResNET_TF2 \
  --out_path ~/challenge/normalizers/resnet_max_abs.pkl
./bin/create_normalizer.py \
  --features_dir ./data/features/resnet/ \
  --splits_dir ./data/splits/ \
  --normalizer min_max \
  --features ResNET_TF2 \
  --out_path ~/challenge/normalizers/resnet_min_max.pkl
ldfandian commented 1 year ago

can you please help?

jvbsoares commented 1 year ago

Thank you for your interest! If you would like to use the ResNet features with PCA according to the early SoccerNet works and the implementation in the SoccerNet Dev Kit, you can do that in two ways:

  1. You can use the code from the SoccerNet Dev Kit directly. See instructions at https://github.com/SilvioGiancola/SoccerNetv2-DevKit/tree/main/Features#extract-resnet-features-for-a-given-video
  2. You can alternatively use the script at ./bin/extract_features.py, which does the same as the code in the SoccerNet Dev Kit above. In order to run this feature extraction script, you'll need to download the relevant SoccerNet models, as suggested at: https://github.com/yahoo/spivak/blob/6f020f0f438029ecf921acfc74a0272519980e5e/Action-spotting-usage.md?plain=1#L303-L308 (Apologies for the work-in-progress documentation!) You will not need to run "./bin/transform_features.py". That code is meant for another use-case, in which the Baidu features need to be sampled at a higher frequency (frame rate), after which different kinds of features can be concatenated together (ResNet+PCA concatenated with the resampled Baidu features). Please let us know if that's not clear or if any questions.