Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
data/DanceDB-bvhs/
data/DanceDB/
pre-trained/
scripts/*.out
scripts/*.err

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -107,4 +113,4 @@ venv.bak/
.DS_Store
.vscode/
.idea/
.nosync
.nosync
7 changes: 4 additions & 3 deletions bvh/bvh_parser.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from typing import Optional
import torch
import bvh.bvh_io as bvh_io
import numpy as np
Expand Down Expand Up @@ -93,8 +94,8 @@ def ee_id(self):


class BVH_file:
def __init__(self, file_path, no_scale=False, requires_contact=False, joint_reduction=True):
self.anim = bvh_io.load(file_path)
def __init__(self, file_path, no_scale=False, no_blender_scale=True, requires_contact=False, joint_reduction=True, start: Optional[int] = None, end: Optional[int] = None):
self.anim = bvh_io.load(file_path, start=start, end=end)
self._names = self.anim.names
self.frametime = self.anim.frametime
self.skeleton = Skeleton(self.anim.names, self.anim.parent, self.anim.offsets, joint_reduction)
Expand All @@ -110,7 +111,7 @@ def __init__(self, file_path, no_scale=False, requires_contact=False, joint_redu
self.anim.rotations = self.anim.rotations[::2]

# Scale by 1/100 if it's raw exported bvh from blender
if not no_scale and self.skeleton.offsets[0, 1] > 10:
if not no_scale and not no_blender_scale and self.skeleton.offsets[0, 1] > 10:
self.scale(1. / 100)
# Scale by 0.14 for Xia's dataset
if not no_scale and self.skeleton.skeleton_type == 3:
Expand Down
11 changes: 7 additions & 4 deletions bvh/skeleton_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
elephant_corps_name = ['Hips', 'Bip01_Pelvis', 'BN_Tail_01', 'BN_Tail_02', 'BN_Tail_03', 'BN_Tail_04', 'Bip01_Spine', 'Bip01_R_Thigh', 'Bip01_R_Calf', 'Bip01_R_Foot', 'Bip01_R_Toe0', 'Bip01_L_Thigh', 'Bip01_L_Calf', 'Bip01_L_Foot', 'Bip01_L_Toe0', 'Bip01_Spine1', 'Bip01_Spine2', 'Bip01_Neck', 'Bip01_Head', 'BN_Eyebrow_L', 'BN_Eyebrow_R', 'BN_Ear_L_01', 'BN_Ear_L_02', 'BN_Mouth_01', 'BN_Ear_R_01', 'BN_Ear_R_02', 'BN_Nose_01', 'BN_Nose_02', 'BN_Nose_03', 'BN_Nose_04', 'BN_Nose_05', 'BN_Nose_06', 'Bip01_R_Clavicle', 'Bip01_R_UpperArm', 'Bip01_R_Forearm', 'Bip01_R_Hand', 'Bip01_L_Clavicle', 'Bip01_L_UpperArm', 'Bip01_L_Forearm', 'Bip01_L_Hand']
crab_dance_corps_name = ['ORG_Hips', 'ORG_BN_Bip01_Pelvis', 'DEF_BN_Eye_L_01', 'DEF_BN_Eye_L_02', 'DEF_BN_Eye_L_03', 'DEF_BN_Eye_L_03_end', 'DEF_BN_Eye_R_01', 'DEF_BN_Eye_R_02', 'DEF_BN_Eye_R_03', 'DEF_BN_Eye_R_03_end', 'DEF_BN_Leg_L_11', 'DEF_BN_Leg_L_12', 'DEF_BN_Leg_L_13', 'DEF_BN_Leg_L_14', 'DEF_BN_Leg_L_15', 'DEF_BN_Leg_L_15_end', 'DEF_BN_Leg_R_11', 'DEF_BN_Leg_R_12', 'DEF_BN_Leg_R_13', 'DEF_BN_Leg_R_14', 'DEF_BN_Leg_R_15', 'DEF_BN_Leg_R_15_end', 'DEF_BN_leg_L_01', 'DEF_BN_leg_L_02', 'DEF_BN_leg_L_03', 'DEF_BN_leg_L_04', 'DEF_BN_leg_L_05', 'DEF_BN_leg_L_05_end', 'DEF_BN_leg_L_06', 'DEF_BN_Leg_L_07', 'DEF_BN_Leg_L_08', 'DEF_BN_Leg_L_09', 'DEF_BN_Leg_L_10', 'DEF_BN_Leg_L_10_end', 'DEF_BN_leg_R_01', 'DEF_BN_leg_R_02', 'DEF_BN_leg_R_03', 'DEF_BN_leg_R_04', 'DEF_BN_leg_R_05', 'DEF_BN_leg_R_05_end', 'DEF_BN_leg_R_06', 'DEF_BN_Leg_R_07', 'DEF_BN_Leg_R_08', 'DEF_BN_Leg_R_09', 'DEF_BN_Leg_R_10', 'DEF_BN_Leg_R_10_end', 'DEF_BN_Bip01_Pelvis', 'DEF_BN_Bip01_Pelvis_end', 'DEF_BN_Arm_L_01', 'DEF_BN_Arm_L_02', 'DEF_BN_Arm_L_03', 'DEF_BN_Arm_L_03_end', 'DEF_BN_Arm_R_01', 'DEF_BN_Arm_R_02', 'DEF_BN_Arm_R_03', 'DEF_BN_Arm_R_03_end']
xia_corps_name = ['Hips', 'LHipJoint', 'LeftUpLeg', 'LeftLeg', 'LeftFoot', 'LeftToeBase', 'RHipJoint', 'RightUpLeg', 'RightLeg', 'RightFoot', 'RightToeBase', 'LowerBack', 'Spine', 'Spine1', 'Neck', 'Neck1', 'Head', 'LeftShoulder', 'LeftArm', 'LeftForeArm', 'LeftHand', 'LeftFingerBase', 'LeftHandIndex1', 'LThumb', 'RightShoulder', 'RightArm', 'RightForeArm', 'RightHand', 'RightFingerBase', 'RightHandIndex1', 'RThumb']
dancedb_corps_name = ['Hips', 'LHipJoint', 'LeftUpLeg', 'LeftLeg', 'LeftFoot', 'LeftToeBase', 'RHipJoint', 'RightUpLeg', 'RightLeg', 'RightFoot', 'RightToeBase', 'LowerBack', 'Spine', 'Spine1', 'Neck', 'Neck1', 'Head', 'LeftShoulder', 'LeftArm', 'LeftForeArm', 'LeftHand', 'LeftFingerBase', 'LeftHandIndex1', 'LThumb', 'RightShoulder', 'RightArm', 'RightForeArm', 'RightHand', 'RightFingerBase', 'RightHandIndex1', 'RThumb']
dancedb_contacts = ['LeftFoot', 'LeftToeBase', 'RightFoot', 'RightToeBase']


mixamo_contact_name = ['LeftToe_End', 'RightToe_End', 'LeftToeBase', 'RightToeBase']
Expand All @@ -11,10 +13,10 @@


class SkeletonDatabase:
names = ['Mixamo', 'Elephant', 'Crab_dance', 'Xia']
corps_names = [mixamo_corps_name, elephant_corps_name, crab_dance_corps_name, xia_corps_name]
contact_names = [mixamo_contact_name, elephant_contact_name, crab_dance_contact_name, xia_contact_name]
contact_thresholds = [0.018, 0.018, 0.006, 0.018]
names = ['Mixamo', 'Elephant', 'Crab_dance', 'Xia', 'DanceDB']
corps_names = [mixamo_corps_name, elephant_corps_name, crab_dance_corps_name, xia_corps_name, dancedb_corps_name]
contact_names = [mixamo_contact_name, elephant_contact_name, crab_dance_contact_name, xia_contact_name, dancedb_contacts]
contact_thresholds = [0.018, 0.018, 0.006, 0.018, 0.018]

@classmethod
def match(cls, joint_names):
Expand All @@ -28,3 +30,4 @@ def match(cls, joint_names):
max_match = max(n_match)
max_match_id = n_match.index(max_match)
return max_match_id, max_match

9 changes: 7 additions & 2 deletions dataset/motion.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from os.path import join as pjoin
from typing import Optional
import numpy as np
import torch
import torch.nn.functional as F
Expand All @@ -11,9 +12,13 @@
class MotionData:
def __init__(self, filename, repr='quat', padding=False,
use_velo=False, no_scale=False, contact=False, keep_y_pos=False,
joint_reduction=True):
no_blender_scale=True,
joint_reduction=True,
start: Optional[int] = None, end: Optional[int] = None):
self.bvh_file = BVH_file(filename, no_scale, requires_contact=contact,
joint_reduction=joint_reduction)
no_blender_scale=no_blender_scale,
joint_reduction=joint_reduction,
start=start, end=end)
self.contact = contact
self.filename = filename
self.raw_motion = self.bvh_file.to_tensor(repr=repr)
Expand Down
2 changes: 1 addition & 1 deletion demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def main():
conds_rec = None

print('levels:', lengths)
save_path = pjoin(args.save_path, 'bvh')
save_path = pjoin(args.save_path, test_args.bvh_dir)
os.makedirs(save_path, exist_ok=True)

base_id = 0
Expand Down
3 changes: 3 additions & 0 deletions option.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def __init__(self):
self.parser.add_argument('--full_zstar', type=int, default=1)
self.parser.add_argument('--correct_zstar_gen', type=int, default=0)
self.parser.add_argument('--use_6d_fk', type=int, default=0)
self.parser.add_argument('--start', type=int, default=None)
self.parser.add_argument('--end', type=int, default=None)

@staticmethod
def checker(args):
Expand All @@ -116,3 +118,4 @@ def __init__(self):
self.parser.add_argument('--keyframe_editing', type=str, default='')
self.parser.add_argument('--conditional_generation', type=str, default='')
self.parser.add_argument('--interactive', type=int, default=0)
self.parser.add_argument('--bvh_dir', type=str, default="bvh")
5 changes: 5 additions & 0 deletions slurm-scripts/experiments.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BVH_PREFIX,BVH_NAME,SAVE_PATH,START,END
./data/DanceDB-bvhs/greek-and-cypriot-dances/,ANDREAS_Poustsenko,res-andreas-poustsenko,10000,13000
./data/DanceDB-bvhs/greek-and-cypriot-dances/,Clio_Podaraki,res-clio-podaraki,2500,5000
./data/DanceDB-bvhs/greek-and-cypriot-dances/,Stefanos_Theodorou_1os_Antikristos_Katrsilamas_v1,res-stefanos-theodorou-1os-antikristos-katrsilamas,3000,5500

26 changes: 26 additions & 0 deletions slurm-scripts/generate_samples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
#SBATCH --nodes=1
#SBATCH --gres=gpu:1
#SBATCH --time=24:00:00
#SBATCH --mem=16GB
#SBATCH --ntasks-per-node=8
#SBATCH --output="scripts/job.train.%j.out"
#SBATCH --error="scripts/job.train.%j.err"
#SBATCH --job-name=ganimdemo

# # # # # # # # # # # # # # # # # # # # # #
# GPU jupyter notebook setup on CYENS HPC #
# # # # # # # # # # # # # # # # # # # # # #

PROJECT_CONDA_ENV="ganimator"
PROJECT_DIRECTORY="/lustreFS/data/veupnea/cchadjiminas/projects/ganimator"

## Setup environment
source ~/.bashrc

echo "WHICH PYTHON: $(which python)"
cd "$PROJECT_DIRECTORY"

echo python demo.py --save_path="${SAVE_PATH}" --target_length="${TARGET_LENGTH}" --bvh_dir="${BVH_DIR}" --device="cuda"
python demo.py --save_path="${SAVE_PATH}" --target_length="${TARGET_LENGTH}" --bvh_dir="${BVH_DIR}" --device="cuda"

43 changes: 43 additions & 0 deletions slurm-scripts/jupyter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash -l
#SBATCH --nodes=1
#SBATCH --gres=gpu:1
#SBATCH --time=24:00:00
#SBATCH --mem=32GB
#SBATCH --ntasks-per-node=8
#SBATCH --output="scripts/job.%j.out"
#SBATCH --error="scripts/job.%j.err"
#SBATCH --job-name=smdmjp

# # # # # # # # # # # # # # # # # # # # # #
# GPU jupyter notebook setup on CYENS HPC #
# # # # # # # # # # # # # # # # # # # # # #

PROJECT_CONDA_ENV="ganimator"
PROJECT_DIRECTORY="/lustreFS/data/veupnea/cchadjiminas/projects/ganimator"

## Setup environment
source ~/.bashrc
conda deactivate
conda deactivate
conda activate "$PROJECT_CONDA_ENV"

# get tunneling info
export XDG_RUNTIME_DIR="" node=$(hostname -s)
user="$(whoami)"
submit_host="${SLURM_SUBMIT_HOST}"
port=10501
echo $node pinned to port $port
# print tunneling instructions

echo -e "
To connect to the compute node ${node} on CYENS HPC running your jupyter notebook server, you need to run following two commands in a terminal 1.
Command to create ssh tunnel from you workstation/laptop to controller1:

ssh -L ${port}:${node}:${port} ${user}@82.116.197.12

Copy the link provided below by jupyter-server and replace the NODENAME with localhost before pasting it in your browser on your workstation/laptop "

# Run Jupyter
cd "$PROJECT_DIRECTORY"
jupyter lab --no-browser --port=${port} --port-retries=50 --ip=${node}

38 changes: 38 additions & 0 deletions slurm-scripts/run_experiments.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

# Check if the correct number of arguments is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <experiments.csv>"
exit 1
fi

# Assign the first argument to the input variable
input="$1"

# Check if the file exists
if [ ! -f "$input" ]; then
echo "File not found: $input"
exit 1
fi


# Skip the header and iterate over each line
tail -n +2 "$input" | while IFS=',' read -r BVH_PREFIX BVH_NAME SAVE_PATH START END
do
# Skip empty lines
if [ -z "$BVH_PREFIX" ] || [ -z "$BVH_NAME" ] || [ -z "$SAVE_PATH" ] || [ -z "$START" ] || [ -z "$END" ]; then
continue
fi

# Export variables
export BVH_PREFIX="$BVH_PREFIX"
export BVH_NAME="$BVH_NAME"
export SAVE_PATH="$SAVE_PATH"
export START="$START"
export END="$END"

echo $BVH_PREFIX $BVH_NAME $SAVE_PATH $START $END
# Execute the sbatch command
echo $(sbatch scripts/train.sh)
done

36 changes: 36 additions & 0 deletions slurm-scripts/run_generate_samples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# Check if the correct number of arguments is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <samples.csv>"
exit 1
fi

# Assign the first argument to the input variable
input="$1"

# Check if the file exists
if [ ! -f "$input" ]; then
echo "File not found: $input"
exit 1
fi


# Skip the header and iterate over each line
tail -n +2 "$input" | while IFS=',' read -r SAVE_PATH TARGET_LENGTH BVH_DIR
do
# Skip empty lines
if [ -z "$SAVE_PATH" ] || [ -z "$TARGET_LENGTH" ] || [ -z "$BVH_DIR" ]; then
continue
fi

# Export variables
export SAVE_PATH="$SAVE_PATH"
export TARGET_LENGTH="$TARGET_LENGTH"
export BVH_DIR="$BVH_DIR"

echo $SAVE_PATH $TARGET_LENGTH $BVH_DIR
# Execute the sbatch command
echo $(sbatch scripts/generate_samples.sh)
done

18 changes: 18 additions & 0 deletions slurm-scripts/samples.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
SAVE_PATH,TARGET_LENGTH,BVH_DIR
240703-1135-res-andreas-poustsenko,600,bvh_600
240703-1135-res-andreas-poustsenko,1200,bvh_1200
240703-1135-res-andreas-poustsenko,2400,bvh_2400
240703-1135-res-andreas-poustsenko,4800,bvh_4800
240703-1135-res-stefanos-theodorou-1os-antikristos-katrsilamas,600,bvh_600
240703-1135-res-stefanos-theodorou-1os-antikristos-katrsilamas,1200,bvh_1200
240703-1135-res-stefanos-theodorou-1os-antikristos-katrsilamas,2400,bvh_2400
240703-1135-res-stefanos-theodorou-1os-antikristos-katrsilamas,4800,bvh_4800
240703-1145-res-clio-podaraki,600,bvh_600
240703-1145-res-clio-podaraki,1200,bvh_1200
240703-1145-res-clio-podaraki,2400,bvh_2400
240703-1145-res-clio-podaraki,4800,bvh_4800
240702-1446-results-clio-rasopoulos,600,bvh_600
240702-1446-results-clio-rasopoulos,1200,bvh_1200
240702-1446-results-clio-rasopoulos,2400,bvh_2400
240702-1446-results-clio-rasopoulos,4800,bvh_4800

54 changes: 54 additions & 0 deletions slurm-scripts/tensorboard.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash -l
#SBATCH --nodes=1
#SBATCH --time=24:00:00
#SBATCH --mem=32GB
#SBATCH --ntasks-per-node=2
#SBATCH --output="scripts/job.%j.out"
#SBATCH --error="scripts/job.%j.err"
#SBATCH --job-name=ganimtb

# # # # # # # INPUTS # # # # # # # # # #
LOG_DIR="${LOG_DIR:-"results-clio-rasopoulos-3/logs/"}"


PORT="${PORT:-$(availport)}"
PROJECT_CONDA_ENV="${PROJECT_CONDA_ENV:-"ganimator"}"
PROJECT_DIRECTORY="${PROJECT_DIRECTORY:-"/lustreFS/data/veupnea/cchadjiminas/projects/ganimator"}"
# # # # # # # # # # # # # # # # # # # #

cat << EOF
LOG_DIR "${LOG_DIR}"

PROJECT_DIRECTORY "${PROJECT_DIRECTORY}"
PROJECT_CONDA_ENV "${PROJECT_CONDA_ENV}"
PORT "${PORT}"
EOF

## Setup environment
source ~/.bashrc
conda deactivate
conda deactivate
conda activate "$PROJECT_CONDA_ENV"

# get tunneling info
export XDG_RUNTIME_DIR="" node=$(hostname -s)
user="$(whoami)"
submit_host="${SLURM_SUBMIT_HOST}"
echo $node pinned to PORT $PORT
# print tunneling instructions

echo -e "
To connect to the compute node ${node} on CYENS HPC running your jupyter notebook server, you need to run following two commands in a terminal 1.
Command to create ssh tunnel from you workstation/laptop to controller1:

ssh -L ${PORT}:${node}:${PORT} ${user}@82.116.197.12

Copy the link provided below in your local browser"

echo "http://localhost:${PORT}/#scalars"


# Run Tensorboard
cd "$PROJECT_DIRECTORY"
tensorboard --port="${PORT}" --logdir "${LOG_DIR}" --host="${node}"

35 changes: 35 additions & 0 deletions slurm-scripts/train.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash -l
#SBATCH --nodes=1
#SBATCH --gres=gpu:1
#SBATCH --time=24:00:00
#SBATCH --mem=32GB
#SBATCH --ntasks-per-node=8
#SBATCH --output="scripts/job.train.%j.out"
#SBATCH --error="scripts/job.train.%j.err"
#SBATCH --job-name=ganim

# # # # # # # # # # # # # # # # # # # # # #
# GPU jupyter notebook setup on CYENS HPC #
# # # # # # # # # # # # # # # # # # # # # #

PROJECT_CONDA_ENV="ganimator"
PROJECT_DIRECTORY="/lustreFS/data/veupnea/cchadjiminas/projects/ganimator"

## Setup environment
source ~/.bashrc
source /lustreFS/data/veupnea/cchadjiminas/miniconda3/etc/profile.d/conda.sh
conda deactivate
conda deactivate
conda activate "$PROJECT_CONDA_ENV"

cd "$PROJECT_DIRECTORY"

START_OPT=${START:+--start=${START}}
END_OPT=${END:+--end=${END}}

BVH_PREFIX="${BVH_PREFIX:-"./data/DanceDB/"}"
SAVE_PATH="${SAVE_PATH:-"./results"}"

echo python train.py --device="cuda" --bvh_prefix="${BVH_PREFIX}" --bvh_name="${BVH_NAME}" --save_path="${SAVE_PATH}" "${START_OPT}" "${END_OPT}"
python train.py --device="cuda" --bvh_prefix="${BVH_PREFIX}" --bvh_name="${BVH_NAME}" --save_path="${SAVE_PATH}" "${START_OPT}" "${END_OPT}"

Loading