Skip to content

Commit 71f1fb5

Browse files
committed
feat: default evaluation scripts get a clearer arg parser
1 parent 42b0068 commit 71f1fb5

File tree

6 files changed

+142
-46
lines changed

6 files changed

+142
-46
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
*.out
22
*.bin
33
*.inc
4-
*.sh
54
*.tar.gz
5+
*.sh
66
.DS_Store
77
builds
88
compressai_vision/version.py

scripts/evaluation/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ with
3939
## Test your environment
4040
In addition, the following script is provided to test your environment
4141
```
42-
bash default_vision_performances.sh compressai-split-inference /path/to/testdata
42+
bash default_vision_performances.sh --command [entry_cmd] --testdata [/path/to/dataset] --device [device]"
4343
```
4444
it runs the evaluation of the performance of the vision models without compression of input video or intermediate data. In both pipeline types, the input content is passed to the decoder without compression.
4545

scripts/evaluation/default_mmpose_rtmo.sh

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,45 @@
55
# see provided installation scripts
66
set -eu
77

8-
ENTRY_CMD=$1
9-
TESTDATA_DIR=$2
10-
DEVICE=$3
8+
usage() {
9+
echo "Usage: $0 --command <command> --testdata <path> --device <device>"
10+
echo ""
11+
echo "Runs evaluation for mmpose rtmo."
12+
echo ""
13+
echo "Options:"
14+
echo " -c, --command Entrypoint command. Options: compressai-split-inference, compressai-remote-inference"
15+
echo " -t, --testdata Path to the test data directory (e.g., /path/to/COCODataset/)."
16+
echo " -d, --device Device to use for evaluation (e.g., cuda:0)."
17+
echo " -h, --help Display this help message."
18+
exit 1
19+
}
20+
21+
# Parse arguments
22+
while [[ $# -gt 0 ]]; do
23+
key="$1"
24+
case $key in
25+
-c|--command) shift; ENTRY_CMD="$1"; shift; ;;
26+
-t|--testdata) shift; TESTDATA_DIR="$1"; shift; ;;
27+
-d|--device) shift; DEVICE="$1"; shift; ;;
28+
-h|--help) usage;;
29+
*) echo "[ERROR] Unknown parameter $1"; usage; exit; ;;
30+
esac
31+
done
32+
33+
# Check if mandatory arguments are provided
34+
if [ -z "${ENTRY_CMD-}" ] || [ -z "${TESTDATA_DIR-}" ] || [ -z "${DEVICE-}" ]; then
35+
echo "Error: Missing mandatory arguments."
36+
usage
37+
fi
1138

1239
# List of entry cmds
13-
CMD_OPTS=("compressai-split-inference", "compressai-remote-inference")
40+
CMD_OPTS=("compressai-split-inference" "compressai-remote-inference")
1441

15-
if [[ "${CMD_OPTS[@]}" =~ ${ENTRY_CMD} ]]; then
42+
if [[ " ${CMD_OPTS[@]} " =~ " ${ENTRY_CMD} " ]]; then
1643
echo "Run ${ENTRY_CMD} ........"
1744
else
18-
echo : "${ENTRY_CMD} does not exist in the options."
19-
echo : "Please choose one out of these options: ${CMD_OPTS[@]}"
45+
echo ": ${ENTRY_CMD} does not exist in the options."
46+
echo ": Please choose one out of these options: ${CMD_OPTS[*]}"
2047
exit 1
2148
fi
2249

@@ -27,12 +54,9 @@ configs["compressai-remote-inference"]="eval_remote_inference_example"
2754

2855
CONF_NAME=${configs[${ENTRY_CMD}]}
2956

