-
Notifications
You must be signed in to change notification settings - Fork 26
/
run_gui_in_docker.sh
65 lines (56 loc) · 1.88 KB
/
run_gui_in_docker.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
#!/bin/bash
key=''
key_name=''
value=''
# Parsing keyword arguments
while [ $# -gt 0 ]; do
if [ -z "${key}" ]; then
case "$1" in
--images|--video|--workspace)
key="other"
key_name="${1}"
;;
--num_objects)
key="--num_objects"
;;
*)
printf "***************************\n"
printf "* Error: Invalid argument ${1}\n"
printf "* Specify one of --images --video or --workspace with <video file/frame folder path>.*\n"
printf "***************************\n"
exit 1
esac
else
if [ "${key}" = '--num_objects' ]; then
export "num_objects=${1}"
else
value=$(realpath -e "${1}") # input path must exist
export "${key}=${value}"
fi
key=''
fi
shift
done
if [ -z "${key_name}" ]; then
echo "Missing argument: --images|--video|--workspace - path to the input video/frames."
>&2 echo "Error: one or more arguments missing, exiting..."
exit 1
fi
# An array of arguments instead of just a string
# To avoid bash quoting (e.g. instead of 'python3 file.py --arg val' -> python3 file.py --arg val)
# This way Docker can parse a command and it's arguments separately
# Otherwise it will try to run a command named 'python3 file.py --arg val', which obviously is incorrect
args=("${key_name}" "${value}") # $key_name would be one of 'images' 'video' or 'workspace'
if [ -n "${num_objects}" ]; then
args+=("--num_objects" "${num_objects}")
fi
LOCAL_WORKSPACE_DIR="$(pwd)/workspace" # Feel free to change if necessary
DISPLAY_TO_USE="${DISPLAY}" # Feel free to change if necessary
set -x # To print the exact command that will run
docker run --runtime=nvidia -it --rm \
-e DISPLAY="${DISPLAY_TO_USE}" \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v "${value}":"${value}" \
-v "${LOCAL_WORKSPACE_DIR}":/app/workspace \
max810/xmem2:gui \
python3 interactive_demo.py "${args[@]}"