pi-ocr 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -46,13 +46,26 @@ def progress(payload):
46
46
 
47
47
  progress({"status": "loading", "message": "Initializing Pix2Text models..."})
48
48
 
49
+ # Auto-detect optimal GPU device
50
+ import torch
51
+ if torch.cuda.is_available():
52
+ _device = "cuda"
53
+ elif hasattr(torch.backends, "mps") and torch.backends.mps.is_available():
54
+ _device = "mps"
55
+ else:
56
+ _device = "cpu"
57
+
58
+ # Prevent MPS memory fragmentation on macOS
59
+ if _device == "mps":
60
+ os.environ.setdefault("PYTORCH_MPS_HIGH_WATERMARK_RATIO", "0.0")
61
+
49
62
  # Suppress model-loading noise on stdout during initialization
50
63
  _real_stdout = sys.stdout
51
64
  sys.stdout = sys.stderr
52
65
 
53
66
  try:
54
67
  from pix2text import Pix2Text
55
- p2t = Pix2Text.from_config(enable_formula=True, enable_table=False)
68
+ p2t = Pix2Text.from_config(enable_formula=True, enable_table=False, device=_device)
56
69
  finally:
57
70
  sys.stdout = _real_stdout
58
71
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-ocr",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Pi extension: Zero-setup multi-backend OCR — MinerU (free cloud), Ollama (local GPU, LaTeX formulas), Pix2Text (local Python). Extract text, formulas, and tables from images and PDFs. Default: zero config, works out of the box.",
5
5
  "keywords": [
6
6
  "pi-package",