30-
if [ $# == 2 ]; then
31-
TESTDATA_DIR=$2
32-
fi
3357
if [ ! -d "${TESTDATA_DIR}" ]; then
3458
echo "${TESTDATA_DIR} does not exist, please select dataset folder, e.g.
35-
$ bash default_vision_performances.sh [etnry_cmd] [/path/to/dataset]"
59+
$ bash default_vision_performances.sh --command [entry_cmd] --testdata [/path/to/dataset] --device [device]"
3660
exit
3761
fi
3862

scripts/evaluation/default_vision_performances.sh

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,45 @@
55
# see provided installation scripts
66
set -eu
77

8-
ENTRY_CMD=$1
9-
TESTDATA_DIR=$2
10-
DEVICE=$3
8+
usage() {
9+
echo "Usage: $0 --command <command> --testdata <path> --device <device>"
10+
echo ""
11+
echo "Runs evaluation for vision performances."
12+
echo ""
13+
echo "Options:"
14+
echo " -c, --command Entrypoint command. Options: compressai-split-inference, compressai-remote-inference"
15+
echo " -t, --testdata Path to the test data directory (e.g., /path/to/COCODataset/)."
16+
echo " -d, --device Device to use for evaluation (e.g., cuda:0)."
17+
echo " -h, --help Display this help message."
18+
exit 1
19+
}
20+
21+
# Parse arguments
22+
while [[ $# -gt 0 ]]; do
23+
key="$1"
24+
case $key in
25+
-c|--command) shift; ENTRY_CMD="$1"; shift; ;;
26+
-t|--testdata) shift; TESTDATA_DIR="$1"; shift; ;;
27+
-d|--device) shift; DEVICE="$1"; shift; ;;
28+
-h|--help) usage;;
29+
*) echo "[ERROR] Unknown parameter $1"; usage; exit; ;;
30+
esac
31+
done
32+
33+
# Check if mandatory arguments are provided
34+
if [ -z "${ENTRY_CMD-}" ] || [ -z "${TESTDATA_DIR-}" ] || [ -z "${DEVICE-}" ]; then
35+
echo "Error: Missing mandatory arguments."
36+
usage
37+
fi
1138

1239
# List of entry cmds
13-
CMD_OPTS=("compressai-split-inference", "compressai-remote-inference")
40+
CMD_OPTS=("compressai-split-inference" "compressai-remote-inference")
1441

15-
if [[ "${CMD_OPTS[@]}" =~ ${ENTRY_CMD} ]]; then
42+
if [[ " ${CMD_OPTS[@]} " =~ " ${ENTRY_CMD} " ]]; then
1643
echo "Run ${ENTRY_CMD} ........"
1744
else
18-
echo : "${ENTRY_CMD} does not exist in the options."
19-
echo : "Please choose one out of these options: ${CMD_OPTS[@]}"
45+
echo ": ${ENTRY_CMD} does not exist in the options."
46+
echo ": Please choose one out of these options: ${CMD_OPTS[*]}"
2047
exit 1
2148
fi
2249

@@ -27,12 +54,9 @@ configs["compressai-remote-inference"]="eval_remote_inference_example"
2754

2855
CONF_NAME=${configs[${ENTRY_CMD}]}
2956

30-
if [ $# == 2 ]; then
31-
TESTDATA_DIR=$2
32-
fi
3357
if [ ! -d "${TESTDATA_DIR}" ]; then
3458
echo "${TESTDATA_DIR} does not exist, please select dataset folder, e.g.
35-
$ bash default_vision_performances.sh [etnry_cmd] [/path/to/dataset]"
59+
$ bash default_vision_performances.sh --command [entry_cmd] --testdata [/path/to/dataset] --device [device]"
3660
exit
3761
fi
3862

scripts/evaluation/default_vision_performances_sam.sh

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,45 @@
55
# see provided installation scripts
66
set -eu
77

8-
ENTRY_CMD=$1
9-
TESTDATA_DIR=$2
10-
DEVICE=$3
8+
usage() {
9+
echo "Usage: $0 --command <command> --testdata <path> --device <device>"
10+
echo ""
11+
echo "Runs evaluation for vision performances with SAM."
12+
echo ""
13+
echo "Options:"
14+
echo " -c, --command Entrypoint command. Options: compressai-split-inference, compressai-remote-inference"
15+
echo " -t, --testdata Path to the test data directory (e.g., /path/to/COCODataset/)."
16+
echo " -d, --device Device to use for evaluation (e.g., cuda:0)."
17+
echo " -h, --help Display this help message."
18+
exit 1
19+
}
20+
21+
# Parse arguments
22+
while [[ $# -gt 0 ]]; do
23+
key="$1"
24+
case $key in
25+
-c|--command) shift; ENTRY_CMD="$1"; shift; ;;
26+
-t|--testdata) shift; TESTDATA_DIR="$1"; shift; ;;
27+
-d|--device) shift; DEVICE="$1"; shift; ;;
28+
-h|--help) usage;;
29+
*) echo "[ERROR] Unknown parameter $1"; usage; exit; ;;
30+
esac
31+
done
32+
33+
# Check if mandatory arguments are provided
34+
if [ -z "${ENTRY_CMD-}" ] || [ -z "${TESTDATA_DIR-}" ] || [ -z "${DEVICE-}" ]; then
35+
echo "Error: Missing mandatory arguments."
36+
usage
37+
fi
1138

1239
# List of entry cmds
13-
CMD_OPTS=("compressai-split-inference", "compressai-remote-inference")
40+
CMD_OPTS=("compressai-split-inference" "compressai-remote-inference")
1441

