forked from alievk/avatarify-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·149 lines (123 loc) · 3.36 KB
/
run.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/env bash
# set -x
ENABLE_CONDA=1
ENABLE_VCAM=1
KILL_PS=1
USE_DOCKER=0
IS_WORKER=0
IS_CLIENT=0
DOCKER_IS_LOCAL_CLIENT=0
DOCKER_NO_GPU=0
FOMM_CONFIG=fomm/config/vox-adv-256.yaml
FOMM_CKPT=vox-adv-cpk.pth.tar
ARGS=""
DOCKER_ARGS=""
while (( "$#" )); do
case "$1" in
--no-conda)
ENABLE_CONDA=0
shift
;;
--no-vcam)
ENABLE_VCAM=0
ARGS="$ARGS --no-stream"
shift
;;
--keep-ps)
KILL_PS=0
shift
;;
--docker)
USE_DOCKER=1
shift
;;
--no-gpus)
DOCKER_NO_GPU=1
shift
;;
--is-worker)
IS_WORKER=1
ARGS="$ARGS $1"
DOCKER_ARGS="$DOCKER_ARGS -p 5557:5557 -p 5558:5558"
shift
;;
--is-client)
IS_CLIENT=1
ARGS="$ARGS $1"
shift
;;
--is-local-client)
IS_CLIENT=1
DOCKER_IS_LOCAL_CLIENT=1
ARGS="$ARGS --is-client"
shift
;;
*|-*|--*)
ARGS="$ARGS $1"
shift
;;
esac
done
eval set -- "$ARGS"
if [[ $USE_DOCKER == 0 ]]; then
if [[ $KILL_PS == 1 ]]; then
kill -9 $(ps aux | grep 'afy/cam_fomm.py' | awk '{print $2}') 2> /dev/null
fi
source scripts/settings.sh
if [[ $ENABLE_VCAM == 1 ]]; then
bash scripts/create_virtual_camera.sh
fi
if [[ $ENABLE_CONDA == 1 ]]; then
source $(conda info --base)/etc/profile.d/conda.sh
conda activate $CONDA_ENV_NAME
fi
export PYTHONPATH=$PYTHONPATH:$(pwd):$(pwd)/fomm
python afy/cam_fomm.py \
--config $FOMM_CONFIG \
--checkpoint $FOMM_CKPT \
--virt-cam $CAMID_VIRT \
--relative \
--adapt_scale \
$@
else
source scripts/settings.sh
if [[ $ENABLE_VCAM == 1 ]]; then
bash scripts/create_virtual_camera.sh
fi
if [[ $DOCKER_NO_GPU == 0 ]]; then
DOCKER_ARGS="$DOCKER_ARGS --gpus all"
fi
if [[ $DOCKER_IS_LOCAL_CLIENT == 1 ]]; then
DOCKER_ARGS="$DOCKER_ARGS --network=host"
elif [[ $IS_CLIENT == 1 ]]; then
DOCKER_ARGS="$DOCKER_ARGS -p 5557:5554 -p 5557:5558"
fi
if [[ $IS_WORKER == 0 ]]; then
xhost +local:root
docker run $DOCKER_ARGS -it --rm --privileged \
-v $PWD:/root/.torch/models \
-v $PWD/avatars:/app/avatarify/avatars \
--env="DISPLAY" \
--env="QT_X11_NO_MITSHM=1" \
--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
avatarify python3 afy/cam_fomm.py \
--config $FOMM_CONFIG \
--checkpoint $FOMM_CKPT \
--virt-cam $CAMID_VIRT \
--relative \
--adapt_scale \
$@
xhost -local:root
else
docker run $DOCKER_ARGS -it --rm --privileged \
-v $PWD:/root/.torch/models \
-v $PWD/avatars:/app/avatarify/avatars \
avatarify python3 afy/cam_fomm.py \
--config $FOMM_CONFIG \
--checkpoint $FOMM_CKPT \
--virt-cam $CAMID_VIRT \
--relative \
--adapt_scale \
$@
fi
fi