Skip to content

Commit

Permalink
Merge pull request #23 from PTG-Kitware/dev/feat_v6
Browse files Browse the repository at this point in the history
Refactor data generation
  • Loading branch information
hdefazio authored May 10, 2024
2 parents abb1622 + a982707 commit 33a8c92
Show file tree
Hide file tree
Showing 16 changed files with 957 additions and 715 deletions.
20 changes: 20 additions & 0 deletions PTG_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generate training data

```bash
$ python tcn_hpl/data/utils/ptg_datagenerator.py --config configs/experiment/r18/r18.yaml
```

* Update `paths.data_dir` in the config to point to the folder generated by this script

# Train
```bash
$ python tcn_hpl/train.py experiment=r18/feat_v6
```

## To view training metrics
Navigate to the ${paths.root_dir} directory set in your experiment config. Then run
```bash
$ aim up - p {port_num}
```

then go to ``http://127.0.0.1:{port_num}`` in your browser
6 changes: 6 additions & 0 deletions configs/data/all_transforms/ActivationDelta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ActivationDelta:
_target_: tcn_hpl.data.components.augmentations.ActivationDelta
conf_delta: 0.05
num_obj_classes: 42
feat_version: 2
top_k_objects: 1
3 changes: 2 additions & 1 deletion configs/data/all_transforms/MoveCenterPts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ MoveCenterPts:
_target_: tcn_hpl.data.components.augmentations.MoveCenterPts
hand_dist_delta: 0.05
obj_dist_delta: 0.05
window_size: ${data.window_size}
joint_dist_delta: 0.025
im_w: 1280
im_h: 720
num_obj_classes: 42
feat_version: 2
top_k_objects: 1
4 changes: 3 additions & 1 deletion configs/data/all_transforms/NormalizeFromCenter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ NormalizeFromCenter:
_target_: tcn_hpl.data.components.augmentations.NormalizeFromCenter
im_w: 1280
im_h: 720
feat_version: 3
num_obj_classes: 42
feat_version: 2
top_k_objects: 1
1 change: 1 addition & 0 deletions configs/data/all_transforms/NormalizePixelPts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ NormalizePixelPts:
im_h: 720
num_obj_classes: 42
feat_version: 2
top_k_objects: 1
1 change: 1 addition & 0 deletions configs/data/all_transforms/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ defaults:
- MoveCenterPts
- NormalizePixelPts
- NormalizeFromCenter
- ActivationDelta
- _self_

train_order: ['MoveCenterPts', 'NormalizePixelPts']
Expand Down
100 changes: 100 additions & 0 deletions configs/experiment/r18/feat_v5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# @package _global_

# to execute this experiment run:
# python train.py experiment=example
topic: "medical"
task: "r18"
feature_version: 5

defaults:
- override /data: ptg
- override /model: ptg
- override /callbacks: default
- override /trainer: gpu
- override /paths: default
- override /logger: aim

# all parameters below will be merged with parameters from default configurations set above

tags: ["r18", "ms_tcn"]

seed: 12345

trainer:
min_epochs: 50
max_epochs: 500


model:
compile: false

net:
dim: 33 # length of feature vector when top_k_objects=1
#dim: xx # length of feature vector when top_k_objects=2


# GENERATE TRAINING DATA
data_gen:
top_k_objects: 1

data_type: "pro"
dataset_kwcoco: "/data/PTG/medical/training/yolo_object_detector/detect/r18_all/r18_all_all_obj_results_with_dets_and_pose.mscoco.json"
train_vid_ids: [1, 2, 4, 5, 6, 8, 9, 11, 12, 14, 15, 16, 17, 19, 20, 21,
22, 23, 24, 26, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 40,
42, 43, 44, 45, 46, 48, 49, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
61, 62, 63, 64, 65, 66, 67, 68, 69, 70]
val_vid_ids: [3, 7, 10, 18, 27, 32, 41]
test_vid_ids: [50, 13, 47, 25]
names_black_gloves: []
names_blue_gloves: []
#data_type: "lab"
#dataset_kwcoco: "/data/PTG/medical/training/yolo_object_detector/detect/r18_all_bbn_lab_data/r18_all_bbn_lab_data_all_obj_results.mscoco.json"
#train_vid_ids: [1, 2, 3, 4, 5, 6, 7, 8]
#val_vid_ids: [9]
#test_vid_ids: [10]
#names_black_gloves: []
#names_blue_gloves: []

filter_black_gloves: false
filter_blue_gloves: false

activity_config_fn: "/home/local/KHQ/hannah.defazio/angel_system/config/activity_labels/medical/r18.yaml"