15-
if [[ "${CMD_OPTS[@]}" =~ ${ENTRY_CMD} ]]; then
42+
if [[ " ${CMD_OPTS[@]} " =~ " ${ENTRY_CMD} " ]]; then
1643
echo "Run ${ENTRY_CMD} ........"
1744
else
18-
echo : "${ENTRY_CMD} does not exist in the options."
19-
echo : "Please choose one out of these options: ${CMD_OPTS[@]}"
45+
echo ": ${ENTRY_CMD} does not exist in the options."
46+
echo ": Please choose one out of these options: ${CMD_OPTS[*]}"
2047
exit 1
2148
fi
2249

@@ -27,12 +54,9 @@ configs["compressai-remote-inference"]="eval_remote_inference_example"
2754

2855
CONF_NAME=${configs[${ENTRY_CMD}]}
2956

30-
if [ $# == 2 ]; then
31-
TESTDATA_DIR=$2
32-
fi
3357
if [ ! -d "${TESTDATA_DIR}" ]; then
3458
echo "${TESTDATA_DIR} does not exist, please select dataset folder, e.g.
35-
$ bash default_vision_performances.sh [etnry_cmd] [/path/to/dataset]"
59+
$ bash default_vision_performances.sh --command [entry_cmd] --testdata [/path/to/dataset] --device [device]"
3660
exit
3761
fi
3862

scripts/evaluation/default_yolox_darknet3_performance.sh

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,45 @@
55
# see provided installation scripts
66
set -eu
77

8-
ENTRY_CMD=$1
9-
TESTDATA_DIR=$2
10-
DEVICE=$3
8+
usage() {
9+
echo "Usage: $0 --command <command> --testdata <path> --device <device>"
10+
echo ""
11+
echo "Runs evaluation for yolox darknet3 performance."
12+
echo ""
13+
echo "Options:"
14+
echo " -c, --command Entrypoint command. Options: compressai-split-inference, compressai-remote-inference"
15+
echo " -t, --testdata Path to the test data directory (e.g., /path/to/COCODataset/)."
16+
echo " -d, --device Device to use for evaluation (e.g., cuda:0)."
17+
echo " -h, --help Display this help message."
18+
exit 1
19+
}
20+
21+
# Parse arguments
22+
while [[ $# -gt 0 ]]; do
23+
key="$1"
24+
case $key in
25+
-c|--command) shift; ENTRY_CMD="$1"; shift; ;;
26+
-t|--testdata) shift; TESTDATA_DIR="$1"; shift; ;;
27+
-d|--device) shift; DEVICE="$1"; shift; ;;
28+
-h|--help) usage ;;
29+
*) echo "[ERROR] Unknown parameter $1"; usage; exit; ;;
30+
esac
31+
done
32+
33+
# Check if mandatory arguments are provided
34+
if [ -z "${ENTRY_CMD-}" ] || [ -z "${TESTDATA_DIR-}" ] || [ -z "${DEVICE-}" ]; then
35+
echo "Error: Missing mandatory arguments."
36+
usage
37+
fi
1138

1239
# List of entry cmds
13-
CMD_OPTS=("compressai-split-inference", "compressai-remote-inference")
40+
CMD_OPTS=("compressai-split-inference" "compressai-remote-inference")
1441

15-
if [[ "${CMD_OPTS[@]}" =~ ${ENTRY_CMD} ]]; then
42+
if [[ " ${CMD_OPTS[@]} " =~ " ${ENTRY_CMD} " ]]; then
1643
echo "Run ${ENTRY_CMD} ........"
1744
else
18-
echo : "${ENTRY_CMD} does not exist in the options."
19-
echo : "Please choose one out of these options: ${CMD_OPTS[@]}"
45+
echo ": ${ENTRY_CMD} does not exist in the options."
46+
echo ": Please choose one out of these options: ${CMD_OPTS[*]}"
2047
exit 1
2148
fi
2249

@@ -27,12 +54,9 @@ configs["compressai-remote-inference"]="eval_remote_inference_example"
2754

2855
CONF_NAME=${configs[${ENTRY_CMD}]}
2956

30-
if [ $# == 2 ]; then
31-
TESTDATA_DIR=$2
32-
fi
3357
if [ ! -d "${TESTDATA_DIR}" ]; then
3458
echo "${TESTDATA_DIR} does not exist, please select dataset folder, e.g.
35-
$ bash default_vision_performances.sh [etnry_cmd] [/path/to/dataset]"
59+
$ bash default_vision_performances.sh --command [entry_cmd] --testdata [/path/to/dataset] --device [device]"
3660
exit
3761
fi
3862

0 commit comments

Comments
 (0)