AnseMin commited on
Commit
98f25ae
·
1 Parent(s): 5367fe1

resolving compatiability issue with docling and GOT OCR

Browse files
Files changed (4) hide show
  1. app.py +21 -0
  2. build.sh +10 -7
  3. requirements.txt +17 -10
  4. setup.sh +7 -4
app.py CHANGED
@@ -134,5 +134,26 @@ except ModuleNotFoundError:
134
  # Call setup function at import time
135
  setup_tesseract()
136
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  if __name__ == "__main__":
138
  main()
 
134
  # Call setup function at import time
135
  setup_tesseract()
136
 
137
+ # Add this near the top of app.py after imports
138
+ # Handle potential import conflicts
139
+ try:
140
+ import transformers
141
+ print(f"Transformers version: {transformers.__version__}")
142
+ except ImportError:
143
+ print("Warning: Transformers not installed or not working")
144
+
145
+ try:
146
+ import torch
147
+ print(f"Torch version: {torch.__version__}")
148
+ print(f"CUDA available: {torch.cuda.is_available()}")
149
+ except ImportError:
150
+ print("Warning: PyTorch not installed or not working")
151
+
152
+ try:
153
+ import docling
154
+ print(f"Docling version: {docling.__version__ if hasattr(docling, '__version__') else 'unknown'}")
155
+ except ImportError:
156
+ print("Warning: Docling not installed or not working")
157
+
158
  if __name__ == "__main__":
159
  main()
build.sh CHANGED
@@ -78,17 +78,20 @@ echo "Installing Google Gemini API client..."
78
  pip install -q -U google-genai
79
  echo "Google Gemini API client installed successfully"
80
 
81
- # Install GOT-OCR dependencies
82
  echo "Installing GOT-OCR dependencies..."
83
- # Install transformers and other dependencies first
84
- pip install -q -U transformers==4.37.2 tiktoken==0.6.0 verovio==4.3.1 accelerate==0.28.0 safetensors==0.4.0
85
- # Install torch and torchvision separately with --no-deps to avoid conflicts
86
  pip install -q -U torch==2.0.1 torchvision==0.15.2 --no-deps
 
87
  echo "GOT-OCR dependencies installed successfully"
88
 
89
- # Install Python dependencies
90
- echo "Installing Python dependencies..."
91
- pip install -e .
 
 
 
 
 
92
 
93
  # Create .env file if it doesn't exist
94
  if [ ! -f .env ]; then
 
78
  pip install -q -U google-genai
79
  echo "Google Gemini API client installed successfully"
80
 
81
+ # Install GOT-OCR dependencies first
82
  echo "Installing GOT-OCR dependencies..."
 
 
 
83
  pip install -q -U torch==2.0.1 torchvision==0.15.2 --no-deps
84
+ pip install -q -U transformers==4.37.2 tiktoken==0.6.0 verovio==4.3.1 accelerate==0.28.0 safetensors==0.4.0
85
  echo "GOT-OCR dependencies installed successfully"
86
 
87
+ # Install docling separately with --no-deps to avoid conflicts
88
+ echo "Installing docling..."
89
+ pip install -q -U docling==2.25.0 --no-deps
90
+ echo "Docling installed successfully"
91
+
92
+ # Install remaining Python dependencies
93
+ echo "Installing remaining Python dependencies..."
94
+ pip install -e . --no-deps
95
 
96
  # Create .env file if it doesn't exist
97
  if [ ! -f .env ]; then
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
- docling==2.25.0
2
  gradio==5.14.0
3
  grpcio-status==1.70.0
4
  markdown==3.7
@@ -9,28 +9,35 @@ pytesseract==0.3.13
9
  semchunk==2.2.2
10
  Pillow>=9.0.0
11
  numpy>=1.21.0
 
12
  # Tesseract dependencies
13
  tesseract==0.1.3
14
  tesserocr>=2.5.0; platform_system != "Windows" # Only install on non-Windows systems
 
15
  # Additional dependencies for image processing
16
  opencv-python-headless>=4.5.0 # Headless version for server environments
17
  pdf2image>=1.16.0 # For PDF processing
18
  dill==0.3.8 # Downgraded to be compatible with datasets
 
