-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpredict.sh
More file actions
executable file
·58 lines (45 loc) · 1.33 KB
/
predict.sh
File metadata and controls
executable file
·58 lines (45 loc) · 1.33 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
#!/bin/bash
# Store the original working directory
ORIGINAL_DIR="$(pwd)"
# Get the absolute path of the script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR" || {
echo "❌ Failed to switch to script directory"
exit 1
}
# Activate virtual environment
source "$SCRIPT_DIR/.venv/bin/activate"
# Default input, output, and model file paths
INPUT_FILE=""
OUTPUT_FILE=""
MODEL_FILE=""
# Parse command-line arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
--input) INPUT_FILE="$2"; shift ;; # Capture --input argument
--output) OUTPUT_FILE="$2"; shift ;; # Capture --output argument
--model-file) MODEL_FILE="$2"; shift ;; # Capture --model-file argument
*) echo "Unknown parameter: $1" ;; # Handle unexpected arguments
esac
shift
done
# Build the command dynamically
CMD="python predict.py"
# Append input file argument if provided
if [[ -n "$INPUT_FILE" ]]; then
CMD+=" --input \"$INPUT_FILE\""
fi
# Append output file argument if provided
if [[ -n "$OUTPUT_FILE" ]]; then
CMD+=" --output \"$OUTPUT_FILE\""
fi
# Append model file argument if provided
if [[ -n "$MODEL_FILE" ]]; then
CMD+=" --model-file \"$MODEL_FILE\""
fi
# Run the command
eval $CMD
# Deactivate virtual environment
deactivate
# Restore the original working directory
cd "$ORIGINAL_DIR"