forked from nerfstudio-project/nerfstudio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender.sh
91 lines (82 loc) · 3.05 KB
/
render.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
if [ -z $1 ]
then
export CUDA_VISIBLE_DEVICES=0
else
export CUDA_VISIBLE_DEVICES=$1
fi
if [ -z $2 ]
then
export MODEL="nerfacto"
else
export MODEL=$2
fi
if [ -z "$3" ]
then
export DATASET="data/nerfstudio/kitchen"
else
export DATASET="$3"
fi
if [ -z $4 ]
then
export RESOL=1
else
export RESOL=$4
fi
if [ -z $5 ]
then
export OVERWRITE=false
else
export OVERWRITE=$5
fi
if [ "${MODEL}" = "generfacto" ] # for model generation
then
SCENE=`echo ${DATASET// /_}` # output folder name, using _ instead of spaces
if ! [ -e outputs/$SCENE ]
then
export SCENE=""
fi
else # for any nerf model
export SCENE=$(echo $(basename $DATASET))
fi
CKPT_LIST=$(ls -d $PWD/outputs/$SCENE/$MODEL/*/*/*.ckpt)
for CKPT in $CKPT_LIST
do
CKPT_PATH=$CKPT #$(ls outputs/$SCENE/$MODEL/*/*/*.ckpt | sort -n | tail -n 1)
CKPT_NAME=$(basename $(dirname $(dirname $CKPT)))
MODEL_PATH=$(dirname $(dirname $CKPT_PATH))
CKPT_DATE=$(basename $MODEL_PATH)
CFG_PATH=$MODEL_PATH/config.yml
if [ -e renders/$SCENE/$MODEL/$CKPT_DATE.mp4 ] && ! $OVERWRITE; then
echo "renders/$SCENE/$MODEL/$CKPT_DATE.mp4 already rendered"
continue
fi
echo $MODEL_PATH;
echo $CKPT_PATH;
PATH_CAMERA_JSON=${DATASET}/camera_paths/*.json
if [ -e $PATH_CAMERA_JSON ]; then
CAM_PATH=$(ls $DATASET/camera_paths/*.json | sort -n | tail -n 1)
echo "ns-render camera-path --load-config $CFG_PATH --camera-path-filename $DATASET/camera_paths/$CKPT_DATE.json --output-path renders/$SCENE/$MODEL/$CKPT_DATE.mp4 --downscale-factor $RESOL --rendered_output_name rgb_fine"
{
ns-render camera-path --load-config $CFG_PATH --camera-path-filename $CAM_PATH --output-path renders/$SCENE/$MODEL/$CKPT_DATE.mp4 --downscale-factor $RESOL --rendered_output_names rgb_fine
} || {
ns-render camera-path --load-config $CFG_PATH --camera-path-filename $CAM_PATH --output-path renders/$SCENE/$MODEL/$CKPT_DATE.mp4 --downscale-factor $RESOL --rendered_output_names rgb
}
else
echo "ns-render interpolate --load-config $CFG_PATH --output-path renders/$SCENE/$MODEL/$CKPT_DATE.mp4 --downscale-factor $RESOL --rendered_output_names rgb"
{
ns-render interpolate --load-config $CFG_PATH --output-path renders/$SCENE/$MODEL/$CKPT_DATE.mp4 --downscale-factor $RESOL --rendered_output_names rgb
} || {
ns-render interpolate --load-config $CFG_PATH --output-path renders/$SCENE/$MODEL/$CKPT_DATE.mp4 --downscale-factor $RESOL --rendered_output_names rgb_fine
}
echo "ns-render spiral --load-config $CFG_PATH --output-path renders/$SCENE/$MODEL/spiral-$CKPT_DATE.mp4 --downscale-factor $RESOL --rendered_output_names rgb"
{
ns-render spiral --load-config $CFG_PATH --output-path renders/$SCENE/$MODEL/spiral-$CKPT_DATE.mp4 --downscale-factor $RESOL --rendered_output_names rgb
} || {
ns-render spiral --load-config $CFG_PATH --output-path renders/$SCENE/$MODEL/spiral-$CKPT_DATE.mp4 --downscale-factor $RESOL --rendered_output_names rgb_fine
}
fi
# mp4 video to gif
echo "ffmpeg -y -i renders/$SCENE/$MODEL/$CKPT_DATE.mp4 renders/$SCENE/$MODEL/$CKPT_DATE.gif"
ffmpeg -y -i renders/$SCENE/$MODEL/$CKPT_DATE.mp4 renders/$SCENE/$MODEL/$CKPT_DATE.gif -filter_complex "fps=30,scale=480:-1"
done