-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from Grutschus/16-setup-a-videomaev2-model
16 setup a videomaev2 model
- Loading branch information
Showing
15 changed files
with
325 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
[core] | ||
remote = storage | ||
autostage = true | ||
hardlink_lock = true | ||
['remote "storage"'] | ||
url = s3://human-fall-detection/ | ||
endpointurl = https://s3.tebi.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from datasets.transforms.label_strategy import HQFD_LABEL_DESCRIPTION | ||
|
||
custom_imports = dict(imports="datasets", allow_failed_imports=False) | ||
type = "HighQualityFallDataset" | ||
sampling_strategy = dict(type="UniformSampling", clip_len=10) | ||
label_strategy = dict(type="ExistenceLabel", label_description=HQFD_LABEL_DESCRIPTION) | ||
ann_file = "tests/test_data/test_annotation.csv" | ||
pipeline = [ | ||
dict(type="DecordInit"), | ||
dict(type="ClipVideo"), | ||
dict(type="SampleFrames", clip_len=16, frame_interval=4, num_clips=1), | ||
dict(type="DecordDecode"), | ||
dict(type="Resize", scale=(-1, 224)), | ||
dict(type="RandomResizedCrop"), | ||
dict(type="Resize", scale=(224, 224), keep_ratio=False), | ||
dict(type="Flip", flip_ratio=0.5), | ||
dict(type="FormatShape", input_format="NCTHW"), | ||
dict(type="PackActionInputs"), | ||
] # type: ignore | ||
multiclass = True | ||
num_classes = 3 | ||
test_mode = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
_base_ = ["../../mmaction2/configs/_base_/default_runtime.py"] | ||
|
||
custom_imports = dict(imports="datasets", allow_failed_imports=False) | ||
work_dir = "work_dirs/videomaev2" | ||
launcher = "none" | ||
|
||
|
||
# model settings | ||
model = dict( | ||
type="Recognizer3D", | ||
backbone=dict( | ||
type="VisionTransformer", | ||
img_size=224, | ||
patch_size=16, | ||
embed_dims=384, | ||
depth=12, | ||
num_heads=6, | ||
mlp_ratio=4, | ||
qkv_bias=True, | ||
num_frames=16, | ||
norm_cfg=dict(type="LN", eps=1e-6), | ||
), | ||
cls_head=dict( | ||
type="TimeSformerHead", | ||
num_classes=3, | ||
in_channels=384, | ||
average_clips="prob", | ||
multi_class=True, | ||
), | ||
# TODO: update this to fit our dataset | ||
data_preprocessor=dict( | ||
type="ActionDataPreprocessor", | ||
mean=[123.675, 116.28, 103.53], | ||
std=[58.395, 57.12, 57.375], | ||
format_shape="NCTHW", | ||
), | ||
) | ||
|
||
# dataset settings | ||
dataset_type = "HighQualityFallDataset" | ||
ann_file_train = "tests/test_data/test_annotation.csv" | ||
|
||
train_pipeline = [ | ||
dict(type="DecordInit"), | ||
dict(type="ClipVideo"), | ||
dict(type="SampleFrames", clip_len=16, frame_interval=4, num_clips=1), | ||
dict(type="DecordDecode"), | ||
dict(type="Resize", scale=(-1, 224)), | ||
dict(type="RandomResizedCrop"), | ||
dict(type="Resize", scale=(224, 224), keep_ratio=False), | ||
dict(type="Flip", flip_ratio=0.5), | ||
dict(type="FormatShape", input_format="NCTHW"), | ||
dict(type="PackActionInputs"), | ||
] | ||
|
||
train_dataloader = dict( | ||
batch_size=1, | ||
num_workers=8, | ||
persistent_workers=False, | ||
sampler=dict(type="DefaultSampler", shuffle=False), | ||
dataset=dict( | ||
type=dataset_type, | ||
sampling_strategy=dict(type="UniformSampling", clip_len=10), | ||
label_strategy=dict( | ||
type="ExistenceLabel", | ||
label_description=dict( | ||
names=["fall", "lying", "other"], | ||
start_timestamp_names=["fall_start", "lying_start"], | ||
end_timestamp_names=["fall_end", "lying_end"], | ||
visible_names=["fall_visible", "lying_visible"], | ||
other_class=2, | ||
), | ||
), | ||
ann_file=ann_file_train, | ||
pipeline=train_pipeline, | ||
multi_class=True, | ||
num_classes=3, | ||
), | ||
) | ||
|
||
train_cfg = dict(type="EpochBasedTrainLoop", max_epochs=5, val_interval=0) | ||
|
||
param_scheduler = dict( | ||
type="MultiStepLR", # Decays the learning rate once the number of epoch reaches one of the milestones | ||
begin=0, # Step at which to start updating the learning rate | ||
end=100, # Step at which to stop updating the learning rate | ||
by_epoch=True, # Whether the scheduled learning rate is updated by epochs | ||
milestones=[40, 80], # Steps to decay the learning rate | ||
gamma=0.1, | ||
) | ||
|
||
optim_wrapper = dict( # Config of optimizer wrapper | ||
type="OptimWrapper", # Name of optimizer wrapper, switch to AmpOptimWrapper to enable mixed precision training | ||
optimizer=dict( # Config of optimizer. Support all kinds of optimizers in PyTorch. Refer to https://pytorch.org/docs/stable/optim.html#algorithms | ||
type="SGD", # Name of optimizer | ||
lr=0.01, # Learning rate | ||
momentum=0.9, # Momentum factor | ||
weight_decay=0.0001, | ||
), # Weight decay | ||
clip_grad=dict(max_norm=40, norm_type=2), | ||
) # Config of gradient clip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Bootstrap: localimage | ||
From: /apps/containers/PyTorch/PyTorch-2.1.0-NGC-23.09.sif | ||
|
||
|
||
%files | ||
containers/requirements.txt | ||
/mimer/NOBACKUP/groups/naiss2023-22-1160/human-fall-detection/mmaction2 | ||
|
||
%post | ||
export DEBIAN_FRONTEND="noninteractive" && apt-get update -y && apt-get install -y python3-opencv | ||
pip install -r containers/requirements.txt | ||
mim install mmengine mmcv mmdet mmpose | ||
cd /mimer/NOBACKUP/groups/naiss2023-22-1160/human-fall-detection/mmaction2 && pip install -v -e . | ||
# For some reason there is a wrong version of opencv installed | ||
pip uninstall -y opencv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# PyTorch is preinstalled in the image | ||
openpyxl>=3.0 | ||
openmim>=0.3 | ||
ffmpeg-python>=0.2 | ||
dvc[s3] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,4 @@ dependencies: | |
- jupyter>=1.0 | ||
- ipympl>=0.9 | ||
- pandas-stubs>=2.1 | ||
- ffmpeg-python>=0.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
# apptainer exec \ | ||
# --env PYTHONPATH=$(pwd) \ | ||
# --env CUDA_VISIBLE_DEVICES=2,3 \ | ||
# containers/c3se_job_container.sif \ | ||
# python -m torch.distributed.launch --nproc_per_node=2 \ | ||
# mmaction2/tools/train.py \ | ||
# configs/models/videomaev2.py \ | ||
# --launcher pytorch | ||
|
||
apptainer exec \ | ||
--env PYTHONPATH=$(pwd) \ | ||
--env CUDA_VISIBLE_DEVICES=2,3 \ | ||
containers/c3se_job_container.sif \ | ||
python mmaction2/tools/train.py \ | ||
configs/models/videomaev2.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from mmengine.registry import Registry | ||
|
||
|
||
SAMPLING_STRATEGIES = Registry( | ||
"sampling strategy", locations=["datasets.transforms.sampling_strategy"], scope="." | ||
) | ||
|
||
LABEL_STRATEGIES = Registry( | ||
"label strategy", locations=["datasets.transforms.label_strategy"], scope="." | ||
) |
Oops, something went wrong.