forked from nerfstudio-project/nerfstudio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathall_process.sh
107 lines (91 loc) · 2.24 KB
/
all_process.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
92
93
94
95
96
97
98
99
100
if [ -z $1 ]
then
export CUDA_VISIBLE_DEVICES=0
else
export CUDA_VISIBLE_DEVICES=$1
fi
if [ -z $2 ]
then
export FOLDER="data/nerfstudio"
else
export FOLDER=$2
fi
if [ -z $3 ]
then
export OVERWRITE=false
else
export OVERWRITE=$3
fi
if [ -z $4 ]
then
export SFM=colmap
else
export SFM=$4 #colmap or hloc
fi
for SCENE_FOLDER in $FOLDER/*
do
SCENE=$(basename $SCENE_FOLDER)
DATASET=$FOLDER/$SCENE
OUTPUT_DIR=$DATASET
TRANSFORMS=${DATASET}/transforms.json
TRANSFORMS_TRAIN=${DATASET}/transforms_train.json
TRANSFORMS_TEST=${DATASET}/transforms_test.json
TRANSFORMS_VAL=${DATASET}/transforms_val.json
# ([ -e $TRANSFORMS ] || [ -e $TRANSFORMS_TRAIN ] || [ -e $TRANSFORMS_TEST ] || [ -e $TRANSFORMS_VAL ] )
if [ -e $TRANSFORMS ] && ! $OVERWRITE; then
echo "$DATASET already processed"
continue
else
if [ ! -d $DATASET ]; then
continue
fi
# possible video paths
PATH_MP4=${DATASET}/*.mp4
PATH_AVI=${DATASET}/*.avi
PATH_MKV=${DATASET}/*.mkv
PATH_MOV=${DATASET}/*.mov
PATH_WMV=${DATASET}/*.wmv
PATH_FLV=${DATASET}/*.flv
PATH_WEBM=${DATASET}/*.webm
# check data dir for images or video
if [ -e "$DATASET/images" ]; then
TYPE="images"
DATASET="$DATASET/images"
elif [ -e "$DATASET/rgb" ]; then
TYPE="images"
DATASET="$DATASET/rgb"
elif [ -e "$DATASET/image" ]; then
TYPE="images"
DATASET="$DATASET/image"
elif [ -e "$DATASET/train" ] || [ -e "$DATASET/test" ] || [ -e "$DATASET/val" ]; then
TYPE="images"
DATASET="$DATASET/train"
elif [ -e $PATH_MP4 ]; then
TYPE="video"
DATASET=$(ls $DATASET/*.mp4 | sort -n 1 | tail -n 1)
elif [ -e $PATH_AVI ]; then
TYPE="video"
DATASET=$(ls $DATASET/*.avi | sort -n 1 | tail -n 1)
elif [ -e $PATH_MKV ]; then
TYPE="video"
DATASET=$(ls $DATASET/*.mkv | sort -n 1 | tail -n 1)
elif [ -e $PATH_MOV ]; then
TYPE="video"
DATASET=$(ls $DATASET/*.MOV | sort -n 1 | tail -n 1)
elif [ -e $PATH_WMV ]; then
TYPE="video"
DATASET=$(ls $DATASET/*.wmv | sort -n 1 | tail -n 1)
elif [ -e $PATH_FLV ]; then
TYPE="video"
DATASET=$(ls $DATASET/*.flv | sort -n 1 | tail -n 1)
elif [ -e $PATH_WEBM ]; then
TYPE="video"
DATASET=$(ls $DATASET/*.webm | sort -n 1 | tail -n 1)
else
echo "$DATASET has no data"
break
fi
echo "sh process_data.sh $CUDA_VISIBLE_DEVICES $TYPE $DATASET $SFM $OUTPUT_DIR"
sh process_data.sh $CUDA_VISIBLE_DEVICES $TYPE $DATASET $SFM $OUTPUT_DIR
fi
done