@echo off
setlocal
set "BASE=%~dp0"
set "ENV_DIR=%LOCALAPPDATA%\MCAT_UNET\py311"
set "PY="
if exist "%ENV_DIR%\python.exe" set "PY=%ENV_DIR%\python.exe"
if not defined PY if exist "%ENV_DIR%\Scripts\python.exe" set "PY=%ENV_DIR%\Scripts\python.exe"
set "SCRIPT=%BASE%mcat_learn_unet1d_1_3.py"

if not defined PY (
  echo Python environment not found: %ENV_DIR%\python.exe or %ENV_DIR%\Scripts\python.exe
  echo Run Setup_unet1d_1_3_env.bat first.
  pause
  exit /b 1
)

if not exist "%SCRIPT%" (
  echo Script not found: %SCRIPT%
  pause
  exit /b 1
)

set "KMP_DUPLICATE_LIB_OK=TRUE"
set "PATH=%ENV_DIR%;%ENV_DIR%\Library\bin;%ENV_DIR%\Scripts;%PATH%"
set "MCAT_UNET_DEVICE=auto"
set "MCAT_UNET_SAVE_PTH=0"
"%PY%" "%SCRIPT%"
if errorlevel 1 pause
endlocal
