mbuckle commited on
Commit
582f6bc
·
1 Parent(s): 7829b2b

Add Monkey Patch

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -52,6 +52,21 @@ def fix_ssl_library():
52
  print(f"Failed to install libssl1.1: {e}")
53
  return False
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  # Try alternative PaddlePaddle versions
56
  def try_paddle_import():
57
  """Try different approaches to import PaddleOCR"""
 
52
  print(f"Failed to install libssl1.1: {e}")
53
  return False
54
 
55
+ def monkey_patch_pymupdf():
56
+ """Fix PaddleOCR compatibility with newer PyMuPDF versions"""
57
+ import fitz
58
+
59
+ # Add pageCount property to Document class if it doesn't exist
60
+ if not hasattr(fitz.Document, 'pageCount'):
61
+ def pageCount_property(self):
62
+ return self.page_count
63
+
64
+ fitz.Document.pageCount = property(pageCount_property)
65
+ print("Added pageCount compatibility property to PyMuPDF Document class")
66
+
67
+ # Apply the monkey patch before importing PaddleOCR
68
+ monkey_patch_pymupdf()
69
+
70
  # Try alternative PaddlePaddle versions
71
  def try_paddle_import():
72
  """Try different approaches to import PaddleOCR"""