51 lines
898 B
Bash
51 lines
898 B
Bash
set -e
|
|
|
|
if [ -f .env ]; then
|
|
source .env
|
|
fi
|
|
|
|
if [ -z ${1} ]; then
|
|
echo "Please provide a JSON object"
|
|
exit 1
|
|
fi
|
|
|
|
function fail () {
|
|
ID="${1}"
|
|
META=${2}
|
|
URL="${YOLO_WEB_URL}/job/fail/${ID}"
|
|
echo "${META}"
|
|
curl -s -X POST \
|
|
-H 'Content-Type: application/json' \
|
|
-d "{\"meta\":\"${META}\"}" "${URL}"
|
|
}
|
|
|
|
JSON="${1}"
|
|
|
|
ID=$(echo $JSON | jq -r '.id')
|
|
DATASET=$(echo $JSON | jq -r '.dataset')
|
|
MODEL=$(echo $JSON | jq -r '.model')
|
|
NAME=$(echo $JSON | jq -r '.name')
|
|
FILEPATH=$(echo $JSON | jq -r '.path')
|
|
|
|
DOWNLOAD="${YOLO_WEB_URL}${FILEPATH}"
|
|
DEST="${YOLOv5}${DATASET}.zip"
|
|
UNZIPPED="${YOLOv5}${DATASET}"
|
|
|
|
echo "Downloading ${DOWNLOAD}"
|
|
|
|
if [ ! -f "${DEST}" ]; then
|
|
wget -q -O "${DEST}" "${DOWNLOAD}"
|
|
fi
|
|
|
|
unzip "${DEST}" -d "${UNZIPPED}"
|
|
|
|
if [ ! -f "${UNZIPPED}/data.yaml" ]; then
|
|
fail "${ID}" "Invalid dataset"
|
|
rm -rf "${UNZIPPED}"
|
|
rm "${DEST}"
|
|
exit 1
|
|
fi
|
|
|
|
FULLDEST=$(realpath "${DEST}")
|
|
|