bashkir-trocr-base / start_ocr.bat
failed09's picture
Initial public release of BashkirTrOCR v3 (ONNX FP16 CUDA & INT8 CPU)
c8cdee4 verified
Raw History Blame Contribute Delete
1.4 kB
@echo off
setlocal
cd /d "%~dp0"
title Bashkir OCR Studio v3
echo [1] CPU - ONNX INT8
echo [2] NVIDIA GPU - ONNX FP16
echo [3] Auto - detect NVIDIA GPU (FP16) or fall back to CPU (INT8)
set "OCR_MODE="
set /p "OCR_MODE=Choose mode [1/2/3, default 3]: "
if "%OCR_MODE%"=="" set "OCR_MODE=3"
set "OCR_BACKEND=cpu"
set "OCR_RUN_BACKEND=cpu"
if "%OCR_MODE%"=="2" (
set "OCR_BACKEND=gpu"
set "OCR_RUN_BACKEND=gpu"
)
if "%OCR_MODE%"=="3" (
set "OCR_RUN_BACKEND=auto"
if exist ".venv-gpu\.ready" (
set "OCR_BACKEND=gpu"
) else (
nvidia-smi >nul 2>&1
if not errorlevel 1 set "OCR_BACKEND=gpu"
)
)
set "OCR_ENV=.venv-%OCR_BACKEND%"
if exist "%OCR_ENV%\.ready" goto LAUNCH
echo First start (%OCR_BACKEND%): Python 3.11-3.13 and internet access are needed to install dependencies.
python --version >nul 2>&1
if errorlevel 1 (
echo Install Python from python.org and enable Add Python to PATH.
goto FINISH
)
if not exist "%OCR_ENV%\Scripts\python.exe" python -m venv "%OCR_ENV%"
if errorlevel 1 goto FINISH
"%OCR_ENV%\Scripts\python.exe" -m pip install -r "requirements-%OCR_BACKEND%.txt"
if errorlevel 1 (
echo Installation failed. Check your connection, then run install again:
echo %OCR_ENV%\Scripts\python.exe -m pip install -r requirements-%OCR_BACKEND%.txt
goto FINISH
)
type nul > "%OCR_ENV%\.ready"
:LAUNCH
"%OCR_ENV%\Scripts\python.exe" studio.py --backend %OCR_RUN_BACKEND%
:FINISH
pause