rem echo %CM_PYTHON_BIN%
rem echo %CM_DATASET_PATH%
rem echo %CM_DATASET_AUX_PATH%
rem echo %CM_ML_MODEL_FILE_WITH_PATH%

rem connect CM intelligent components with CK env
set CK_ENV_ONNX_MODEL_ONNX_FILEPATH=%CM_ML_MODEL_FILE_WITH_PATH%
set CK_ENV_ONNX_MODEL_INPUT_LAYER_NAME=input_tensor:0
set CK_ENV_ONNX_MODEL_OUTPUT_LAYER_NAME=softmax_tensor:0
set CK_ENV_DATASET_IMAGENET_VAL=%CM_DATASET_PATH%
set CK_CAFFE_IMAGENET_SYNSET_WORDS_TXT=%CM_DATASET_AUX_PATH%\synset_words.txt
set ML_MODEL_DATA_LAYOUT=NCHW
set CK_BATCH_SIZE=%CM_BATCH_SIZE%
set CK_BATCH_COUNT=%CM_BATCH_COUNT%

IF NOT DEFINED CM_TMP_CURRENT_SCRIPT_PATH SET CM_TMP_CURRENT_SCRIPT_PATH=%CD%

IF DEFINED CM_INPUT SET CM_IMAGE=%CM_INPUT%

echo.
%CM_PYTHON_BIN_WITH_PATH% -m pip install -r %CM_TMP_CURRENT_SCRIPT_PATH%\requirements.txt
IF %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL%

echo.
%CM_PYTHON_BIN_WITH_PATH% %CM_TMP_CURRENT_SCRIPT_PATH%\src\onnx_classify.py
IF %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL%

rem Just a demo to pass environment variables from native scripts back to CM workflows
echo CM_APP_IMAGE_CLASSIFICATION_ONNX_PY=sucess > tmp-run-env.out
