File size: 1,326 Bytes
62785f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash
# Inference for ct_binary_coronary_segmentation
#
# Usage:
#   ./scripts/inference.sh                                      # Ensemble on default data
#   ./scripts/inference.sh --dataset-dir /path/to/images        # Ensemble on custom data
#   ./scripts/inference.sh --single --fold 0                    # Single model
#   ./scripts/inference.sh --output-dir /path/to/output         # Custom output
#   ./scripts/inference.sh --gpu 1                              # Use specific GPU

set -euo pipefail
cd "$(dirname "$0")/.."

ENSEMBLE=true
GPU=0
EXTRA_ARGS=()

while [[ $# -gt 0 ]]; do
    case $1 in
        --single) ENSEMBLE=false; shift ;;
        --dataset-dir) EXTRA_ARGS+=("--dataset_dir" "$2"); shift 2 ;;
        --output-dir) EXTRA_ARGS+=("--output_dir" "$2"); shift 2 ;;
        --fold) EXTRA_ARGS+=("--fold" "$2"); shift 2 ;;
        --gpu) GPU="$2"; shift 2 ;;
        *) EXTRA_ARGS+=("$1"); shift ;;
    esac
done

if $ENSEMBLE; then
    CONFIG="configs/ensemble_inference.yaml"
else
    CONFIG="configs/inference.yaml"
fi

echo "=== Running inference ($(if $ENSEMBLE; then echo 'ensemble'; else echo 'single model'; fi)) on GPU $GPU ==="
CUDA_VISIBLE_DEVICES=$GPU micromamba run -n monai python -m monai.bundle run inference \
    --config_file "$CONFIG" \
    "${EXTRA_ARGS[@]+"${EXTRA_ARGS[@]}"}"