Skip to content

Commit

Permalink
almost done with custom
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffheo committed Jun 10, 2023
1 parent 08cb9be commit 07c8d00
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 186 deletions.
8 changes: 6 additions & 2 deletions custom_video/VIBE_custom/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,14 @@ def main(args):
if not os.path.isfile(video_file):
exit(f'Input video \"{video_file}\" does not exist!')

output_path = os.path.join(args.output_folder, os.path.basename(video_file).replace('.mp4', ''))
output_path = os.path.join(args.output_folder, os.path.basename(video_file).replace('.mp4', '.vibe'))
#print (output_path)
print(f'Output folder: {output_path}')

os.makedirs(output_path, exist_ok=True)

image_folder, num_frames, img_shape = video_to_images(video_file, return_info=True)
print('Images are extracted at {}!'.format(image_folder))

print(f'Input video number of frames {num_frames}')
orig_height, orig_width = img_shape[:2]
Expand Down Expand Up @@ -386,7 +390,7 @@ def main(args):
parser.add_argument('--run_smplify', action='store_true',
help='run smplify for refining the results, you need pose tracking to enable it')

parser.add_argument('--no_render', action='store_true',
parser.add_argument('--no_render', type=bool, default=True,
help='disable final rendering of output video.')

parser.add_argument('--wireframe', action='store_true',
Expand Down
1 change: 1 addition & 0 deletions custom_video/VIBE_custom/lib/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
POSETRACK_DIR = 'data/posetrack'
VIBE_DATA_DIR = 'data/vibe_data'


# Configuration variables
cfg = CN()

Expand Down
1 change: 1 addition & 0 deletions custom_video/VIBE_custom/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ llvmlite==0.32.1
git+https://github.com/mattloper/chumpy.git
git+https://github.com/mkocabas/yolov3-pytorch.git
git+https://github.com/mkocabas/multi-person-tracker.git
pyglet==1.5.21
2 changes: 1 addition & 1 deletion custom_video/VIBE_custom/scripts/install_conda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ which pip

pip install numpy==1.17.5 torch==1.4.0 torchvision==0.5.0
pip install git+https://github.com/giacaglia/pytube.git --upgrade
pip install -r requirements.txt
pip install -r ./VIBE_custom/requirements.txt
75 changes: 48 additions & 27 deletions custom_video/demo.sh
Original file line number Diff line number Diff line change
@@ -1,39 +1,60 @@
#!/bin/bash
# Name of the yml file without the extension
vibe_name="vibe_environment"
set -e # Exit on any error
export PATH="$PATH:."


# Create the environment from the yml file
conda env create -f ${vibe_name}.yml
# Activate the environment
conda init bash
conda activate $vibe_name
source ./VIBE_custom/scripts/install_conda.sh


video_names=$(yq e '.videos.names[]' ./nemo-config.yml)
# Obtain video names from nemo-config.yml
video_names=($(awk '/names:/{flag=1;next}/]/{flag=0}flag' ./nemo-config.yml | grep -o '"[^"]*"' | sed 's/"//g'))
# # Print the video names one per line
#printf '%s\n' "${video_names[@]}"

# change write permissions for the data folder so that the docker container can write to it
chmod 777 ./data
# # Change write permissions for the data folder so that the docker container can write to it
script_dir=$(cd "$(dirname "$0")" && pwd)
data_dir="${script_dir}/data"
chmod -R 777 "$data_dir"

# iterate over video names
for name in $video_names; do
python ./VIBE_custom/demo.py --vid_file ./data/videos/${name}.mp4 --output_folder ./data/exps/${name}.vibe/ --display
cd ./VIBE_custom
# Iterate over video names
for name in "${video_names[@]}"; do
python ./demo.py --vid_file "../${data_dir}/videos/${name}.mp4" --output_folder "../${data_dir}/exps/"
done

cd ..

# Deactivate the environment
eval "$(conda shell.bash hook)"

conda deactivate
# create conda environment through custom_env.yml
env_name="custom_env"
conda env create -f ${env_name}.yml

# Create conda environment through custom_env.yml
env_name="nemo-env"
conda env create -f "${env_name}.yml"

eval "$(conda shell.bash hook)"
# Activate the environment
conda activate $env_name
#iterate over video names
#get the number of videos
num_videos=$(yq e '.videos.names | length' ./nemo-config.yml)
count=$((num_videos))
for name in $video_names; do
#get the name of the video before the . in the name
video_name=$(echo $name | cut -d'.' -f 1)
python ./video_to_frames_custom.py --action $video_name --num_videos $count --display
docker run --gpus 5 --rm -v /pasteur/u/jeffheo/projects/nemo-cvpr2023-jeff/custom_video/data/exps:/mnt cwaffles/openpose ./build/examples/openpose/openpose.bin --image_dir /mnt/${name}.frames --write_json /mnt/${name}.op --display 0 --model_pose BODY_25 --number_people_max 1 --render_pose 0
done
conda activate "$env_name"

pip install --force-reinstall pyopengl==3.1.5

# Get the number of videos
num_elements=${#video_names[@]}
count="$num_elements"
video_name_with_extension=${video_names[0]}

# Remove the extension and the number
video_name="${video_name_with_extension%%.*}"
#echo "$video_name"
#echo "$count"

python ./video_to_frames_custom.py --action "$video_name" --num_videos "$count"
# Iterate over video names
for name in "${video_names[@]}"; do
docker run --gpus 1 --rm -v "${data_dir}/exps:/mnt" cwaffles/openpose ./build/examples/openpose/openpose.bin --image_dir /mnt/"${name%.mp4}.frames" --write_json /mnt/"${name%.mp4}.op" --display 0 --model_pose BODY_25 --number_people_max 1 --render_pose 0
done
cd ..
# Now run the NeMo script
bash ./nemo-run.sh 0
bash custom_video/nemo-run.sh 0
6 changes: 4 additions & 2 deletions custom_video/nemo-config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
exp_dir: "/pasteur/u/jeffheo/projects/nemo-cvpr2023-jeff/custom_video/data/exps/"
exp_dir: "./custom_video/data/exps/"
format: "release"
videos:
root_dir: "/pasteur/u/jeffheo/projects/nemo-cvpr2023-jeff/custom_video/data/videos/"
root_dir: "./custom_video/data/videos/"
names:
[
"tennis_swing.0",
Expand All @@ -11,3 +11,5 @@ videos:
"tennis_swing.4",
"tennis_swing.5",
]


68 changes: 47 additions & 21 deletions custom_video/custom_env.yml → custom_video/nemo-env.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: nemo_custom
name: nemo-env
channels:
- pytorch
- nvidia
- anaconda
- conda-forge
- defaults
dependencies:
Expand All @@ -21,14 +22,12 @@ dependencies:
- cuda-nvrtc=11.7.99=0
- cuda-nvtx=11.7.91=0
- cuda-runtime=11.7.1=0
- ffmpeg=4.2.2=h20bf706_0
- ffmpeg=4.3=hf484d3e_0
- freetype=2.12.1=h4a9f257_0
- future=0.18.2=py37h89c1867_5
- giflib=5.2.1=h5eee18b_3
- gmp=6.2.1=h295c915_3
- gnutls=3.6.15=he1e5248_0
- h5py=3.7.0=py37h737f45e_0
- hdf5=1.10.6=h3ffc7dd_1
- idna=3.4=py37h06a4308_0
- intel-openmp=2021.4.0=h06a4308_3561
- jpeg=9e=h5eee18b_1
Expand All @@ -45,37 +44,30 @@ dependencies:
- libdeflate=1.17=h5eee18b_0
- libffi=3.4.2=h6a678d5_6
- libgcc-ng=12.2.0=h65d4601_19
- libgfortran-ng=11.2.0=h00389a5_1
- libgfortran5=11.2.0=h1234567_1
- libiconv=1.16=h7f8727e_2
- libidn2=2.3.2=h7f8727e_0
- libllvm11=11.1.0=h9e868ea_6
- libnpp=11.7.4.75=0
- libnvjpeg=11.8.0.2=0
- libopus=1.3.1=h7b6447c_0
- libpng=1.6.39=h5eee18b_0
- libstdcxx-ng=11.2.0=h1234567_1
- libtasn1=4.16.0=h27cfd23_0
- libtiff=4.5.0=h6a678d5_2
- libunistring=0.9.10=h27cfd23_0
- libuuid=2.38.1=h0b41bf4_0
- libvpx=1.7.0=h439df22_0
- libwebp=1.2.4=h11a3e52_1
- libwebp-base=1.2.4=h5eee18b_1
- libxcb=1.13=h7f98852_1004
- llvm-openmp=14.0.6=h9e868ea_0
- llvmlite=0.38.0=py37h4ff587b_0
- lz4-c=1.9.4=h6a678d5_0
- mkl=2021.4.0=h06a4308_640
- mkl-service=2.4.0=py37h7f8727e_0
- mkl_fft=1.3.1=py37hd3c417c_0
- mkl_random=1.2.2=py37h51133e4_0
- ncurses=6.4=h6a678d5_0
- nettle=3.7.3=hbbd107a_1
- numba=0.55.1=py37h51133e4_0
- numpy-base=1.21.5=py37ha15fc14_3
- openh264=2.1.1=h4ff587b_0
- openssl=1.1.1t=h7f8727e_0
- openssl=1.1.1s=h7f8727e_0
- pillow=9.4.0=py37h6a678d5_0
- pip=22.3.1=py37h06a4308_0
- pthread-stubs=0.4=h36c2ea0_1001
Expand All @@ -92,14 +84,12 @@ dependencies:
- setuptools=65.6.3=py37h06a4308_0
- six=1.16.0=pyhd3eb1b0_1
- sqlite=3.41.1=h5eee18b_0
- tbb=2021.8.0=hdb19cb5_0
- tk=8.6.12=h1ccaba5_0
- torchaudio=0.13.1=py37_cu117
- torchvision=0.14.1=py37_cu117
- typing_extensions=4.3.0=py37h06a4308_0
- urllib3=1.26.14=py37h06a4308_0
- wheel=0.38.4=py37h06a4308_0
- x264=1!157.20191217=h7b6447c_0
- xorg-kbproto=1.0.7=h7f98852_1002
- xorg-libice=1.0.10=h7f98852_0
- xorg-libsm=1.2.3=hd9c2040_1000
Expand All @@ -114,55 +104,91 @@ dependencies:
- zstd=1.5.4=hc292b87_0
- pip:
- backcall==0.2.0
- blis==0.7.9
- blobfile==2.0.1
- catalogue==2.0.8
- cdflib==0.4.9
- chumpy==0.71
- chumpy==0.70
- click==8.1.3
- confection==0.0.4
- configer==1.3.1
- configparser==5.3.0
- cycler==0.11.0
- cymem==2.0.7
- decorator==5.1.1
- dotmap==1.3.30
- filelock==3.11.0
- filterpy==1.4.5
- freetype-py==2.3.0
- ftfy==6.1.1
- h5py==3.8.0
- human-body-prior==0.8.5.0
- imageio==2.27.0
- importlib==1.0.4
- importlib-metadata==6.3.0
- ipdb==0.13.9
- ipython==7.34.0
- jedi==0.18.2
- jinja2==3.1.2
- joblib==1.2.0
- kiwisolver==1.4.4
- langcodes==3.3.0
- llvmlite==0.39.1
- lxml==4.9.2
- markupsafe==2.1.2
- matplotlib==3.1.3
- matplotlib-inline==0.1.6
- multi-person-tracker==0.1
- git+https://github.com/mkocabas/multi-person-tracker.git
- murmurhash==1.0.9
- networkx==2.6.3
- numba==0.56.4
- numpy==1.21.6
- opencv-python==4.6.0.66
- packaging==23.0
- pandas==1.3.5
- parso==0.8.3
- pathy==0.10.1
- pexpect==4.8.0
- pickleshare==0.7.5
- preshed==3.0.8
- prompt-toolkit==3.0.38
- protobuf==3.20.3
- ptyprocess==0.7.0
- pycryptodomex==3.17
- pydantic==1.10.7
- pyglet==1.5.26
- pygments==2.14.0
- pyopengl==3.1.5
- pyopengl
- pyopengl-accelerate==3.1.6
- pyparsing==3.0.9
- pyrender==0.1.45
- pyrender
- python-dateutil==2.8.2
- pytz==2023.3
- pywavelets==1.3.0
- pyyaml==5.4.1
- regex==2022.10.31
- roma==1.3.1
- scikit-image==0.19.3
- scipy==1.7.3
- smart-open==6.3.0
- smplx==0.1.28
- spacy==3.5.1
- spacy-legacy==3.0.12
- spacy-loggers==1.0.4
- srsly==2.4.6
- tensorboardx==2.6
- thinc==8.1.9
- tifffile==2021.11.2
- toml==0.10.2
- torchgeometry==0.1.2
- tqdm==4.65.0
- traitlets==5.9.0
- transforms3d==0.4.1
- trimesh==3.21.4
- typing-extensions==4.5.0
- typer==0.7.0
- typing-extensions==4.4.0
- wasabi==1.1.1
- wcwidth==0.2.6
- yacs==0.1.8
- yolov3==0.1
- git+https://github.com/mkocabas/yolov3-pytorch.git
- zipp==3.15.0
prefix: /pasteur/u/jeffheo/miniconda3/envs/temp_nemo
6 changes: 3 additions & 3 deletions custom_video/nemo-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ partition=pasteur
cmd="python -m scripts.learned_multi_view_recon_nn \
--default_config config/default-v1.yml \
--label_type ${label_type} \
--data_loader_type generic \
--data_loader_type demo \
--nemo_cfg_path custom_video/nemo-config.yml \
--out_dir custom_video/out/${expname} \
--lr_factor ${lr_factor} \
Expand All @@ -63,7 +63,7 @@ cmd="python -m scripts.learned_multi_view_recon_nn \
--h_dim ${h_dim} \
--render_rollout_figure \
--weight_3d_loss ${weight_3d_loss} \
--render_video 0 \
--render_video 1 \
--db
"

Expand Down Expand Up @@ -107,4 +107,4 @@ done
done
done
done
done
done
Loading

0 comments on commit 07c8d00

Please sign in to comment.