# This matches the folder name created in the data generator
exp_name: "${task}_${data_gen.data_type}_data_top_${data_gen.top_k_objects}_objs_feat_v${feature_version}"

# TRAINING
exp_name: ${data_gen.exp_name}_win_25

paths:
data_dir: "/data/PTG/medical/training/activity_classifier/TCN_data/${task}/${data_gen.exp_name}"
root_dir: "/data/PTG/medical/training/activity_classifier/TCN_HPL/"

data:
num_classes: 6 # activities: includes background
batch_size: 512
num_workers: 0
epoch_length: 20000
window_size: 45
sample_rate: 1

# AUGMENTATIONS
all_transforms:
train_order: [] #["MoveCenterPts", "NormalizePixelPts"]
test_order: [] #["NormalizePixelPts"]
MoveCenterPts:
feat_version: ${feature_version}
num_obj_classes: 6 # not including background
NormalizeFromCenter:
feat_version: ${feature_version}
NormalizePixelPts:
feat_version: ${feature_version}
num_obj_classes: 6 # not including background


logger:
aim:
experiment: ${exp_name}
capture_terminal_logs: true

task_name: ${exp_name}
107 changes: 53 additions & 54 deletions configs/experiment/r18/feat_v6.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

# to execute this experiment run:
# python train.py experiment=example
topic: "medical"
task: "r18"
feature_version: 6

defaults:
- override /data: ptg
- override /model: ptg
Expand All @@ -12,13 +15,6 @@ defaults:
- override /logger: aim

# all parameters below will be merged with parameters from default configurations set above
# this allows you to overwrite only specified parameters
# exp_name: "p_m2_tqt_data_test_feat_v6_with_pose" #[_v2_aug_False]
# exp_name: "p_r18_feat_v6_with_pose_v3_aug_False_reshuffle_True" #[_v2_aug_False]
exp_name: "p_r18_feat_v6_with_pose_v3_aug_False_reshuffle_True_bbn" #[_v2_aug_False]
# exp_name: "p_m2_tqt_data_test_feat_v6_with_pose_v2_aug_False_reshuffle_False" #[_v2_aug_False]
# exp_name: "p_m2_tqt_data_test_feat_v6_with_pose_v2_aug_True_reshuffle_True" #[_v2_aug_False]
# exp_name: "p_m2_tqt_data_test_feat_v6_with_pose_v2_aug_True_reshuffle_False" #[_v2_aug_False]

tags: ["r18", "ms_tcn"]

Expand All @@ -33,65 +29,68 @@ model:
compile: false

net:
dim: 209 # length of feature vector

data:
num_classes: 6 # activities: includes background
batch_size: 512
num_workers: 0
epoch_length: 20000
window_size: 45
sample_rate: 1


all_transforms:
train_order: [] #["MoveCenterPts", "NormalizePixelPts"]
test_order: [] #["NormalizePixelPts"]
MoveCenterPts:
feat_version: 6
num_obj_classes: 4 # not including background
NormalizeFromCenter:
feat_version: 6
NormalizePixelPts:
feat_version: 6
num_obj_classes: 4 # not including background
dim: 297 # length of feature vector when top_k_objects=1
#dim: 506 # length of feature vector when top_k_objects=2


# GENERATE TRAINING DATA
data_gen:
reshuffle_datasets: true
augment: false
num_augs: 5
feat_type: "with_pose" #[no_pose, with_pose, only_hands_joints, only_objects_joints]
filter_black_gloves: false
filter_blue_gloves: false
top_k_objects: 1

data_type: "pro"
dataset_kwcoco: "/data/PTG/medical/training/yolo_object_detector/detect/r18_all/r18_all_all_obj_results_with_dets_and_pose.mscoco.json"
train_vid_ids: [1, 2, 4, 5, 6, 8, 9, 11, 12, 14, 15, 16, 17, 19, 20, 21,
22, 23, 24, 26, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 40,
42, 43, 44, 45, 46, 48, 49, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
61, 62, 63, 64, 65, 66, 67, 68, 69, 70]
val_vid_ids: [3, 7, 10, 18, 27, 32, 41]
test_vid_ids: [50, 13, 47, 25]
names_black_gloves: []
names_blue_gloves: []
#data_type: "lab"
#dataset_kwcoco: "/data/PTG/medical/training/yolo_object_detector/detect/r18_all_bbn_lab_data/r18_all_bbn_lab_data_all_obj_results.mscoco.json"
#train_vid_ids: [1, 2, 3, 4, 5, 6, 7, 8]
#val_vid_ids: [9]
#test_vid_ids: [10]
#names_black_gloves: []
#names_blue_gloves: []

