Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,16 @@ from io import StringIO
|
|
| 2 |
import sys
|
| 3 |
|
| 4 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
#from huggingface_hub import login
|
| 6 |
import gradio as gr
|
| 7 |
import json
|
|
@@ -68,9 +78,6 @@ if not GROQ_API_KEY:
|
|
| 68 |
|
| 69 |
EMBED_MODEL_ID = "sentence-transformers/all-MiniLM-L6-v2"
|
| 70 |
|
| 71 |
-
# Set EasyOCR cache directory to a writable location
|
| 72 |
-
os.environ["EASYOCR_CACHE_DIR"] = "/app/.EASYOCR"
|
| 73 |
-
|
| 74 |
# =============================================================================
|
| 75 |
# Document Extraction Functions
|
| 76 |
# =============================================================================
|
|
|
|
| 2 |
import sys
|
| 3 |
|
| 4 |
import os
|
| 5 |
+
# Set EasyOCR cache directory to a writable location
|
| 6 |
+
os.environ["EASYOCR_CACHE_DIR"] = "/app/.EASYOCR"
|
| 7 |
+
import easyocr
|
| 8 |
+
# Monkey-patch the easyocr.Reader to force the model_storage directory parameter
|
| 9 |
+
_original_reader = easyocr.Reader
|
| 10 |
+
def custom_reader(langs, **kwargs):
|
| 11 |
+
kwargs.setdefault("model_storage_directory", "/app/.EasyOCR")
|
| 12 |
+
return _original_reader(langs, **kwargs)
|
| 13 |
+
easyocr.Reader = custom_reader
|
| 14 |
+
|
| 15 |
#from huggingface_hub import login
|
| 16 |
import gradio as gr
|
| 17 |
import json
|
|
|
|
| 78 |
|
| 79 |
EMBED_MODEL_ID = "sentence-transformers/all-MiniLM-L6-v2"
|
| 80 |
|
|
|
|
|
|
|
|
|
|
| 81 |
# =============================================================================
|
| 82 |
# Document Extraction Functions
|
| 83 |
# =============================================================================
|