19
  # Gemini API client
20
  google-genai>=0.1.0
 
21
  # Environment variables
22
  python-dotenv>=1.0.0
 
23
  # Pin pydantic to resolve compatibility issues with gradio
24
  pydantic==2.7.1
25
 
26
- # GOT-OCR dependencies - pinned versions to avoid conflicts
27
- transformers==4.37.2 # Exact version for GOT-OCR2
28
- tiktoken==0.6.0
29
- verovio==4.3.1
30
- accelerate==0.28.0
31
- safetensors>=0.4.0
32
  packaging>=21.0 # For version comparison
 
33
 
34
- # Torch dependencies - install separately to avoid conflicts
35
- # torch==2.0.1
36
- # torchvision==0.15.2
 
 
 
 
 
 
 
1
+ # Core dependencies
2
  gradio==5.14.0
3
  grpcio-status==1.70.0
4
  markdown==3.7
 
9
  semchunk==2.2.2
10
  Pillow>=9.0.0
11
  numpy>=1.21.0
12
+
13
  # Tesseract dependencies
14
  tesseract==0.1.3
15
  tesserocr>=2.5.0; platform_system != "Windows" # Only install on non-Windows systems
16
+
17
  # Additional dependencies for image processing
18
  opencv-python-headless>=4.5.0 # Headless version for server environments
19
  pdf2image>=1.16.0 # For PDF processing
20
  dill==0.3.8 # Downgraded to be compatible with datasets
21
+
22
  # Gemini API client
23
  google-genai>=0.1.0
24
+
25
  # Environment variables
26
  python-dotenv>=1.0.0
27
+
28
  # Pin pydantic to resolve compatibility issues with gradio
29
  pydantic==2.7.1
30
 
31
+ # Common dependencies - not pinned to allow resolution
 
 
 
 
 
32
  packaging>=21.0 # For version comparison
33
+ safetensors>=0.4.0
34
 
35
+ # Note: The following packages will be installed separately in setup.sh and build.sh
36
+ # to avoid dependency conflicts:
37
+ # - docling
38
+ # - transformers
39
+ # - torch
40
+ # - torchvision
41
+ # - tiktoken
42
+ # - verovio
43
+ # - accelerate
setup.sh CHANGED
@@ -18,14 +18,17 @@ pip install -q -U pytesseract pillow opencv-python-headless pdf2image
18
  pip install -q -U google-genai
19
  echo "Python dependencies installed successfully"
20
 
21
- # Install GOT-OCR dependencies
22
  echo "Installing GOT-OCR dependencies..."
23
- # Install transformers and other dependencies first
24
- pip install -q -U transformers==4.37.2 tiktoken==0.6.0 verovio==4.3.1 accelerate==0.28.0 safetensors==0.4.0
25
- # Install torch and torchvision separately with --no-deps to avoid conflicts
26
  pip install -q -U torch==2.0.1 torchvision==0.15.2 --no-deps
 
27
  echo "GOT-OCR dependencies installed successfully"
28
 
 
 
 
 
 
29
  # Install tesserocr with pip
30
  echo "Installing tesserocr..."
31
  pip install -q -U tesserocr || echo "Failed to install tesserocr with pip, trying with specific compiler flags..."
 
18
  pip install -q -U google-genai
19
  echo "Python dependencies installed successfully"
20
 
21
+ # Install GOT-OCR dependencies first
22
  echo "Installing GOT-OCR dependencies..."
 
 
 
23
  pip install -q -U torch==2.0.1 torchvision==0.15.2 --no-deps
24
+ pip install -q -U transformers==4.37.2 tiktoken==0.6.0 verovio==4.3.1 accelerate==0.28.0 safetensors==0.4.0
25
  echo "GOT-OCR dependencies installed successfully"
26
 
27
+ # Install docling separately with --no-deps to avoid conflicts
28
+ echo "Installing docling..."
29
+ pip install -q -U docling==2.25.0 --no-deps
30
+ echo "Docling installed successfully"
31
+
32
  # Install tesserocr with pip
33
  echo "Installing tesserocr..."
34
  pip install -q -U tesserocr || echo "Failed to install tesserocr with pip, trying with specific compiler flags..."