Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
issue #18 fix image file path in start script
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeslabreche committed Mar 22, 2024
1 parent 94ee270 commit de821c2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion smartcam/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ cluster_img_types = ["jpeg","png","ims_rgb","fapec"]
[model_default]
default.tflite_model = models/default/model.tflite
default.labels = models/default/labels.txt
default.labels_keep = ["earth:doom","edge:doom","bad"]
default.labels_keep = ["earth:doom","edge:doom","bad:doom"]
default.input_height = 224
default.input_width = 224
default.input_mean = 0
Expand Down
46 changes: 24 additions & 22 deletions smartcam/start.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
#!/bin/sh

# the DOOM experiment directory path
exp_dir="/home/exp272/"

# function to write messages with a timestamp to a log file
log() {
# echo the original message to the console
echo "$*"

# prefix each message with the current timestamp and write to the log file
echo "$(date '+%Y-%m-%d %H:%M:%S') - $*" >> "${exp_dir}run.log"
}

show_usage() {
echo "Usage: $0 -i <image_file> [other options]"
# You can list other recognized options here
log "Usage: $0 -i <image_file> [other options]"
exit 1
}


# Initialize image_file to an empty string
image_file=""

Expand All @@ -14,8 +26,8 @@ while getopts ":i:" opt; do
case $opt in
i) image_file="$OPTARG"
;;
*) # Catch all other options and do nothing
# Optionally, you could log these if needed
*) # catch all other options and do nothing
# optionally, you could log these if needed
# echo "Ignoring unrecognized option: $OPTARG"
;;
esac
Expand All @@ -28,33 +40,23 @@ fi

# need the full image file path of the image for uderlying scripts
# smart cam image files are written in /home/exp1000/
image_file=/home/exp1000/$image_file
image_file=$(readlink -f $image_file)

# check if given image file exists
if [ ! -f "$image_file" ]; then
echo "Error: The image file does not exist."
log "Error: the image file does not exist ${image_file}"
exit 1
fi

# Save the current directory path
# save the current directory path
sc_dir=$(pwd)

# the DOOM experiment directory path
exp_dir="/home/exp272/"
# cd into the DOOM directory and run the experiment
cd "$exp_dir" || { log "Failed to change directory to ${exp_dir}"; exit 1; }
./start_exp272.sh "$image_file" > /dev/null 2>&1

# Check if the directory exists
if [ -d "$exp_dir" ]; then
# If the directory exists, cd into it and run the experiment
cd "$exp_dir" || exit 1
./start_exp272.sh "$image_file" > /dev/null 2>&1

# Return to the original directory
cd "$sc_dir" || exit 1
else
# If the directory does not exist, print an error message
echo "DOOM is not installed!"
exit 1
fi
# return to the original directory
cd "$sc_dir" || { log "Failed to return to ${sc_dir}"; exit 1; }

# if successful, print JSON string
echo '{"doom": 1}'
Expand Down

0 comments on commit de821c2

Please sign in to comment.