Caught typo in upload logic. Add export step to train

This commit is contained in:
Matt McWilliams 2023-06-30 10:45:07 -04:00
parent b5ff3543b6
commit 522ad74717
4 changed files with 31 additions and 3 deletions

View File

@ -21,4 +21,8 @@ if [[ "${JSON}" != *"{"* ]]; then
exit 1
fi
bash ./scripts/train.sh "${JSON}"
if [ -f ./scripts/claim_mail.sh ]; then
bash ./scripts/claim_mail.sh "${JSON}"
fi
bash ./scripts/train.sh "${JSON}"

View File

@ -8,3 +8,4 @@ cd yolov5
python -m venv env
source env/bin/activate
python -m pip install -r requirements.txt
python -m pip install onnx

View File

@ -19,6 +19,8 @@ function fail () {
-d "{\"meta\":\"${META}\"}" "${URL}"
}
trap 'fail $ID' ERR
JSON="${1}"
ID=$(echo $JSON | jq -r '.id')
@ -62,3 +64,24 @@ fi
python train.py --img 640 --batch 16 --epochs 300 --data "${FULLDEST}/data.yaml" --weights "${WEIGHTS}" --cache --project ../models/ --name "${ID}"
if [ ! -f "../models/${ID}/weights/best.pt" ]; then
fail "${ID}" "Error training model"
rm -rf "${UNZIPPED}"
rm "${DEST}"
exit 3
fi
python export.py --weights "../models/${ID}/weights/best.pt" --include onnx
if [ ! -f "../models/${ID}/weights/best.onnx" ]; then
fail "${ID}" "Error exporting model"
rm -rf "${UNZIPPED}"
rm "${DEST}"
exit 3
fi
MODELPATH=$(realpath "../models/${ID}/weights/best.onnx")
curl -s -X POST \
-F "model@${MODELPATH}" \
"${YOLO_WEB_URL}/job/${ID}"

View File

@ -219,7 +219,7 @@ app.post('/', uploadZip.single('dataset'), async (req : Request, res : Response,
req.setTimeout(0);
if (typeof req.file === 'undefined' && req.file === null) {
if (typeof req.file === 'undefined' || req.file === null) {
console.error('No file in upload');
return next('ERROR: Please upload dataset as zip file');
}
@ -273,7 +273,7 @@ app.post('/job/:id', uploadOnnx.single('model'), async (req : Request, res : Res
req.setTimeout(0);
if (typeof req.file === 'undefined' && req.file === null) {
if (typeof req.file === 'undefined' || req.file === null) {
console.error('No file in upload');
return next('ERROR: Please model as ONNX file');
}