train_vid_ids_bbn: [1, 2, 3, 4, 5, 6, 7, 8]
val_vid_ids_bbn: [9]
test_vid_ids_bbn: [10]
filter_black_gloves: false
filter_blue_gloves: false

activity_config_fn: "/home/local/KHQ/hannah.defazio/angel_system/config/activity_labels/medical/r18.yaml"

# This matches the folder name created in the data generator
exp_name: "${task}_${data_gen.data_type}_data_top_${data_gen.top_k_objects}_objs_feat_v${feature_version}_NEW_ORDER"

# TRAINING
exp_name: ${data_gen.exp_name}_win_25_norm

paths:
# data_dir: "/data/PTG/TCN_data/r18/p_r18_feat_v6_with_pose_v3_aug_False_reshuffle_True" #[_v2_aug_False]
data_dir: "/data/PTG/TCN_data/r18/p_r18_feat_v6_with_pose_v3_aug_False_reshuffle_True_bbn" #[_v2_aug_False]
# data_dir: "/data/PTG/TCN_data/m2/p_m2_tqt_data_test_feat_v6_with_pose_v2_aug_False_reshuffle_False" #[_v2_aug_False]
# data_dir: "/data/PTG/TCN_data/m2/p_m2_tqt_data_test_feat_v6_with_pose_v2_aug_True_reshuffle_True" #[_v2_aug_False]
# data_dir: "/data/PTG/TCN_data/m2/p_m2_tqt_data_test_feat_v6_with_pose_v2_aug_True_reshuffle_False" #[_v2_aug_False]
# root_dir: "/data/PTG/medical/training/activity_classifier/TCN_HPL"
root_dir: "/data/users/peri.akiva/PTG/medical/training/activity_classifier/TCN_HPL"
dataset_kwcoco: "/data/users/peri.akiva/datasets/ptg/r18_all_all_obj_results_with_dets_and_pose.mscoco.json"
dataset_kwcoco_lab: "/data/users/peri.akiva/datasets/ptg/r18_all_bbn_lab_data_all_obj_results_with_dets_and_pose.mscoco.json"
activity_config_root: "/home/local/KHQ/peri.akiva/projects/angel_system/config/activity_labels"
activity_config_fn: "${paths.activity_config_root}/${task}"
ptg_root: "/home/local/KHQ/peri.akiva/angel_system"
activity_config_path: "${paths.ptg_root}/config/activity_labels/medical"
output_data_dir_root: "/data/PTG/TCN_data"
# bbn_data_root: "{bbn_data_dir}/Release_v0.5/v0.56"
bbn_data_dir: "/data/PTG/medical/bbn_data"
data_dir: "/data/PTG/medical/training/activity_classifier/TCN_data/${task}/${data_gen.exp_name}"
root_dir: "/data/PTG/medical/training/activity_classifier/TCN_HPL/"

data:
num_classes: 6 # activities: includes background
batch_size: 512
num_workers: 0
epoch_length: 20000
window_size: 25
sample_rate: 1

# AUGMENTATIONS
all_transforms:
train_order: ["MoveCenterPts", "NormalizePixelPts"]
test_order: ["NormalizePixelPts"]
MoveCenterPts:
feat_version: ${feature_version}
num_obj_classes: 6 # not including background, includes hands
NormalizeFromCenter:
feat_version: ${feature_version}
NormalizePixelPts:
feat_version: ${feature_version}
num_obj_classes: 6 # not including background, includes hands
top_k_objects: ${data_gen.top_k_objects}

logger:
aim:
Expand Down
1 change: 1 addition & 0 deletions configs/model/ptg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ criterion:
# weight: [1, 1, 1, 1, 1, 1]
reduction: "mean"

topic: ${topic}
data_dir: ${paths.data_dir}

# Smoothing loss weight
Expand Down
14 changes: 7 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# --------- pytorch --------- #
# torch>=2.0.0
# torchvision>=0.15.0
# lightning>=2.0.0
# torchmetrics>=0.11.4
torch>=2.0.0
torchvision>=0.15.0
lightning>=2.0.0
torchmetrics>=0.11.4

# --------- hydra --------- #
# hydra-core==1.3.2
# hydra-colorlog==1.2.0
# hydra-optuna-sweeper==1.2.0
hydra-core==1.3.2
hydra-colorlog==1.2.0
hydra-optuna-sweeper==1.2.0

# --------- loggers --------- #
# wandb
Expand Down
Loading

0 comments on commit 33a8c92

Please sign in to comment.