-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·64 lines (58 loc) · 1.99 KB
/
run.sh
File metadata and controls
executable file
·64 lines (58 loc) · 1.99 KB
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
#!/usr/bin/env bash
# Run inference: ./run.sh [task] [image(s)]
# task: face_landmarker (default) | face_detector | face_decode | compare | face_decode_embed | compare_embed
# image: path(s); for compare use two paths: ./run.sh compare img1.jpg img2.jpg
# Ensure you have run: ./install.sh
set -e
# --- Paths ---
ROOT="$(cd "$(dirname "$0")" && pwd)"
cd "$ROOT"
PYTHON="${ROOT}/.venv/bin/python"
# --- Check venv ---
if [ ! -x "$PYTHON" ]; then
echo "Run ./install.sh first." >&2
exit 1
fi
# --- Parse task and image ---
TASK="face_landmarker"
IMAGE=""
case "${1:-}" in
face_landmarker|face_detector|face_decode|compare|face_decode_embed|compare_embed)
TASK="$1"
shift
IMAGE="$*"
;;
*)
IMAGE="${1:-}"
;;
esac
# --- Resolve image: use first in images/ if none given (not for compare) ---
if [ -z "$IMAGE" ] && [ "$TASK" != "compare" ] && [ "$TASK" != "compare_embed" ]; then
FIRST="$(find images -maxdepth 1 -type f \( -name '*.jpg' -o -name '*.jpeg' -o -name '*.png' \) 2>/dev/null | head -1)"
if [ -z "$FIRST" ]; then
echo "Usage: ./run.sh [task] [path/to/image.jpg ...]" >&2
echo " compare/compare_embed need two images: ./run.sh compare img1.jpg img2.jpg" >&2
exit 1
fi
IMAGE="$FIRST"
fi
if [ "$TASK" = "compare" ] || [ "$TASK" = "compare_embed" ]; then
if [ -z "$IMAGE" ]; then
echo "Usage: ./run.sh $TASK path/to/img1.jpg path/to/img2.jpg" >&2
exit 1
fi
fi
# --- Run ---
if [ "$TASK" = "face_landmarker" ]; then
"$PYTHON" run.py --task face_landmarker --no-blendshapes --image $IMAGE
elif [ "$TASK" = "face_detector" ]; then
"$PYTHON" run.py --task face_detector --image $IMAGE
elif [ "$TASK" = "face_decode" ]; then
"$PYTHON" run.py --task face_decode --image $IMAGE
elif [ "$TASK" = "compare" ]; then
"$PYTHON" run.py --task compare --image $IMAGE
elif [ "$TASK" = "face_decode_embed" ]; then
"$PYTHON" run.py --task face_decode_embed --image $IMAGE
elif [ "$TASK" = "compare_embed" ]; then
"$PYTHON" run.py --task compare_embed --image $IMAGE
fi