Download OCR_INDRA/tools/exp/remote_setup.sh from prosperious/ocr-projects-archive: direct link, hf CLI and curl.
- Browser
- Download file 3.28 kB
-
https://huggingface.co/prosperious/ocr-projects-archive/resolve/main/OCR_INDRA/tools/exp/remote_setup.sh
- Command line
-
hf download hf://prosperious/ocr-projects-archive/OCR_INDRA/tools/exp/remote_setup.sh
-
curl -L -o remote_setup.sh https://huggingface.co/prosperious/ocr-projects-archive/resolve/main/OCR_INDRA/tools/exp/remote_setup.sh
3.28 kB
| # Remote (khalti-t4) environment setup + probe. Run FIRST after cloning the bundle. | |
| # Usage: bash tools/exp/remote_setup.sh [--target PATH] [--torch-cpu] | |
| # | |
| # --target: pip --target deps dir (default $REPO/.deps) — matches local practice | |
| # when the box forbids venvs; prepend it to PYTHONPATH (the run sheets | |
| # and every tools/exp script already do this). | |
| # --torch-cpu: CPU-only torch wheel (default: CUDA wheel — needs nvidia-smi present). | |
| # | |
| # Both flags may be combined. Everything is installed with --upgrade so a | |
| # re-run repairs a partially-failed install. | |
| set -euo pipefail | |
| REPO=$(cd "$(dirname "$0")/../.." && pwd) | |
| DEPS="$REPO/.deps" | |
| TORCH_INDEX="" | |
| while [[ $# -gt 0 ]]; do | |
| case "$1" in | |
| --target) DEPS="$2"; shift 2 ;; | |
| --torch-cpu) TORCH_INDEX="--index-url https://download.pytorch.org/whl/cpu"; shift ;; | |
| *) echo "unknown arg $1"; exit 1 ;; | |
| esac | |
| done | |
| mkdir -p "$DEPS" "$REPO/results" | |
| cd "$REPO" # callable from anywhere (probe + selfcheck paths are repo-relative) | |
| echo "== probes ==" | |
| python3 -V || true | |
| python3 -m pip --version || pip --version || true | |
| nproc || true | |
| free -h || true | |
| df -h "$REPO" | tail -1 || true | |
| nvidia-smi || echo "(no nvidia-smi — CPU-only box?)" | |
| echo "== pip install into $DEPS ==" | |
| python3 -m pip install --quiet --target "$DEPS" --upgrade \ | |
| numpy opencv-python-headless pillow onnx onnxruntime \ | |
| safetensors pypdfium2 huggingface_hub | |
| python3 -m pip install --quiet --target "$DEPS" --upgrade $TORCH_INDEX torch | |
| echo "== import check + probe.json ==" | |
| REPO="$REPO" PYTHONPATH="$DEPS:$REPO/indra:$REPO/tools" python3 - <<'EOF' | |
| import json, os, sys, pathlib | |
| import numpy as np, cv2, PIL | |
| probe = {"python": sys.version.split()[0], "numpy": np.__version__, | |
| "cv2": cv2.__version__, "pillow": PIL.__version__} | |
| try: | |
| import torch | |
| probe["torch"] = torch.__version__ | |
| probe["cuda"] = torch.cuda.is_available() | |
| probe["cuda_device"] = torch.cuda.get_device_name(0) if probe["cuda"] else None | |
| probe["torch_amp_gradscaler"] = hasattr(torch, "amp") | |
| except Exception as ex: | |
| probe["torch"] = f"IMPORT FAIL: {ex}" | |
| try: | |
| import onnxruntime as ort | |
| probe["onnxruntime"] = ort.__version__ | |
| probe["ort_providers"] = ort.get_available_providers() | |
| except Exception as ex: | |
| probe["onnxruntime"] = f"IMPORT FAIL: {ex}" | |
| try: | |
| import onnx | |
| probe["onnx"] = onnx.__version__ | |
| except Exception as ex: | |
| probe["onnx"] = f"IMPORT FAIL: {ex}" | |
| from indra_ocr.vocab import Vocab | |
| probe["indra_vocab_classes"] = Vocab.multi().n_classes | |
| repo = pathlib.Path(os.environ["REPO"]) | |
| out = repo / "results" / "probe.json" | |
| out.parent.mkdir(parents=True, exist_ok=True) | |
| out.write_text(json.dumps(probe, indent=1) + "\n") | |
| print(json.dumps(probe, indent=1)) | |
| print(f"wrote {out}") | |
| EOF | |
| echo "== sanity: recognizer selfcheck (needs safetensors) ==" | |
| PYTHONPATH="$DEPS:$REPO/indra:$REPO/tools" python3 tools/exp/train_rec.py --selfcheck | |
| echo "== sanity: full offline verification chain (export + exactness + smoke) ==" | |
| PYTHONPATH="$DEPS:$REPO/indra:$REPO/tools" bash tools/exp/verify_bundle.sh || { | |
| echo "verify_bundle.sh FAILED — STOP and report before touching any data"; exit 1; } | |
| echo "DONE. Paste results/probe.json + results/verify/*.json back into the session." | |