File size: 1,881 Bytes
7c2871f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env bash
# Generic test script for running inference with any method and dataset.
# Usage:
#   bash scripts/test_generic.sh <method> <dataset> [checkpoint_path]
# Examples:
#   bash scripts/test_generic.sh cta fairtalking
#   bash scripts/test_generic.sh psm fairtalking_ffpp outputs/psm/checkpoints/last.ckpt
#   bash scripts/test_generic.sh radr fairtalking_hdtf_paired
set -eo pipefail
cd "$(dirname "$0")/.."

# load .env if present
[ -f .env ] && set -a && . ./.env && set +a

# Validate arguments
if [ $# -lt 2 ]; then
    echo "Usage: $0 <method> <dataset> [checkpoint_path]"
    echo "Available methods: cta, psm, radr"
    echo "Available datasets: fairtalking, fairtalking_thb, fairtalking_ffpp, fairtalking_hdtf_paired"
    exit 1
fi

METHOD="$1"
DATASET="$2"
shift 2
CKPT="${1:-outputs/${METHOD}/checkpoints/last.ckpt}"
if [ $# -ge 1 ]; then shift; fi

# Validate method
case "$METHOD" in
    cta|psm|radr)
        # Valid method
        ;;
    *)
        echo "Error: Invalid method '$METHOD'. Available methods: cta, psm, radr"
        exit 1
        ;;
esac

# Validate dataset
case "$DATASET" in
    fairtalking|fairtalking_thb|fairtalking_ffpp|fairtalking_hdtf_paired)
        # Valid dataset
        ;;
    *)
        echo "Error: Invalid dataset '$DATASET'. Available datasets: fairtalking, fairtalking_thb, fairtalking_ffpp, fairtalking_hdtf_paired"
        exit 1
        ;;
esac

if [ ! -f "$CKPT" ]; then
    echo "[test_generic] checkpoint not found: $CKPT"
    echo "[test_generic] Please train the model first or provide a valid checkpoint path"
    exit 1
fi

echo "[test_generic] Method: $METHOD"
echo "[test_generic] Dataset: $DATASET"
echo "[test_generic] Checkpoint: $CKPT"

python3 src/train.py \
    method=$METHOD \
    data=$DATASET \
    trainer=ddp \
    backbone=timesformer \
    +test_only=true \
    +test_ckpt="$CKPT" \
    "$@"